// JavaScript Document
// Global scripts for the ProCote website - SPB 12/12/06

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function activeButton(a, b){
	a='but'+a; var buttonid = document.getElementById(a); 
	if(b=='over'){buttonid.className='buttonmenuover';}else{buttonid.className='buttonmenu';}
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function activeMenu(a, b){
	a='menu'+a; var buttonid = document.getElementById(a); 
	if(b=='over'){buttonid.className='mymenuover';}
	if(b=='out'){buttonid.className='mymenu';}
	if(b=='down'){buttonid.className='mymenudown';}
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function getPage(myurl){
	window.location='../pgs/'+myurl+'.htm';
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function productButton(a, b){
	var buttonid = document.getElementById(a); 
	if(b=='over'){buttonid.className='mybuttonover';}
	if(b=='out'){buttonid.className='mybutton';}
	if(b=='down'){buttonid.className='mybuttondown';}
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function jumpLink(myurl, loc){
	document.location='../pgs/'+myurl+'.htm?'+loc;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function writeQuery(){
	var query = location.search;
	document.write('<p>'+query+'</p>');
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function getMSDS(method, option){
	var bb2 = document.getElementById('bb2'); var pci_info = document.getElementById('pci_info');
	var ts2 = document.getElementById('ts2'); var pcii_info = document.getElementById('pcii_info');
	var bb2k = document.getElementById('bb2k'); var pc2k_info = document.getElementById('pc2k_info');
	var pcul = document.getElementById('pcul'); var pcif_info = document.getElementById('pcif_info');
												var pcul_info = document.getElementById('pcul_info');
										
	pci_info.style.display='none'; pcii_info.style.display='none'; pc2k_info.style.display='none';
	pcif_info.style.display='none'; pcul_info.style.display='none';
	
	if(method=='p'){
		if(option==0){
			alert('Please choose a product to view MSDS');
			bb2.style.display='none'; ts2.style.display='none'; bb2k.style.display='none'; pcul.style.display='none';}
		if(option==1){bb2.style.display=''; ts2.style.display='none'; bb2k.style.display='none'; pcul.style.display='none';}
		if(option==2){bb2.style.display='none'; ts2.style.display=''; bb2k.style.display='none'; pcul.style.display='none';}
		if(option==3){bb2.style.display='none'; ts2.style.display='none'; bb2k.style.display=''; pcul.style.display='none';}
		document.form1.systemsel.value=0;
	}
	
	
	if(method=='s'){
		if(option==0){
			alert('Please choose a product to view MSDS');
			bb2.style.display='none'; ts2.style.display='none'; bb2k.style.display='none'; pcul.style.display='none';
			pci_info.style.display='none'; pcii_info.style.display='none'; pc2k_info.style.display='none';
	pcif_info.style.display='none'; pcul_info.style.display='none';}
		if(option==1){
			bb2.style.display=''; ts2.style.display=''; bb2k.style.display='none'; pcul.style.display='none';
			pci_info.style.display='';}
		if(option==2){
			bb2.style.display=''; ts2.style.display=''; bb2k.style.display='none'; pcul.style.display='none';
			pcii_info.style.display='';}
		if(option==3){
			bb2.style.display=''; ts2.style.display=''; bb2k.style.display=''; pcul.style.display='none';
			pc2k_info.style.display='';}
		if(option==4){
			bb2.style.display=''; ts2.style.display=''; bb2k.style.display=''; pcul.style.display='';
			pcul_info.style.display='';}
		if(option==5){
			bb2.style.display=''; ts2.style.display=''; bb2k.style.display=''; pcul.style.display='';
			pcif_info.style.display='';}
		document.form1.productsel.value=0;
	}
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function getQuery(){
	var query = location.search; var pos = query.length; query=query.substring(1,pos);
	var option=0;
	if(query=='pci'){option=1;}
	if(query=='pcii'){option=2;}
	if(query=='pc2k'){option=3;}
	if(query=='pcul'){option=4;}
	if(query=='pcf'){option=5;}
	return option;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function revQuery(a){
	var qtext='';
	if(a==1){qtext='pci';}
	if(a==2){qtext='pcii';}
	if(a==3){qtext='pc2k';}
	if(a==4){qtext='pcul';}
	if(a==5){qtext='pcf';}
	return qtext;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function queryMSDS(){
	var selection='s'; var floortype=getQuery();
	if (floortype!=0){getMSDS(selection, floortype);}
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function printMSDS(product){
	product='msds_'+product+'.htm';
	newwin = window.open(product);
	if (!newwin.opener) newwin.opener = self;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function queryRecommend(){
	var ftype=getQuery();
	if (ftype!=0){focusRecommend(ftype);}
	/*else{
		var showpci = document.getElementById('tpci'); showpci.style.display='';
		var showpcii = document.getElementById('tpcii'); showpcii.style.display='';
		var showpc2k = document.getElementById('tpc2k'); showpc2k.style.display='';
		var showpcul = document.getElementById('tpcul'); showpcul.style.display='';
		var showpcf = document.getElementById('tpcf'); showpcf.style.display='';
		}*/
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function focusRecommend(a){
	var myid = revQuery(a);
	var hilite = document.getElementById(myid);
	var txthilite = document.getElementById('t'+myid);
	hilite.className='highlightrec';
	txthilite.style.display='';
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function showPic(picnum){
	alert(picnum);
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function liteGallery(a, b){
	a=a.toString(); var mypic = document.getElementById('gal'+a);
	if(b=='over'){mypic.className='galinsetover';}
	if(b=='out'){mypic.className='galinset';}
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function getReferralinfo(){
	var prevlocation = location.search;
	var mybanner=document.getElementById('choosebanner');
	if (prevlocation=='?contact'){
		mybanner.src='../imgs/banners/contact.jpg';
		document.write('<p class="rectitle">Thank you!</p><p class="maintext">Your information request has been received. A ProCote representative should be contacting you shortly.</p>');}
	if (prevlocation=='?estimate'){
		mybanner.src='../imgs/banners/estimate.jpg';
		document.write('<p class="rectitle">Thank you!</p><p class="maintext">Your estimate request has been received. A ProCote representative should be contacting you shortly.</p>');}
	
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function estimateArea(a){
	var mycheck = document.getElementById('area'+a+'chk'); var mytable = document.getElementById('area'+a+'sub');
	if(mycheck.checked){mytable.style.display='';}else{mytable.style.display='none';};
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function getAddress(){
	var addressstr='';
	addressstr=document.estimateform.street.value+' '+document.estimateform.city.value+', '+document.estimateform.state.value+' '+document.estimateform.zip.value;
	return addressstr;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function getPreferred(){
	var mymethod = ''; var methodselect=document.getElementById('prefercontact');
	if(methodselect.value=='1'){mymethod='Telephone';}
	if(methodselect.value=='2'){mymethod='eMail';}
	if(methodselect.value=='3'){mymethod='Regular Mail';}
	return mymethod;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function compileConditions(a){
	var conditions = '';
		var chip = document.getElementById('chipping'+a); if(chip.checked){conditions=conditions+'Chipping, '}
		var peel = document.getElementById('peeling'+a); if(peel.checked){conditions=conditions+'Peeling, '}
		var wear = document.getElementById('wearthrough'+a); if(wear.checked){conditions=conditions+'Wearthough, '}
		var stain = document.getElementById('oilsoaked'+a); if(stain.checked){conditions=conditions+'Oil soaked, '}
		var clean = document.getElementById('hardclean'+a); if(clean.checked){conditions=conditions+'Hard to clean, '}
		var crack = document.getElementById('cracked'+a); if(crack.checked){conditions=conditions+'Cracked, '}
		var rough = document.getElementById('rough'+a); if(rough.checked){conditions=conditions+'Rough'}
	return conditions;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function getAreainfo(a){
	var mydesc = '';
	var areadesc=document.getElementById('area'+a+'desc');
	var areasize=document.getElementById('area'+a+'sf');
	var areafloor=document.getElementById('area'+a+'floor'); var floorval='';
		if(areafloor.value=='Other'){
			var othertype = document.getElementById('otherfloor'+a); floorval=othertype.value;}
		else{floorval=areafloor.value;}
	var areacoat=document.getElementById('area'+a+'coat'); var coatval='';
		if(areacoat.value=='Other'){
			var othercoat = document.getElementById('othercoat'+a); coatval=othercoat.value;}
		else{coatval=areacoat.value;}
	
	
	mydesc = '<hr>Area '+a+':<br>Description/Use: '+areadesc.value+'<br>Size of area: '+areasize.value+'<br>Floor type: '+floorval+'<br>Current coating: '+coatval+'<br>Current floor/coating has following issues: '+compileConditions(a)+'<br><hr><br>';
	return mydesc;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function formatHours(a){
		var hour=0; var ampm='AM';
		a=parseFloat(a);
		if(a>=12){ampm='PM';}
		if(a>=13){hour=a-12;}else{hour=a;}
		if(a==0){hour=12;}
	return{hour:hour, ampm:ampm}
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function getDatetime(){
		var timestring='';
		var submitdate=new Date();
		var monthnames=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
		var mymonth = submitdate.getMonth(); mymonth=parseFloat(mymonth);
		var submitmonth=monthnames[mymonth]; var submitday = submitdate.getDate(); var submityear = submitdate.getYear();
		var submithours=submitdate.getHours(); var submitmins=submitdate.getMinutes();
		var timeformat=formatHours(submithours);
		
		timestring=submitmonth+' '+ submitday+', '+submityear+' '+timeformat.hour+':'+submitmins+' '+timeformat.ampm;
		return timestring;
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function verifyEstimate(){
	document.estimatereq.contactname.value=document.estimateform.realname.value;
	document.estimatereq.contacttitle.value=document.estimateform.contitle.value;
	document.estimatereq.businessname.value=document.estimateform.bname.value;
	document.estimatereq.contactaddress.value=getAddress();
	document.estimatereq.contactphone.value=document.estimateform.phone.value;
	document.estimatereq.contactemail.value=document.estimateform.email.value;
	document.estimatereq.prefermethod.value=getPreferred();
	document.estimatereq.cleancurrent.value=document.estimateform.cleanhowoften.value;
	document.estimatereq.cleancommit.value=document.estimateform.commit.value;
	document.estimatereq.howheard.value=document.estimateform.howheard.value;
	
	document.estimatereq.submittime.value=getDatetime();
	
	document.estimatereq.area1desc.value=getAreainfo(1);
	var check2 = document.getElementById('area2chk'); if(check2.checked){document.estimatereq.area2desc.value=getAreainfo(2);}
	var check3 = document.getElementById('area3chk'); if(check3.checked){document.estimatereq.area3desc.value=getAreainfo(3);}
	
	document.estimatereq.submit();
}//----------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------BEGIN FUNCTION
function rollMenu(a){
	var mybutton = document.getElementById('splash');
	mybutton.src='imgs/splash/button_'+a+'.gif';
}//----------------------------------------------------------------------------------------------END FUNCTION




