

try {document.execCommand("BackgroundImageCache", false, true);} catch(err) {}

if(page=="unit"){
	var Gal = new Array();
	Gal[0]='photos/'+comName+'/'+base+'_a.jpg'
	Gal[1]='../../scripts/images/layout/gControls.gif' /* could not find this file as part of the project; created a clearpixel with this name & left this line in case it would break something else */
	Gal[2]='../../scripts/images/layout/bar_bg.gif'
	Gal[3]='../../scripts/images/layout/redbar_bg.gif'
	Gal[4]='../../scripts/images/layout/blank.gif'
	Gal[5]='../../scripts/images/layout/open_bg.gif'
	for(var i=1;i<alpha.length;i++){
		Gal[i+5]='http://'+domain+'/photos/'+comName+'/'+base+'_'+alpha[i]+'.jpg'
	}
}else{
	var Gal = new Array();
	Gal[0]='../../scripts/images/layout/bar_bg.gif'
	Gal[1]='../../scripts/images/layout/blank.gif'
	Gal[2]='../../scripts/images/layout/browse_sprite.gif'
	Gal[3]='../../scripts/images/layout/special_slope.gif'
}

var preLoad = new Array();
for (var r=0;r<Gal.length;r++){
   preLoad[r] = new Image();
   preLoad[r].src = Gal[r];
}

var last,last2,dur,dur2,dur3,dur4,dur5,textWidth,thanks;
var gonogo = 0;
var nrtop = 0;
var tnsp = 0;
var rate = 8;
var pos = 342;
var ftt = 0;
var PositionX = 10;
var PositionY = 10;
var defaultWidth  = 230;
var defaultHeight = 50;
var AutoClose = false;

var miniGalHeight = 21;

var nextPage = "price";

var ucImages = new Array();
ucImages[0]='qquote'
ucImages[1]='contact'
ucImages[2]='make_offer'
ucImages[3]='print'
ucImages[4]='credit'
ucImages[5]='email_friend'
ucImages[6]='drive'
ucImages[7]='pricing'

var ucImg = new Array;
var ucImgo = new Array;
for(var i=0;i<ucImages.length;i++) 
{
	ucImg[i] = new Image();
	ucImg[i].src='../../scripts/images/layout/uc/uc_'+ucImages[i]+'.gif';
	ucImgo[i] = new Image();
	ucImgo[i].src='../../scripts/images/layout/uc/uc_'+ucImages[i]+'_live.gif';
}
function ucOver(x) {
	document.getElementById("uc"+x).src = ucImgo[x].src;
}
function ucOff(x) {
	document.getElementById("uc"+x).src = ucImg[x].src;
}
function initUNav() {
	var x = [];
	for(var i=0;i<ucImages.length;i++)
	{
		x[i] = document.getElementById("uc"+i);
	}
	for(var i=0;i<x.length;i++)
	{
		x[i].onmouseover = function () {ucOver(this.id.substr(2))}
		x[i].onmouseout = function () {ucOff(this.id.substr(2))}
	}
}


/* an alternate version of the button code for the adRequest Form */
var uCtlImages = new Array();
uCtlImages[0]='info'
uCtlImages[1]='print'
uCtlImages[2]='credit'

var uCtlImg = new Array;
var uCtlImgo = new Array;
for(var i=0;i<uCtlImages.length;i++) 
{
	uCtlImg[i] = new Image();
	uCtlImg[i].src='../../scripts/images/layout/uc/uc_'+uCtlImages[i]+'.gif';
	uCtlImgo[i] = new Image();
	uCtlImgo[i].src='../../scripts/images/layout/uc/uc_'+uCtlImages[i]+'_live.gif';
}
function uCtlOver(x) {
	document.getElementById("uCtl"+x).src = uCtlImgo[x].src;
}
function uCtlOff(x) {
	document.getElementById("uCtl"+x).src = uCtlImg[x].src;
}
function initUctrlNav() {
	var x = [];
	for(var i=0;i<uCtlImages.length;i++)
	{
		x[i] = document.getElementById("uCtl"+i);
	}
	for(var i=0;i<x.length;i++)
	{
		x[i].onmouseover = function () {uCtlOver(this.id.substr(4))}
		x[i].onmouseout = function () {uCtlOff(this.id.substr(4))}
	}
}
function initAdRequest(){
	if(document.getElementById("marqText")){
		textWidth = document.getElementById("marqText").offsetWidth;
	}
	initUctrlNav();initForm();initMarq();
}

function initMarq() {
	clearTimeout(dur5);
	var M = document.getElementById("marquee");
	if(M){
		if(pos<0-textWidth){
			pos = 342;
		}
		pos--;
		M.style.left = pos+"px";
		dur5 = setTimeout("initMarq()",10);
	}
}

function selImg(x) {
	var img = document.getElementById("galImg");
	var miniimg = document.getElementById("mini"+x);
	var nailimg = document.getElementById("nail"+x);
	img.src = "http://"+domain+"/photos/"+comName+"/"+base+"_"+x+".jpg";
	if(last==null||last==""){}else{
		last.style.border = "1px solid #cdcdcd";
		last2.style.border = "1px solid #cdcdcd";
	}
	miniimg.style.border = "1px solid #ff0000";
	nailimg.style.border = "1px solid #ff0000";
	last = miniimg;
	last2 = nailimg;
}

function magImgSmall() {
	var img = document.getElementById("galImg").src;
	img = img.substring(0,img.lastIndexOf("/"))+"/Lrgphotos"+img.substring(img.lastIndexOf("/"));
	popImage(img,'');
}

function magImg() {
	//the clicked image
	var img = document.getElementById("galImg").src;
	
	//determine Img#
	var suffix;
	var letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
	var letter = img.substring(img.lastIndexOf("_")+1,img.lastIndexOf("."));
	for (i=0;i<=letters.length;i++) {
		if (letter==letters[i]) {
			suffix = i+1;
			break;
		}
	}
	
	//extract ImgName (aka Unit#)
	imgName = img.substring(img.lastIndexOf("/")+1, img.lastIndexOf("_"));
	
	//build the path
	img = "http://"+domain+"/stkPhotos/"+comName+"/"+imgName+"_s"+suffix+".jpg";
	
	//show the image in a popup
	popImage(img,'');
}

function play() {
	gonogo = 1;
	clearTimeout(dur);
	var img = document.getElementById("galImg");
	var pos = img.src.substr(img.src.search("_")+1,1);
	for(var i=0;i<alpha.length-1;i++)
	{
		if(pos==alpha[i]){
			selImg(alpha[i+1]);
			break;
		}else{
			selImg(alpha[0]);
		}
	}
	dur = setTimeout("play()",3000);
}
function ppC() {
	if(gonogo==0){
		play()
		document.getElementById("PPC").style.backgroundPosition = "0 -42px";
	}else{
		gonogo = 0;
		clearInterval(dur);
		document.getElementById("PPC").style.backgroundPosition = "0 -21px";
	}
}
function ocC() {
	var occ = document.getElementById("OCC");
	var south = document.getElementById("south");
	var east = document.getElementById("east");
	var galLeft = document.getElementById("galLeft");
	var galRight = document.getElementById("galRight");
	if(nrtop==0){
		openN();
		occ.style.backgroundPosition = "0 -84px";
		south.style.visibility = "hidden";
		east.style.width = "72px";
		east.style.paddingRight = "0px";
		south.style.width = "262px";
		galLeft.style.display = "inline";
		galRight.style.display = "inline";
	}else{
		closeN();
		occ.style.backgroundPosition = "0 -63px";
		south.style.visibility = "visible";
		east.style.width = "24px";
		east.style.paddingRight = "3px";
		south.style.width = "307px";
		galLeft.style.display = "none";
		galRight.style.display = "none";
	}
}
function openN() {
	clearTimeout(dur3);
	var nav = document.getElementById("galNav");
	var north = document.getElementById("north");
	var south = document.getElementById("south");
	var i = nav.offsetHeight
	north.style.display = "block";
	south.style.height = "21px";
	if(i<106){
		i = i + ((106-i)/rate);
		north.style.height = (i-22)+"px";
		nav.style.height = i+"px";
		dur3 = setTimeout("openN()",rate);
	}
	if(i>=106){
		nav.style.height = "105px";
	}
	nrtop = 1;
}
function closeN() {
	clearTimeout(dur3);
	var nav = document.getElementById("galNav");
	var north = document.getElementById("north");
	var south = document.getElementById("south");
	south.style.height = miniGalHeight+"px";
	var i = nav.offsetHeight
	if(i>(miniGalHeight+1)){
		i = i - ((i-rate)/rate);
		north.style.height = (i-(miniGalHeight+1))+"px";
		nav.style.height = i+"px";
		dur3 = setTimeout("closeN()",rate);
	}
	if(i<(miniGalHeight+1)){
		nav.style.height = miniGalHeight+"px";
		north.style.display = "none";
	}
	nrtop = 0;
}
function initGal() {
	if(document.getElementById("galImg").src.search("newonlot")!=-1){
		return;
	} else if (document.getElementById("galImg").src.search("Models")!=-1){
		return;
	}
	if(autoplay=="1"){
		selImg(alpha[alpha.length-1]);
		ppC();
	}else{
		selImg(alpha[0]);
	}
	var x = [];
	var y = [];
	for(var i=0;i<alpha.length;i++) {
		x[i] = document.getElementById("nail"+alpha[i]);
		y[i] = document.getElementById("mini"+alpha[i]);
	}
	for(var i=0;i<x.length;i++) {
		if ((x[i]!= null) && (x[i]!= null)) {
		x[i].onmouseover = y[i].onmouseover = function () {selImg(this.id.substr(4));}
		x[i].onclick = y[i].onclick = function () {magImg();}
		}
	}
	var south = document.getElementById("south");
	var nav = document.getElementById("galNav");
	if (alpha.length <= 12) {
		miniGalHeight = 21;
	} else {
		miniGalHeight = 42;
	}
	south.style.height = miniGalHeight+"px";
	nav.style.height = miniGalHeight+"px";
}
function slideNail(x) {
	clearTimeout(dur2);
	var slide = document.getElementById("galSlide");
	if(x=="left"){
		if(tnsp<378-(document.getElementById("galSlide").getElementsByTagName("IMG").length*105)){
			return false;
		}
		tnsp-=2;
		slide.style.marginLeft = tnsp +"px";
		dur2 = setTimeout("slideNail('left')",1);
	}else if(x=="right"){
		if(tnsp==0){
			return false;
		}
		tnsp+=2;
		slide.style.marginLeft = tnsp +"px";
		dur2 = setTimeout("slideNail('right')",1);
	}
	if(x=="stop"){
		clearTimeout(dur2);
	}
}
function expand(id,x){
	var ex = document.getElementById(id);
	if(x==1) {
		ex.style.display = "block";
	}else{
		ex.style.display = "none";
	}
}
function delFrame(){
	var node=document.getElementById('googleHit');
	node.innerHTML='';
	clearTimeout(frame);
}
function showForm(name){
	clearTimeout(thanks);
	var form = document.getElementById(name+"_form");
	var noform = document.getElementById("price_form");
	var x = document.getElementById("formsArena").getElementsByTagName("FORM");
	if(form.style.display==""||form.style.display==null||form.style.display=="none"){
		noform.style.display = "none";
		for(var i=0;i<x.length;i++)
		{
			x[i].style.display = "none";
		}
		form.style.display = "block";
		clearTimeout(dur4);
	}else{
		form.style.display = "none";
		noform.style.display = "block";
		initMarq();
	}
}
function initForm(next) {
	var x = document.getElementById("formsArena").getElementsByTagName("FORM");
	
	for(var i=0;i<x.length;i++)
	{
		if ( (next === undefined) || (next == "") || (next == null) ) {
			x[i].onsubmit = function () {return validate(this.id)}
		} else {
			x[i].onsubmit = function () {return validate(this.id,next)}
		}
	}
}
function validate(id,next) {
	
	var form = document.getElementById(id);
	
	//botFilter - the SpamCatcher
	if(form.emailBot.value !== "") {
		showForm('confirm');
		return false;
	}
	
	if(form.First_Name.value == ""){
		alert("Please fill in your First Name.")
		form.First_Name.focus()
		return false;
	}
	if(form.Last_Name.value == ""){
		alert("Please fill in your Last Name.")
		form.Last_Name.focus()
		return false;
	}
	if(form.Customer_eMail952.value == ""){
		alert("Please fill in your Email.")
		form.Customer_eMail952.focus()
		return false;
	}else{
		var at="@"
		var dot="."
		var str = form.Customer_eMail952.value;
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid Email")
		   form.Customer_eMail952.focus()
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid Email")
		   form.Customer_eMail952.focus()
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Invalid Email")
			form.Customer_eMail952.focus()
			return false;
		}
		if (str.indexOf(at,(lat+1))!=-1){
			alert("Invalid Email")
			form.Customer_eMail952.focus()
			return false;
		}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Invalid Email")
			form.Customer_eMail952.focus()
			return false;
		}
		if (str.indexOf(dot,(lat+2))==-1){
			alert("Invalid Email")
			form.Customer_eMail952.focus()
			return false;
		}
		if (str.indexOf(" ")!=-1){
			alert("Invalid Email")
			form.Customer_eMail952.focus()
			return false;
		}
	}
/* 
	if(form.Phone.value == ""){
		alert("Please fill in your Phone Number.")
		form.Phone.focus()
		return false;
	}else{
		var str = form.Phone.value;
		for(var i=0;i<str.length;i++){
			var char = str.substr(i,1);
			if(isNaN(char)){
				str = str.substring(0,i) + str.substr(i+1);
				i--;
			}
		}
		if(str.length != 10){
			alert("Invalid Phone Number")
			form.Phone.focus()
			return false;
		}else{
			form.Phone.value = str;
		}
	}
*/
	showForm('confirm');
	
	if (window.pageTracker === undefined) {
	} else {
		pageTracker._trackPageview("/FORM_SUBMITTED/"+id); 
	}
	
	
	if ( (next === undefined) || (next == "") || (next == null) ) {
	} else {
		nextPage = next;
	}
	
	if (page=="unit") {
		thanks = setTimeout("showForm(nextPage)",3000);
	}
}


function initUnit(next){
	if(document.getElementById("marqText")){
		textWidth = document.getElementById("marqText").offsetWidth;
	}
	if ( (next === undefined) || (next == "") || (next == null) ) {
	initGal();initUNav();initForm();initMarq();
	} else {
	initGal();initUNav();initForm(next);initMarq();
	}
}

function initMobile(next){
	if ( (next === undefined) || (next == "") || (next == null) ) {
		initForm();
	} else {
		initForm(next);
	}
}

function popImage(imageURL,imageTitle){
	var imgWin = window.open('','_blank','scrollbars=1,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'+
	'<html xmlns="http://www.w3.org/1999/xhtml"><head><title>'+imageTitle+'<\/title><'+'script type="text\/javascript">\n'+
	'function resizeWinTo() {\n'+ 
	'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }\n'+
	'var oH = document.images[0].height, oW = document.images[0].width;\n'+
	'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
	'window.doneAlready = true;\n'+ //for Safari and Opera
	'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
	'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
	'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
	'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
	'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
	'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
	'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
	'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
	'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
	'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
	'}\n'+
	'<\/script>'+
	'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
	(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
	'<img src="'+imageURL+'" alt="Loading image ..." title="" onload="resizeWinTo();" />'+
	(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if(imgWin.focus) { imgWin.focus(); }
	return false;
}
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=370,height=360');");
}
function popUp2(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=510,height=440');");
}
function comboItemSelected(oList1,oList2){
	if(oList2!=null){
		clearComboOrList(oList2);
		if(oList1.selectedIndex == -1){
			oList2.options[oList2.options.length] = new Option('List All or Select..', '');
		}else{
			fillCombobox(oList2, oList1.name + '=' + oList1.options[oList1.selectedIndex].value);
		}
	}
	if(oList1.selectedIndex==0){
		oList2.options[0] = new Option('Select Make First...','');
	}
}
function clearComboOrList(oList){
	for(var i=oList.options.length-1;i>=0;i--)
	{
		oList.options[i] = null;
	}
	oList.selectedIndex = -1;
	if(oList.onchange){
		oList.onchange();
	}
}
function fillCombobox(oList, vValue){
	if(vValue != ''){
		if(assocArray[vValue]){
			oList.options[0] = new Option('List All or Select...','');
			var arrX = assocArray[vValue];
			for (var i=0;i<arrX.length;i=i+2)
			{
				if(arrX[i] != 'EOF'){
					oList.options[oList.options.length] = new Option(arrX[i + 1].split('&amp;').join('&'), arrX[i]);
				}
			}
			if(oList.options.length == 1){
				oList.selectedIndex=0;
				if(oList.onchange){
					oList.onchange();
				}
			}
		}else{
			oList.options[0] = new Option('None found','');
		}
	}
}
function fillListbox(oList, vValue){
	if(vValue != ''){
		if(assocArray[vValue]){
			var arrX = assocArray[vValue];
			for (var i=0;i<arrX.length;i=i+2)
			{
				if(arrX[i] != 'EOF'){
					oList.options[oList.options.length] = new Option(arrX[i + 1].split('&amp;').join('&'), arrX[i]);
				}
			}
			if(oList.options.length == 1){
				oList.selectedIndex=0;
				if(oList.onchange){
					oList.onchange();
				}
			}
		}else{
			oList.options[0] = new Option('None found','');
		}
	}
}
function IEzIndex() {
	var x = document.getElementById("inventory").getElementsByTagName("DIV");
	for(var i=0;i<x.length;i++)
	{
		x[i].id = "div"+i;
		var y = document.getElementById("div"+i).getElementsByTagName("A");
		var z = document.getElementById("div"+i).getElementsByTagName("SPAN");
		y[0].id = "link"+i;
		y[0].onmouseover = function () {
			var p = x.length-this.id.substr(4)-1;
			var r = this.id.substr(4);
			document.getElementById("div"+r).style.zIndex = "10";
			for(var d=1;d<=p;d++)
			{
				if(d==3){break;}
				var c = 0;
				c += parseFloat(r)+d;
				var a = document.getElementById("div"+c).getElementsByTagName("SPAN");
				for(var b=0;b<a.length;b++)
				{
					a[b].style.zIndex = "0";
				}
			}
		}
		y[0].onmouseout = function () {
			for(var n=0;n<x.length;n++)
			{
				x[n].style.zIndex = "0";
				for(var e=0;e<z.length;e++)
				{
					z[e].style.zIndex = "0";
				}
			}
		}
	}
}
