function loadPopup( url, w, h, s ){
	var winRef = window.open(url, "hello", "width="+w+", height="+h+", fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars="+s+",resizable=no,directories=no,location=no");
	winRef.focus();
}

function globalPrintCheck(printUrl) {
	if (document.getElementById('globalPrint')) {
		document.getElementById('globalPrint').getElementsByTagName('a')[0].href = "javascript:loadPopup('"+printUrl+"','712','450','yes');";
	}
}

function loadSpins(spinsUrlIE,spinsUrl) {
//	if (navigator.appName == 'Microsoft Internet Explorer') {
		spinswindow = window.open(spinsUrlIE,'3Dspins','width=700,height=350,fullscreen=no,toolbar=no,status=yes,menubar=no,scrollbars=no,resizable=no,directories=no,location=no');
//	}
//	else { window.frames['contentFrame'].location.href = spinsUrl; }
}

function scaleFrame(obj){
	document.getElementById('vehicledetailsDiv').innerHTML = window.frames['contentFrame'].document.body.innerHTML;
}

function switchTab(btnRef,state) {
	var classRef = 'detailsTabOut';

	if ((state == 'clicked') || (btnRef.className == 'detailsTabClicked')) {
		if (typeof(oldBtnRef) != 'undefined') {
			oldBtnRef.className = classRef;
			oldBtnRef.childNodes[0].className = classRef+'Span';
		}
		classRef = 'detailsTabClicked';
		oldBtnRef = btnRef;
	}
	else if (state == 'over') { classRef = 'detailsTabOver'; }

	btnRef.className = classRef;
	btnRef.childNodes[0].className = classRef+'Span';
}

var largerImage = false;
function resizeImg(imgRef) {
    if(!document.getElementById('largePhotoLink')) return; //DNA609354 added check for largePhotoLink
    
    var phototest = new Image();
	phototest.src = imgRef.src;
	if ((phototest.width > 320) || (phototest.height > 240)) {
		document.getElementById('largePhotoLink').style.cursor = 'hand';
		document.getElementById('largePhotoNote').style.display = 'block';
		largerImage = true;
	}
	else {
		document.getElementById('largePhotoLink').style.cursor = 'default';
		document.getElementById('largePhotoNote').style.display = 'none';
		largerImage = false;
	}
}

function loadVehicleImage(url) {
	if(largerImage) { loadPopup(url,'340','250','yes'); }
}

/* slide show */
var photoMax = 0;
var photoCnt = 1;

function slideShow() {
	if (typeof(document.images['carImage']) != 'undefined') {
		var carImageRef = document.images['carImage'];
		if (carImageRef.filters) {
			carImageRef.style.filter="blendTrans(duration=1)";
			carImageRef.filters.blendTrans(duration=5).Apply();
			carImageRef.filters.blendTrans.Play();
		}
		carImageRef.src = document.images['vehicleImage'+photoCnt++].src.replace(/thumb_/g,'');
		if (photoCnt >= photoMax) { photoCnt = 0; }
	}
}

function startSlideShow() {
	if (typeof(slideShowTimer) != 'undefined') { clearInterval(slideShowTimer); }
	slideShowTimer = setInterval("slideShow();",5000);
}

/* thumb spins */
var extSpins = new Array();
var intSpins = new Array();
var extSpinCnt = 0;
var intSpinCnt = 0;

function thumbSpins() {
	if (typeof(document.images['extSpinThumb']) != 'undefined') {
		var extSpinRef = document.images['extSpinThumb'];
		var intSpinRef = document.images['intSpinThumb'];
		if (extSpinRef.filters) {
			extSpinRef.style.filter="blendTrans(duration=0.5)";
			extSpinRef.filters.blendTrans(duration=0.5).Apply();
			extSpinRef.filters.blendTrans.Play();
			intSpinRef.style.filter="blendTrans(duration=0.5)";
			intSpinRef.filters.blendTrans(duration=0.5).Apply();
			intSpinRef.filters.blendTrans.Play();
		}
		extSpinRef.src = extSpins[extSpinCnt++];
		intSpinRef.src = intSpins[intSpinCnt++];
		if (extSpinCnt >= extSpins.length) { extSpinCnt = 0; }
		if (intSpinCnt >= intSpins.length) { intSpinCnt = 0; }
	}
}

function startThumbSpins() {
	if (typeof(thumbSpinsTimer) != 'undefined') { clearInterval(thumbSpinsTimer); }
	thumbSpinsTimer = setInterval("thumbSpins();",2000);
}

function showLargeImage(imgRef) {
	if (typeof(slideShowTimer) != 'undefined') { clearInterval(slideShowTimer); }
	switchImage('carImage',imgRef);
}

