function checkContact(){

chkDetails = new Array();
chkDetails['num'] = 0;
chkDetails['mssg'] = 'Please fill in all required fields.<br /><br />';

TqdName = document.contactus.realname.value; qdName = TqdName.replace(/ /gi,"");
TqdEmail = document.contactus.email.value;
TqdPhone = document.contactus.phone.value; qdPhone = TqdPhone.replace(/ /gi,"");
TqdMessage = document.contactus.message.value; qdMessage = TqdMessage.replace(/ /gi,"");

var efilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	
	if(qdName != "")
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Full Name<br />";
	}
	
	if(efilter.test(TqdEmail))
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Please enter a valid Email Address\<br />";
	}
	
	if(isNaN(qdPhone) || qdPhone == "")
	{
		chkDetails['mssg'] += "- Please enter a valid Phone Number<br />";
	}
	else
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	
	if(qdMessage != "")
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Message<br />";
	}
	
	if(chkDetails['num'] != 4)
	{
		if(!document.getElementById("quoteerror"))
		{
			var errBody = document.getElementsByTagName("body")[0];
			var errDiv = document.createElement("div");
			errBody.appendChild(errDiv);
			errDiv.setAttribute("id", "quoteerror");
		}
	
		chkDetails['mssg'] += '<span id="errConf" onclick="hideErr()">OK</div>';
		
		document.getElementById("quoteerror").innerHTML = chkDetails['mssg'];
		document.getElementById("quoteerror").style.display = "block";
		return false;
	}
	else
	{
		if(document.getElementById("quoteerror"))
		{
			document.getElementById("quoteerror").innerHTML = '';
			document.getElementById("quoteerror").style.display = "none";
		}
		//document.quotedetails.submit();
		return true;
	}

}


function checkDetails(){

chkDetails = new Array();
chkDetails['num'] = 0;
chkDetails['mssg'] = 'Please fill in all required fields.<br /><br />';

TqdTitle = document.quotedetails.title.value; qdTitle = TqdTitle.replace(/ /gi,"");
TqdInitial = document.quotedetails.initial.value; qdInitial = TqdInitial.replace(/ /gi,"");
TqdSurname = document.quotedetails.surname.value; qdSurname = TqdSurname.replace(/ /gi,"");
TqdEmail = document.quotedetails.email.value;
TqdPhone = document.quotedetails.phone.value; qdPhone = TqdPhone.replace(/ /gi,"");
TqdAddress = document.quotedetails.address.value; qdAddress = TqdAddress.replace(/ /gi,"");
TqdPostCode = document.quotedetails.postcode.value; qdPostCode = TqdPostCode.replace(/ /gi,"");

var efilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if(qdTitle != "")
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Title<br />";
	}
	
	if(qdInitial != "")
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Initial<br />";
	}
	
	if(qdSurname != "")
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Surname<br />";
	}
	
	if(qdAddress != "")
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Address<br />";
	}
	
	if(qdPostCode != "")
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Post Code<br />";
	}
	
	if(isNaN(qdPhone) || qdPhone == "")
	{
		chkDetails['mssg'] += "- Please enter a valid Phone Number<br />";
	}
	else
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	
	if(efilter.test(TqdEmail))
	{
		chkDetails['num'] = chkDetails['num']+1;
	}
	else
	{
		chkDetails['mssg'] += "- Please enter a valid Email Address\<br />";
	}
	
	if(chkDetails['num'] != 7)
	{
		if(!document.getElementById("quoteerror"))
		{
			var errBody = document.getElementsByTagName("body")[0];
			var errDiv = document.createElement("div");
			errBody.appendChild(errDiv);
			errDiv.setAttribute("id", "quoteerror");
		}
	
		chkDetails['mssg'] += '<span id="errConf" onclick="hideErr()">OK</div>';
		
		document.getElementById("quoteerror").innerHTML = chkDetails['mssg'];
		document.getElementById("quoteerror").style.display = "block";
		return false;
	}
	else
	{
		if(document.getElementById("quoteerror"))
		{
			document.getElementById("quoteerror").innerHTML = '';
			document.getElementById("quoteerror").style.display = "none";
		}
		//document.quotedetails.submit();
		return true;
	}


}

function hideErr(){

		document.getElementById("quoteerror").innerHTML = '';
		document.getElementById("quoteerror").style.display = "none";
}


function checkQuote(){
	formErrors = new Array();
	formErrors['errnum']=0;
	formErrors['mF'] = 'Please fill in all the required fields.<br /><br />';
	
	var gSv;
	var gWv;
	var gRv;
	var gDv;

	for (var i=0; i < document.quotespecnme.garageSize.length; i++)
	{
		if (document.quotespecnme.garageSize[i].checked)
		{
			formErrors['errnum']=formErrors['errnum']+1;
			gSv = "1";
		}
	}
	
	if(gSv != "1")
	{
		formErrors['mF'] += '- Select a Garage Size<br />';
	}

	for (var i=0; i < document.quotespecnme.wallFinish.length; i++)
	{
		if (document.quotespecnme.wallFinish[i].checked)
		{
			formErrors['errnum']=formErrors['errnum']+1;
			gWv = "1";
		}
	}
	
	if(gWv != "1")
	{
		formErrors['mF'] += '- Select a Wall Finish<br />';
	}

	for (var i=0; i < document.quotespecnme.roofType.length; i++)
	{
		if (document.quotespecnme.roofType[i].checked)
		{
			formErrors['errnum']=formErrors['errnum']+1;
			gRv = "1";
		}
	}
	
	if(gRv != "1")
	{
		formErrors['mF'] += '- Select a Roof Type<br />';
	}

	for (var i=0; i < document.quotespecnme.doorType.length; i++)
	{
		if (document.quotespecnme.doorType[i].checked)
		{
			formErrors['errnum']=formErrors['errnum']+1;
			gDv = "1";
		}

	}
	
	if(gDv != "1")
	{
		formErrors['mF'] += '- Select a Door Type<br />';
	}

	return formErrors;
}


function changeOpt(wOpt){

	if(wOpt == 0)
	{
		document.quotespecnme.frontFascia.checked = "";
	}
	else if(wOpt == 1)
	{
		document.quotespecnme.frontFascia.checked = "checked";
	}

}


function calQuote(t){

formErrors = checkQuote();

if(formErrors['errnum'] != 4)
{
	if(!document.getElementById("quoteerror"))
	{
		var errBody = document.getElementsByTagName("body")[0];
		var errDiv = document.createElement("div");
		errBody.appendChild(errDiv);
		errDiv.setAttribute("id", "quoteerror");
	}
	
	if (self.pageYOffset) 
	{
		var scrolling = self.pageYOffset;
	} 
	else
	{
		var scrolling = document.documentElement.scrollTop;
	}
	
	var errPos = scrolling+330;

	formErrors['mF'] += '<span id="errConf" onclick="hideErr()">OK</div>';

	document.getElementById("quoteerror").style.top = errPos+"px";
	document.getElementById("quoteerror").innerHTML = formErrors['mF'];
	document.getElementById("quoteerror").style.display = "block";
	return false;
}
else
{

/*
document.quotespecnme.title.value = document.quotedetails.title.value;
document.quotespecnme.initial.value = document.quotedetails.initial.value;
document.quotespecnme.surname.value = document.quotedetails.surname.value;
document.quotespecnme.email.value = document.quotedetails.email.value;
document.quotespecnme.phone.value = document.quotedetails.phone.value;
if(document.quotedetails.optout.checked){document.quotespecnme.optout.value = document.quotedetails.optout.value;}
document.quotespecnme.address.value = document.quotedetails.address.value;
document.quotespecnme.postcode.value = document.quotedetails.postcode.value;
*/

baseoptions = new Array();
baseoptions['2-6x3-8'] = 5595;
baseoptions['2-6x4-4'] = 5995;
baseoptions['2-6x5-1'] = 6295;
baseoptions['2-6x5-7'] = 6895;
baseoptions['2-6x6-3'] = 7495;
baseoptions['2-6x6-9'] = 8195;
baseoptions['2-9x3-8'] = 5995;
baseoptions['2-9x4-4'] = 6295;
baseoptions['2-9x5-1'] = 6895;
baseoptions['2-9x5-7'] = 7495;
baseoptions['2-9x6-3'] = 8195;
baseoptions['2-9x6-9'] = 8795;
baseoptions['3-2x3-8'] = 6295;
baseoptions['3-2x4-4'] = 6895;
baseoptions['3-2x5-1'] = 7495;
baseoptions['3-2x5-7'] = 8195;
baseoptions['3-2x6-3'] = 8795;
baseoptions['3-2x6-9'] = 9395;

baseoptionsAg = new Array();
baseoptionsAg['2-6x3-8'] = 400;
baseoptionsAg['2-6x4-4'] = 300;
baseoptionsAg['2-6x5-1'] = 600;
baseoptionsAg['2-6x5-7'] = 600;
baseoptionsAg['2-6x6-3'] = 700;
baseoptionsAg['2-6x6-9'] = 600;
baseoptionsAg['2-9x3-8'] = 300;
baseoptionsAg['2-9x4-4'] = 600;
baseoptionsAg['2-9x5-1'] = 600;
baseoptionsAg['2-9x5-7'] = 700;
baseoptionsAg['2-9x6-3'] = 600;
baseoptionsAg['2-9x6-9'] = 600;
baseoptionsAg['3-2x3-8'] = 600;
baseoptionsAg['3-2x4-4'] = 600;
baseoptionsAg['3-2x5-1'] = 700;
baseoptionsAg['3-2x5-7'] = 600;
baseoptionsAg['3-2x6-3'] = 600;
baseoptionsAg['3-2x6-9'] = 600;


for (var i=0; i < document.quotespecnme.wallFinish.length; i++)
{
	if (document.quotespecnme.wallFinish[i].checked)
	{
		wallfinish = document.quotespecnme.wallFinish[i].value;
	}
}

if(wallfinish == "white" || wallfinish == "magnolia" || wallfinish == "french-stone" || wallfinish == "palace-grey")
{
	for (var i=0; i < document.quotespecnme.garageSize.length; i++)
	{
		if (document.quotespecnme.garageSize[i].checked)
		{
			baseprice = baseoptions[document.quotespecnme.garageSize[i].value];
			pdfbasetsize = document.quotespecnme.garageSize[i].value;
			pdfbasetype = "Textured";
			
			pricefordoort = document.quotespecnme.garageSize[i].value;
			pricefordoor = pricefordoort.substr(0,3);
		}
	}
	fasciaopt = 195;
}
else
{
	for (var i=0; i < document.quotespecnme.garageSize.length; i++)
	{
		if (document.quotespecnme.garageSize[i].checked)
		{
			baseprice = baseoptions[document.quotespecnme.garageSize[i].value]+baseoptionsAg[document.quotespecnme.garageSize[i].value];
			pdfbasetsize = document.quotespecnme.garageSize[i].value;
			pdfbasetype = "Aggregate";
			
			pricefordoort = document.quotespecnme.garageSize[i].value;
			pricefordoor = pricefordoort.substr(0,3);
		}
	}
	fasciaopt = 0;
}


dooroption = new Array();
dooroption['standard2-6'] = 0;
dooroption['standard2-9'] = 0;
dooroption['standard3-2'] = 0;
dooroption['plastisol2-6'] = 129;
dooroption['plastisol2-9'] = 149;
dooroption['plastisol3-2'] = 175;
dooroption['georgian2-6'] = 249;
dooroption['georgian2-9'] = 419;
dooroption['georgian3-2'] = 549;
dooroption['manualRoller2-6'] = 199;
dooroption['manualRoller2-9'] = 229;
dooroption['manualRoller3-2'] = 249;
dooroption['electricRoller2-6'] = 679;
dooroption['electricRoller2-9'] = 699;
dooroption['electricRoller3-2'] = 729;
dooroption['infillS2-6'] = 625;
dooroption['infillS2-9'] = 625;
dooroption['infillS3-2'] = 625;
dooroption['infillD2-6'] = 749;
dooroption['infillD2-9'] = 749;
dooroption['infillD3-2'] = 749;

for (var i=0; i < document.quotespecnme.doorType.length; i++)
{
	if (document.quotespecnme.doorType[i].checked)
	{
		doortype = dooroption[document.quotespecnme.doorType[i].value+pricefordoor];
	}
}

psDoorOption = new Array();
psDoorOption['singleGlazed'] = 625;
psDoorOption['doubleGlazed'] = 749;
personaldoor = 0;

for (var i=0; i < document.quotespecnme.personalDoorType.length; i++)
{
	if (document.quotespecnme.personalDoorType[i].checked)
	{
		personaldoor = psDoorOption[document.quotespecnme.personalDoorType[i].value];
	}
}

psWindowOption = new Array();
psWindowOption['singleGlazed'] = 299;
psWindowOption['doubleGlazed'] = 375;
personalwindow = 0;

for (var i=0; i < document.quotespecnme.personalWindowType.length; i++)
{
	if (document.quotespecnme.personalWindowType[i].checked)
	{
		personalwindow = psWindowOption[document.quotespecnme.personalWindowType[i].value];
	}
}

options=0;
if (document.quotespecnme.frontFascia.checked)
{
	options = options+fasciaopt;
}

if (document.quotespecnme.partitionWallSolid.checked)
{
	options = options+675;
}

if (document.quotespecnme.partitionWallDoor.checked)
{
	options = options+979;
}

if (document.quotespecnme.skirting.checked)
{
	options = options+125;
}

if (document.quotespecnme.electricalPack.checked)
{
	options = options+749;
}

if (document.quotespecnme.vaultedCeiling.checked)
{
	ceilingOpts = new Array();
	ceilingOpts['2-6x3-8'] = 585;
	ceilingOpts['2-6x4-4'] = 665;
	ceilingOpts['2-6x5-1'] = 740;
	ceilingOpts['2-6x5-7'] = 820;
	ceilingOpts['2-6x6-3'] = 899;
	ceilingOpts['2-6x6-9'] = 975;
	ceilingOpts['2-9x3-8'] = 645;
	ceilingOpts['2-9x4-4'] = 730;
	ceilingOpts['2-9x5-1'] = 815;
	ceilingOpts['2-9x5-7'] = 905;
	ceilingOpts['2-9x6-3'] = 999;
	ceilingOpts['2-9x6-9'] = 1075;
	ceilingOpts['3-2x3-8'] = 699;
	ceilingOpts['3-2x4-4'] = 799;
	ceilingOpts['3-2x5-1'] = 899;
	ceilingOpts['3-2x5-7'] = 990;
	ceilingOpts['3-2x6-3'] = 1085;
	ceilingOpts['3-2x6-9'] = 1185;


	for (var i=0; i < document.quotespecnme.garageSize.length; i++)
	{
		if (document.quotespecnme.garageSize[i].checked)
		{
			options = options+ceilingOpts[document.quotespecnme.garageSize[i].value];
		}
	}
	
}

	
totaltext = 'base: '+baseprice+'+ door: '+doortype+'+ personal door: '+personaldoor+'+ personal window: '+personalwindow+'+ other options: '+options+'\n';
total = baseprice+doortype+personaldoor+personalwindow+options;
disctotalt = Math.round(total/5);
disctotal = total-disctotalt;

document.quotespecnme.quoteprice.value = disctotal;

qtTotalDiv = document.getElementById("quotespecdetprice");
qtTotalDivou = document.getElementById("quotespecdet");
qtTotalDivemail = document.getElementById("prquoteemail");
qtLoaderDiv = document.getElementById("quoteload");

qtTotalDivouC = document.getElementById("quotespecdetc");
qtTotalDivouR = document.getElementById("quotespecdetr");

pdfbasesize = pdfbasetsize.substr(0,3);


qtTotalDiv.innerHTML = '<div id="nmprice">Normal Price: <span>&pound;'+total+'</span></div>';
qtTotalDiv.innerHTML += '<div id="dsprice">Discount price: <em>&pound;'+disctotal+'*</em></div>';
qtTotalDiv.innerHTML += '<br />Download your free plans:<br />';
qtTotalDiv.innerHTML += '<a href="/pdfs/'+pdfbasesize+'_wide_'+pdfbasetype+'_Coated_Standard_Plan.pdf" target="_blank" class="doclink"><span>Base Plan</span></a>';
qtTotalDiv.innerHTML += '<a href="/pdfs/'+pdfbasesize+'_wide_'+pdfbasetype+'_Coated_Elevation_Plan.pdf" target="_blank" class="doclink"><span>Building Plan</span></a>';
qtTotalDivemail.innerHTML = document.quotedetails.email.value;

qtTotalDivouC.style.display = "none";
qtTotalDivouR.style.display = "none";
qtTotalDivou.style.display = "block";


displayqComplete(2);

qtLoaderDiv.style.background = 'url(/gfx/loader.gif) no-repeat center center';
qtLoaderDiv.style.display = "block";

var qttimera = setTimeout("qtLoaderDiv.style.display = 'none'",2000);
var qttimerb = setTimeout("qtTotalDivou.style.backgroundColor = '#DDE1E2'",2000);

var qttimerc = setTimeout("qtTotalDivouC.style.display = 'block'",2000);
var qttimerd = setTimeout("qtTotalDivouR.style.display = 'block'",2000);
var qttimere = setTimeout("qtLoaderDiv.style.background=''",2000);
var qttimerf = setTimeout("document.getElementById('quotenote').style.display = 'block'",2000);


document.getElementById("quotedetGQ").style.display = "none";
document.getElementById("quotedetRS").style.display = "none";
document.getElementById("quotedetRSB").style.display = "block";

pageHeight();

window.open("/quote-sent.html", t, "width=100,height=100,top=0,left=0");

}
}

function resetQuote(){

	document.getElementById("quotespec").style.height = "";
	document.getElementById("quotespec").style.borderWidth = "1px";
	document.getElementById("quotespeccomp").style.display = "none";
	document.getElementById("quotespec").style.marginTop = "15px";
	document.getElementById("quotespec").style.marginBottom = "25px";
		
	document.getElementById("quotenote").style.display = "none";
	document.getElementById("quotespecdet").style.display = "none";
	document.getElementById("quotespecdetprice").innerHTML = '';
	document.getElementById("prquoteemail").innerHTML = '';
	document.getElementById("quotedetGQ").style.display = "";
	document.getElementById("quotedetRS").style.display = "";
	document.getElementById("quotedetRSB").style.display = "none";
	document.getElementById("quotespecdet").style.backgroundColor = "#ffffff"
	window.scrollTo(0,0);
}


function preload(wpage){


	if(wpage == "quote")
	{
		image0 = new Image(166,44);
		image0.src ="/gfx/continue-quoteHi.gif";
		image1 = new Image(174,44);
		image1.src ="/gfx/generate-quoteHi.gif";
		image2 = new Image(98,34);
		image2.src ="/gfx/loader.gif";
	}

}


function displayqComplete(qStage){

	if(qStage == 1)
	{
		document.getElementById("quotedets").style.height = "0px";
		document.getElementById("quotedets").style.overflow = "hidden";
		document.getElementById("quotedets").style.borderWidth = "0px";
		document.getElementById("quotedets").style.marginBottom = "0px";
		document.getElementById("quotedets").style.paddingBottom = "0px";
		document.getElementById("quotedetscomp").style.display = "block";
	}
	else if(qStage == 2)
	{
		document.getElementById("quotespec").style.height = "0px";
		document.getElementById("quotespec").style.borderWidth = "0px";
		document.getElementById("quotespec").style.marginBottom = "0px";
		document.getElementById("quotespec").style.marginTop = "0px";
		document.getElementById("quotespeccomp").style.display = "block";
	}

}


function pageHeight() {

//# This script is designed to alter your main content div min-height

var contentdiv = "maincontent"; //enter your content div ID here

//# The figure require to minus from the height of the window == the height of the 'Chrome' of a window 
//# plus any header/footer heights, and margin/paddings! In this case the header/footer total px height
//# is 338.

var headfoot = "338"; //enter your page header footer pixels total here (including padding and margin totals)


//# Each browser type has its own chrome height:
//# IE      = 176 (ish)
//# Firefox = 156 (ish)
//# Opera   = 127 (ish)
//# Safari  = 95  (ish)
//# Chrome  = 63  (ish)

	if (bName == "Explorer")
	{
		var brChrome = 140;
	}
	else if (bName == "Firefox")
	{
		var brChrome = 160;
	}
	else if (bName == "Opera")
	{
		var brChrome = 108;
	}
	else if (bName == "Safari")
	{
		var brChrome = 84;
	}
	else if (bName == "Chrome")
	{
		var brChrome = 63;
	}
	else
	{
		var brChrome = 140;
	}
	
	if (self.pageYOffset) 
	{
		var scrolling = self.pageYOffset;
	} 
	else
	{
		var scrolling = document.documentElement.scrollTop;
	}


	var wheight = screen.availHeight;
	var heighttemp = parseInt(brChrome)+parseInt(headfoot);
	var nheight = wheight-heighttemp;
	
	document.getElementById(contentdiv).style.minHeight=nheight+"px";
	
	var contentheight = document.getElementById(contentdiv).offsetHeight;
	
	var bdheight = parseInt(contentheight)+230;
	
	document.getElementById("mainbody").style.minHeight=bdheight+"px";
	
}

function ieqtCover(){

	if(bName == "Explorer" && bVer == "6")
	{
		if(document.getElementById("qtCover"))
		{
			document.getElementById("qtCover").style.height = document.getElementById("quotespec").offsetHeight;
		}
	}

}

function showSpec(){

	if(document.getElementById("quotespec"))
	{
		document.getElementById("quotespec").style.display = "block";
	}
}


 /* ====================================================
 Image Slide Show
==================================================== */

//*** Fader script ***
// http://brainerror.net/scripts/javascript/blendtrans/ for the fade transition

function opacityin(id, opacStart, opacEnd, millisec) { 
//speed for each frame 
var speed = Math.round(millisec / 100); 
var timer = 10; 

//determine the direction for the blending, if start and end are the same nothing happens 
if(opacStart > opacEnd) { 
 for(i = opacStart; i >= opacEnd; i--) { 
     setTimeout("changeOpacin(" + i + ",'" + id + "')",(timer * speed)); 
     timer++; 
 } 
} else if(opacStart < opacEnd) { 
 for(i = opacStart; i <= opacEnd; i++) 
 { 
     setTimeout("changeOpacin(" + i + ",'" + id + "')",(timer * speed)); 
     timer++; 
 } 
} 
} 

//change the opacity for different browsers 
function changeOpacin(opacity, id) { 
var object = document.getElementById(id).style; 
	object.filter = "alpha(opacity=" + opacity + ")"; 
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
}


function whyUltimate(){

mtimeouth = setTimeout("opacityin('whyulh', 0, 100, 500)",100);

mtimeout = new Array();
mtimeout['whyulh0'] = setTimeout("opacityin('whyulh0', 0, 100, 500)",1000);
mtimeout['whyulh1'] = setTimeout("opacityin('whyulh1', 0, 100, 500)",2000);
mtimeout['whyulh2'] = setTimeout("opacityin('whyulh2', 0, 100, 500)",3000);
mtimeout['whyulh3'] = setTimeout("opacityin('whyulh3', 0, 100, 500)",4000);
mtimeout['whyulh4'] = setTimeout("opacityin('whyulh4', 0, 100, 500)",5000);
mtimeout['whyulh5'] = setTimeout("opacityin('whyulh5', 0, 100, 500)",6000);
mtimeout['whyulh6'] = setTimeout("opacityin('whyulh6', 0, 100, 500)",7000);
mtimeout['whyulh7'] = setTimeout("opacityin('whyulh7', 0, 100, 500)",8000);
mtimeout['whyulh8'] = setTimeout("opacityin('whyulh8', 0, 100, 500)",9000);
mtimeout['whyulh9'] = setTimeout("opacityin('whyulh9', 0, 100, 500)",10000);
mtimeout['whyulh10'] = setTimeout("opacityin('whyulh10', 0, 100, 500)",11000);
mtimeout['whyulh11'] = setTimeout("opacityin('whyulh11', 0, 100, 500)",12000);

}


function strGallery(photoId){

	galDiv = document.getElementById("ugGallery");
	
	if(bName == "Explorer")
	{
		//galDiv.style.backgroundImage = "none";
		//galDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/gfx/gaBackground.png',sizingMethod='scale')";
	}
	
	
	var limg = document.createElement("img");
	galDiv.appendChild(limg);
	limg.setAttribute("src", "/gfx/gaLoader.gif");
	limg.setAttribute("alt", "Photo Loading");
	limg.setAttribute("id", "ugLoader");
	
	if (self.pageYOffset) 
	{
		var scrolling = self.pageYOffset;
	} 
	else
	{
		var scrolling = document.documentElement.scrollTop;
	}
	
	var loadPos = scrolling+300;
	
	document.getElementById("ugLoader").style.top = loadPos+"px";
	
	document.getElementById("photoContainer").style.border = "none";
	
	galDiv.style.opacity = "0";
	galDiv.style.filter = "alpha(opacity=0)";
	galDiv.style.display = "block";
	opacityin('ugGallery', 0, 100, 500);
	
	document.getElementById("ugLoader").style.display = "block";

	var galTimer = setTimeout("navGallery("+photoId+")",1000);
	
}

function navGallery(photoId){

galleryPhoto = new Array();
galleryPhoto[0] = "/images/stoneflex_homeoffice1.jpg";
galleryPhoto[1] = "/images/stoneflex4.jpg";
galleryPhoto[2] = "/images/painted_gym.jpg";
galleryPhoto[3] = "/images/painted_laundry.jpg";
galleryPhoto[4] = "/images/painted_main1.jpg";
galleryPhoto[5] = "/images/ultimate-building-office1.jpg";
galleryPhoto[6] = "/images/ultimate-building-office2.jpg";
galleryPhoto[7] = "/images/stoneflex5.jpg";
galleryPhoto[8] = "/images/stoneflex_gym.jpg";
galleryPhoto[9] = "/images/stoneflex_main4.jpg";
galleryPhoto[10] = "/images/stoneflex_interior1.jpg";
galleryPhoto[11] = "/images/stoneflex_interior2.jpg";
galleryPhoto[12] = "/images/stoneflex_window_door1.jpg";
galleryPhoto[13] = "/images/electricpack_consumer_unit.jpg";
galleryPhoto[14] = "/images/electricpack_light.jpg";
galleryPhoto[15] = "/images/electricpack_socket.jpg";
galleryPhoto[16] = "/images/internal_roof_cladding.jpg";
galleryPhoto[17] = "/images/painted_finish.jpg";
galleryPhoto[18] = "/images/skirting_finished.jpg";
galleryPhoto[19] = "/images/stoneflex_fascia.jpg";
galleryPhoto[20] = "/images/stoneflex_finish.jpg";
galleryPhoto[21] = "/images/outdoor-personal-door1.jpg";
galleryPhoto[22] = "/images/outdoor-personal-door2.jpg";

	document.getElementById("photoContainer").style.display = "none";
	document.getElementById("photoDetails").style.display = "none";
	
	if (self.pageYOffset) 
	{
		var scrolling = self.pageYOffset;
	} 
	else
	{
		var scrolling = document.documentElement.scrollTop;
	}
	
	//alert(scrolling);
	
	if(scrolling <= 164){var imgPos = scrolling;}else{var imgPos = scrolling-108;}
	var loadPos = scrolling+200;
	
	document.getElementById("ugLoader").style.top = loadPos+"px";
	
	document.getElementById("ugLoader").style.display = "block";
	
	if(photoId >= galleryPhoto.length-1)
	{
		nextPhoto = 0;
		prevPhoto = galleryPhoto.length-2;
	}
	else if(photoId <= 0)
	{
		nextPhoto = 1;
		prevPhoto = galleryPhoto.length-1;	
	}
	else
	{
		nextPhoto = photoId+1;
		prevPhoto = photoId-1;
	}
	
	imgNumber = (photoId+1)+"/"+galleryPhoto.length;
	
	var imgtoload = new Image();
	imgtoload.onload = function (){
	
	document.getElementById("ugLoader").style.display = "none";
	

	document.getElementById("photoContainer").style.marginTop = imgPos+"px";

	imgheight = imgtoload.height;
	imgwidth = imgtoload.width;
	document.getElementById("photoContainer").style.width = imgwidth+"px";
	document.getElementById("photoContainer").style.height = imgheight+"px";
	document.getElementById("photoContainer").style.backgroundImage = "url("+galleryPhoto[photoId]+")";
	document.getElementById("photoContainer").style.border = "1px solid #D7D7D7";
	
	navWidth = Math.round(imgwidth/2);
	
	document.getElementById("gLeftNav").style.width = (navWidth-2)+"px";
	document.getElementById("gLeftNav").style.height = (imgheight-2)+"px";
	document.getElementById("gRightNav").style.width = navWidth+"px";
	document.getElementById("gRightNav").style.height = imgheight+"px";
	
	document.getElementById("photoDetails").style.width = imgwidth+"px"; 
	document.getElementById("photoDetails").innerHTML = imgNumber+'<img id="closePhoto" src="/gfx/gaClose.png" alt="Close Photo" width="80" height="19" onclick="clsGallery()" />';
	
	document.getElementById("photoContainer").style.display = "";
	document.getElementById("photoDetails").style.display = "";
	
	document.getElementById("gLeftNav").setAttribute("onmouseover","this.style.backgroundImage = 'url(/gfx/gaPrev.png)'");
	document.getElementById("gRightNav").setAttribute("onmouseover","this.style.backgroundImage = 'url(/gfx/gaNext.png)'");
	document.getElementById("gLeftNav").setAttribute("onclick","navGallery("+prevPhoto+")");
	document.getElementById("gRightNav").setAttribute("onclick","navGallery("+nextPhoto+")");
	document.getElementById("gLeftNav").setAttribute("onmouseout","this.style.backgroundImage = 'none'");
	document.getElementById("gRightNav").setAttribute("onmouseout","this.style.backgroundImage = 'none'");
	
	return false;

	}
	imgtoload.src = galleryPhoto[photoId];
}


function soGallery(){

gDivs = document.getElementsByTagName("div");

	for(i=0;i<gDivs.length;i++)
	{
		gDiv = gDivs[i];
		
		if(bName == "Explorer" && (bVer == "7" || bVer == "6"))
		{
			thisClass = gDiv.getAttribute("className");
		}
		else
		{
			thisClass = gDiv.getAttribute("class");
		}
		
		
		if(thisClass == "gaphoto")
		{
			
			if(bName == "Explorer")
			{
				gaDivWidth = gDivs.item(i).childNodes[0].getAttribute("width");
				gaDivMargLeft = Math.round((255-parseInt(gaDivWidth))/2);

				gDivs.item(i).childNodes[2].style.width = gaDivWidth+"px";
				gDivs.item(i).childNodes[2].style.marginLeft = "1px";

				gDivs.item(i).style.width = (parseInt(gaDivWidth)+2)+"px";
				gDivs.item(i).style.marginLeft = gaDivMargLeft+"px";
			}
			else
			{
				gaDivWidth = gDivs.item(i).childNodes[1].getAttribute("width");
				gaDivMargLeft = Math.round((255-parseInt(gaDivWidth))/2);

				gDivs.item(i).childNodes[3].style.width = gaDivWidth+"px";
				gDivs.item(i).childNodes[3].style.marginLeft = "1px";

				gDivs.item(i).style.width = (parseInt(gaDivWidth)+2)+"px";
				gDivs.item(i).style.marginLeft = gaDivMargLeft+"px";
			}
		}

	}

}

function clsGallery(){

	opacityin('ugGallery', 100, 0, 500);
	guTimera = setTimeout("document.getElementById('photoContainer').style.backgroundImage = 'none'",600);
	guTimerb = setTimeout("document.getElementById('photoDetails').innerHTML = ''",600);
	guTimerc = setTimeout("document.getElementById('ugGallery').style.display = 'none'",600);

}



function addstyles(){

	//** Build js rendered stylesheet link that css validators fail on **
	var jstyle = document.getElementsByTagName("head")[0];
	var lk = document.createElement("link");
	jstyle.appendChild(lk);
	lk.setAttribute("rel", "stylesheet");
	lk.setAttribute("type", "text/css");
	lk.setAttribute("href", "/js-vl.css");
	
	showSpec();
}


function highlightGS(gSwitch,gRow,gCell){

htmlSize = new Array();
htmlSize['a'] = "2.65m<br />8'8&quot;";
htmlSize['b'] = "2.96m<br />9'8&quot;";
htmlSize['c'] = "3.26m<br />10'8&quot;";

elaA = "gs"+gRow+"a";
elaB = "gs"+gRow+"b";
elaC = "gs"+gRow+"c";
elaD = "gs"+gRow+gCell;

	if(gSwitch == 1)
	{
		document.getElementById(elaA).style.backgroundColor = "#FFFAE4";
		document.getElementById(elaB).style.backgroundColor = "#FFFAE4";
		document.getElementById(elaC).style.backgroundColor = "#FFFAE4";
		document.getElementById(elaD).style.backgroundImage = "none";
		document.getElementById(elaD).style.backgroundColor = "#FFFAE4";
		document.getElementById(elaD).innerHTML = htmlSize[gRow];
		document.getElementById(elaD).style.fontWeight = "bold";
	}
	else
	{
		document.getElementById(elaA).style.backgroundColor = "#ffffff";
		document.getElementById(elaB).style.backgroundColor = "#ffffff";
		document.getElementById(elaC).style.backgroundColor = "#ffffff";
		document.getElementById(elaD).style.backgroundImage = "url('/gfx/ex-width-bg.gif')";
		document.getElementById(elaD).style.backgroundColor = "#ffffff";
		document.getElementById(elaD).innerHTML = '';
	}

}


function showAgentResult(){

	if(document.getElementById("resultPagesGrid"))
	{
		Agents = document.getElementsByTagName("table");
		agentCount=0;
		for(i=0;i<Agents.length;i++)
		{
			Agent = Agents[i];
			thisREL = Agent.getAttribute("rel");
			if(thisREL == "agent")
			{
				agentCount = agentCount+1;	
			}
		}
		
		if(mAgent == '')
		{
			mAgent = 0;
		}
		
		if(agentCount < 6 && mAgent < 2)
		{
			document.getElementById("resultPagesGrid").style.display = "none";
		}
	}
}

function retailermap(mapLocation){

thismap = "/gfx/garage-retailer-"+mapLocation+".gif";

document.getElementById("retailermapi").src = thismap;

}


function startMap(){

var thisPage = location.href; 
mapLinks = document.getElementsByTagName("a");

	for(i=0;i<mapLinks.length;i++)
	{
		mapLink = mapLinks[i];

		mapRel = mapLink.getAttribute("rel");
		mapHref = mapLink.getAttribute("href");

		var location_page = location.protocol + "//" + location.hostname + mapHref;

		if((mapHref == thisPage && mapRel == "sitemap") || (location_page == thisPage && mapRel == "sitemap"))
		{ 
			mapLinks.item(i).className ="current";
			
			var mdiv = mapLinks.item(i).parentNode;
			var divadd = document.createElement("span");
			mdiv.appendChild(divadd);
			divadd.setAttribute("id", "youarehere");
			divadd.innerHTML = '&lt;&nbsp;&nbsp; You Are Here';
			goPos = mapLinks.item(i).offsetTop;
			document.getElementById("showSitemap").scrollTop = goPos;
			return;  
		} 
	}
}


function showSitemap(){

	if(!document.getElementById("showSitemap"))
	{
		var checksmap = document.getElementsByTagName("body")[0];
		var sndiv = document.createElement("div");
		checksmap.appendChild(sndiv);
		sndiv.setAttribute("id", "showSitemap");
	}
	
	
	sitemapPos = document.getElementById("page").offsetHeight-762;

	sitemapDiv = document.getElementById("showSitemap");
	sitemapDiv.style.top = sitemapPos+"px";
	sitemapDiv.innerHTML = '\n<div>\n<ul id="sitemap">\n<li><a href="/" rel="sitemap">Home</a></li>\n<li><a href="/about_ultimate_buildings.html" rel="sitemap">Learn More</a>\n<ul>\n<li><a href="/ultimate_garage_standard_features.html" rel="sitemap">Standard Features</a>\n<ul>\n<li><a href="/pdfs/ultimate_garage_spec_details.pdf" target="_blank">Garage Specification Sheet (PDF)</a></li>\n</ul>\n</li>\n<li><a href="/ultimate_garage_personalise.html" rel="sitemap">Personilise you Garage</a></li>\n<li><a href="/ultimate_building_construction_detail.html" rel="sitemap">Garage construction in detail</a>\n<ul>\n<li><a href="/pdfs/2-6_wide_Aggregate_Coated_Elevation_Plan.pdf" target="_blank">2.6m Wide Aggregate Coated Elevation Plan (PDF)</a></li>\n<li><a href="/pdfs/2-6_wide_Aggregate_Coated_Standard_Plan.pdf" target="_blank">2.6m Wide Aggregate Coated Standard Plan (PDF)</a></li>\n<li><a href="/pdfs/2-6_wide_Textured_Coated_Elevation_Plan.pdf" target="_blank">2.6m Wide Textured Coated Elevation Plan (PDF)</a></li>\n<li><a href="/pdfs/2-6_wide_Textured_Coated_Standard_Plan.pdf" target="_blank">2.6m Wide Textured Coated Standard Plan (PDF)</a></li>\n<li><a href="/pdfs/2-9_wide_Aggregate_Coated_Elevation_Plan.pdf" class="" target="_blank">2.9m Wide Aggregate Coated Elevation Plan (PDF)</a></li>\n<li><a href="/pdfs/2-9_wide_Aggregate_Coated_Standard_Plan.pdf" target="_blank">2.9m Wide Aggregate Coated Standard Plan (PDF)</a></li>\n<li><a href="/pdfs/2-9_wide_Textured_Coated_Elevation_Plan.pdf" target="_blank">2.9m Wide Textured Coated Elevation Plan (PDF)</a></li>\n<li><a href="/pdfs/2-9_wide_Textured_Coated_Standard_Plan.pdf" target="_blank">2.9m Wide Textured Coated Standard Plan (PDF)</a></li>\n<li><a href="/pdfs/3-2_wide_Aggregate_Coated_Elevation_Plan.pdf" target="_blank">3.2m Wide Aggregate Coated Elevation Plan (PDF)</a></li>\n<li><a href="/pdfs/3-2_wide_Aggregate_Coated_Standard_Plan.pdf" target="_blank">3.2m Wide Aggregate Coated Standard Plan (PDF)</a></li>\n<li><a href="/pdfs/3-2_wide_Textured_Coated_Elevation_Plan.pdf" target="_blank">3.2m Wide Textured Coated Elevation Plan (PDF)</a></li>\n<li><a href="/pdfs/3-2_wide_Textured_Coated_Standard_Plan.pdf" target="_blank">3.2m Wide Textured Coated Standard Plan (PDF)</a></li>\n</ul>\n</li>\n<li><a href="/ultimate_garage_gallery.html" rel="sitemap">Photo Gallery</a></li>\n</ul>\n</li>\n<li><a href="/design_your_own_ultimate_building.html" rel="sitemap">Online Quote</a>\n<ul>\n<li><a href="/pdfs/Compton_Ultimate_Collection_Price_List.pdf" target="_blank">Ultimate Garage Price List (PDF)</a></li>\n</ul>\n</li>\n<li><a href="/ultimate_garage_retailers.html" rel="sitemap">Local Retailer</a>\n<ul>\n<li><a href="/ultimate_garage_retailers.html?strRegion=East Anglia" rel="sitemap">Retailers in East Anglia</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=East Midlands" rel="sitemap">Retailers in the East Midlands</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=North East" rel="sitemap">Retailers in the North East</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=North West" rel="sitemap">Retailers in the North West</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=Scotland" rel="sitemap">Retailers in Scotland</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=South" rel="sitemap">Retailers in the South</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=South East" rel="sitemap">Retailers in the South East</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=South West" rel="sitemap">Retailers in the South West</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=Wales" rel="sitemap">Retailers in Wales</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=West Midlands" rel="sitemap">Retailers in the West Midlands</a></li>\n<li><a href="/ultimate_garage_retailers.html?strRegion=Yorkshire" rel="sitemap">Retailers in Yorkshire</a></li>\n</ul>\n</li>\n<li><a href="/contact_us.html" rel="sitemap">Contact</a></li>\n<li><a href="/sitemap.html" rel="sitemap">Sitemap</a></li>\n</ul>\n<span id="closeSitemapB" onclick="closeSitemap()">CLOSE</span>\n</div>\n<span id="closeSitemapA" onclick="closeSitemap()">CLOSE</span>\n';
	sitemapDiv.style.display = "block";
	startMap();
}

function closeSitemap(){

	document.getElementById("showSitemap").style.display = "none";
	document.getElementById("showSitemap").innerHTML = "";
}



/** Added from quirksmode to replace old detect method **/
/** http://www.quirksmode.org/js/detect.html           **/

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

var bName = BrowserDetect.browser;
var bVer = BrowserDetect.version;



window.onload = function (){pageHeight();ieqtCover();showSpec();}