var cars_dtflash = new dt.flash("cars.swf?c="+new Date().getTime(), "100%", "284", "transparent");

function fl(exp_txt) {
	try { eval(exp_txt) }catch(e){}
}

function initInitialTextFocus(field_txt) {

	try {
	
		var _el = $(field_txt);
	
		$extend(_el, {
			otext:_el.value,
			oclass:_el.className
		});
		
		_el.addEvents({
			'focus':function(){
				this.className = this.oclass+'_';
				if (this.value == this.otext) this.value = "";
			},
			'blur':function(){
				if (this.value == "") {
					this.value = this.otext;
					this.className = this.oclass;
				}
			}
		});
	
	} catch(e) { initInitialTextFocus.delay(50) }

}

function updateFlashHeight(id_txt, height_num) {

	try {

		$(id_txt).setStyles({
			height: Math.floor(height_num)+'px'
		});
		
	}catch(e){updateFlashHeight.delay(500, '', [id_txt, height_num])}
	
}


function initInitialH1Flash() {

	var _el, uid_txt, h1_dtflash = new dt.flash("title.swf?c="+new Date().getTime(), "100%", "100%", "transparent");

	try {
		
		if ($$('h1[id=title-flash]').length > 0) {

			_el = $$('h1[id=title-flash]')[0];
			
			if (h1_dtflash._version >= 8) {
			
				uid_txt = "uid"+$random(0,9999);
				
				_el.setStyles({
					height:'30px'
				});
				
				_el.setProperty('id', uid_txt);
				
				h1_dtflash.add("title_txt", encodeURIComponent(_el.innerHTML.split('+').join('%2B')));
				h1_dtflash.add("id_txt", uid_txt);
				h1_dtflash.attach(uid_txt);
			
			}
			
			_el.setStyles({
				visibility:'visible'
			});
			
			if ($$('h1[id=title-flash]').length > 0) initInitialH1Flash.delay(100);
			
		}

	} catch(e) { initInitialH1Flash.delay(100) }
	
}

function initializePage(_obj) {
	
	cars_dtflash.add("xml", _obj.xml==undefined?"_xml/cars.asp":_obj.xml);
	cars_dtflash.add("root", _obj.root==undefined?"":_obj.root);
	cars_dtflash.add("showarrows", _obj.arrows==undefined?true:_obj.arrows);
	cars_dtflash.add("defaultcar", _obj.defaultcar==undefined?"":_obj.defaultcar);
	cars_dtflash.add("allcars", _obj.allcars==undefined?"false":_obj.allcars);
	
	cars_dtflash._height = _obj._height==undefined?cars_dtflash._height:_obj._height;
	cars_dtflash._width = _obj._width==undefined?cars_dtflash._width:_obj._width;
	
	cars_dtflash._requiredversion = 8;
	cars_dtflash._noflash = '<div class="noflashinside" style="height:200px">Portions of this site are displayed using the free Flash player.<br>Flash Version 8 or higher is required.<br><a href="http://www.adobe.com/go/EN_US-H-GET-FLASH">Get Flash now</a></div>';
	
	cars_dtflash.attach("cars-flash-inside");
	
	window.addEvent('domready', initInitialH1Flash);
	
}

// Image Gallery
var gallery_bln = null;
function showGalleryImage(img) {
	
	gallery_bln = null;
	
	window.open('popup_gallery.asp?src='+img, 'popup_gallery', 'status=yes,resizable=yes,width=140,height=130')
	
	setTimeout(function(){
		if (gallery_bln != true) alert('You may have a popup blocker installed which is preventing the larger version of this image from loading.');
		gallery_bln = true;
	}, 3000);

}
