
//Javascript for all files to calculate the height of content and assigning the height+400px(to fit the footer) to the header
function calculateHeight()
{
	//document.getElementById("messagediv").style.display="none";
	var headerHeight;
var heightOfWindow=document.getElementById('content').offsetHeight;
//alert(heightOfWindow);

/*if(heightOfWindow < 500)
	{
		headerHeight=document.getElementById("headerFrame").style.height=heightOfWindow-100;
		
		 alert(headerHeight);
		document.getElementById("footer_div").style.marginTop= 782;

	}

if(heightOfWindow < 750)
	{
		headerHeight=document.getElementById("headerFrame").style.height=975;
		 //alert(headerHeight);
		document.getElementById("footer_div").style.marginTop= 782;

	}
if(heightOfWindow >6500)
	{
		headerHeight=document.getElementById("headerFrame").style.height=heightOfWindow+365;
		// alert(headerHeight);
		document.getElementById("footer_div").style.marginTop= heightOfWindow+130;
		document.getElementById("footer_div").style.height=175;

	}
*/
if(heightOfWindow < 200)
	{
		headerHeight=document.getElementById("headerFrame").style.height=995;
		
		// alert(headerHeight);
		document.getElementById("footer_div").style.marginTop=790;

	}
else if(heightOfWindow < 500)
	{
		headerHeight=document.getElementById("headerFrame").style.height=975;
		
		// alert(headerHeight);
		document.getElementById("footer_div").style.marginTop= 765;

	}

else	if(heightOfWindow >=500 && heightOfWindow < 535)
	{
		headerHeight=document.getElementById("headerFrame").style.height=1035;
		
		// alert(headerHeight);
		document.getElementById("footer_div").style.marginTop= 825;

	}

	
else	if(heightOfWindow >=535 && heightOfWindow < 557)
	{
		headerHeight=document.getElementById("headerFrame").style.height=1005;
		
		// alert(headerHeight);
		document.getElementById("footer_div").style.marginTop= 800;

	}

else	if(heightOfWindow >=557 && heightOfWindow < 600)
	{
		headerHeight=document.getElementById("headerFrame").style.height=975;
		
		// alert(headerHeight);
		document.getElementById("footer_div").style.marginTop= 765;

	}
else	if(heightOfWindow >=6000 && heightOfWindow < 7000)
	{
		headerHeight=document.getElementById("headerFrame").style.height=6975;
		
		// alert(headerHeight);
		document.getElementById("footer_div").style.marginTop= 6765;

	}


else {

 headerHeight=document.getElementById("headerFrame").style.height=heightOfWindow+330;
//alert(headerHeight);
 document.getElementById("footer_div").style.marginTop= heightOfWindow+127;

}
//alert(headerHeight);
//alert(document.body.clientHeight);



document.getElementById("headerFrame").style.display="block";
document.getElementById("content").style.visibility="visible";
document.getElementById("footerFrame").style.display="block";







//document.getElementById("footerFrame").style.display="block";


}



// javascript for freequote.htm file


function myselfSelect() {
document.getElementById("contractor").style.visibility="hidden";
document.getElementById("contractor").style.display="none";
if(document.getElementById("construction_method").value == 'have contractor')
   document.getElementById("contractor").style.visibility="visible";

}
function contractSelect() {

document.getElementById("contractor").style.visibility="visible";
document.getElementById("contractor").style.display="inline";
if(document.getElementById("construction_method").value == 'have contractor')
   document.getElementById("contractor").style.visibility="visible";


}
function validateForm() {

 if(document.form.building_type.value=="Gable")
 {
   strreg=document.form.reg_building_width.value;
   if(strreg=="") {
		alert('Please enter your building width');
		document.form.reg_building_width.focus();
		return false;
	}
   
   strlen=document.form.building_length.value;
   if(strlen=="") {
		alert('Please enter your building length');
		document.form.building_length.focus();
		return false;
	}
	
	streh=document.form.eave_height_reg.value;
   if(streh=="") {
		alert('Please enter your building Eave Height');
		document.form.eave_height_reg.focus();
		return false;
	}
}	

if(document.form.building_type.value=="Monitor")
{
   strlw=document.form.monitor_left_width.value;
   if(strlw=="") {
		alert('Please enter your building left width');
		document.form.monitor_left_width.focus();
		return false;
	}
    
   strmw=document.form.monitor_main_width.value;
   if(strmw=="") {
		alert('Please enter your building main width');
		document.form.monitor_main_width.focus();
		return false;
	}
    
	strrw=document.form.monitor_right_width.value;
    if(strrw=="") {
		alert('Please enter your building right width');
		document.form.monitor_right_width.focus();
		return false;
	}

   strlen=document.form.building_length.value;
   if(strlen=="") {
		alert('Please enter your building length');
		document.form.building_length.focus();
		return false;
	}
	
   strehl=document.form.monitor_eave_height_lower.value;
   if(strehl=="") {
		alert('Please enter your building lower eve height');
		document.form.monitor_eave_height_lower.focus();
		return false;
	}

   strehu=document.form.monitor_eave_height_upper.value;
   if(strehu=="") {
		alert('Please enter your building upper eve height');
		document.form.monitor_eave_height_upper.focus();
		return false;
	}

}	
	
if(document.form.building_type.value=="Gambrel")
{
   strgbw=document.form.gam_building_width.value;
   if(strgbw=="") {
		alert('Please enter your building width');
		document.form.gam_building_width.focus();
		return false;
	}
 
   
   strlen=document.form.building_length.value;
   if(strlen=="") {
		alert('Please enter your building length');
		document.form.building_length.focus();
		return false;
	}
   
   strgbw=document.form.eave_height_gam.value;
   if(strgbw=="") {
		alert('Please enter your building height');
		document.form.eave_height_gam.focus();
		return false;
	}
}

if(document.form.building_type.value=="Single Slope")
{
   strssbw=document.form.ss_building_width.value;
   if(strssbw=="") {
		alert('Please enter your building width');
		document.form.ss_building_width.focus();
		return false;
	}
 
   
   strlen=document.form.building_length.value;
   if(strlen=="") {
		alert('Please enter your building length');
		document.form.building_length.focus();
		return false;
	}
   
   strehss=document.form.eave_height_ss.value;
   if(strehss=="") {
		alert('Please enter your building height');
		document.form.eave_height_ss.focus();
		return false;
	}
}

if(document.form.building_type.value=="Hipped Roof")
{
   strhbw=document.form.hip_building_width.value;
   if(strhbw=="") {
		alert('Please enter your building width');
		document.form.hip_building_width.focus();
		return false;
	}
 
   
   strlen=document.form.building_length.value;
   if(strlen=="") {
		alert('Please enter your building length');
		document.form.building_length.focus();
		return false;
	}
   
   strehh=document.form.eave_height_hip.value;
   if(strehh=="") {
		alert('Please enter your building height');
		document.form.eave_height_hip.focus();
		return false;
	}
}

	 if ( (document.form.wind_exposure[0].checked == false)
    && (document.form.wind_exposure[1].checked == false)
    && (document.form.wind_exposure[2].checked == false) ){
       alert ("Please choose your Wind Exposure");
       document.form.wind_exposure[0].focus();
       return false;
    }
	 var strfnm = document.form.firstname.value;
	 if(strfnm=="") {
		alert('Please enter your First Name');
		document.form.firstname.focus();
		return false;
	}
	 var strlnm = document.form.lastname.value;
	 if(strlnm=="") {
		alert('Please enter your Last Name');
		document.form.lastname.focus();
		return false;
	}
	var stradd = document.form.address.value;
	if(stradd=="") {
		alert('Please enter your Address');
		document.form.address.focus();
		return false;
	}
	var strcit = document.form.city.value;
	if(strcit=="") {
		alert('Please enter your City');
		document.form.city.focus();
		return false;
	}
	var strcou = document.form.country.value;
	if(strcou=="") {
		alert('Please enter your Country');
		document.form.country.focus();
		return false;
	}
	var strsta = document.form.state1.value;
	if(strsta=="") {
		alert('Please enter your State');
		document.form.state1.focus();
		return false;
	}
	var strzip = document.form.zip.value;
	if(strzip=="") {
		alert('Please enter your Zip Code');
		document.form.zip.focus();
		return false;
	}
	var strcpb = document.form.county_parrish_borough.value;
	var strcpb2 = document.form.county.value;
	if(strcpb=="" && strcpb2=="") {
		alert('Please enter your County - Parrish - Borough');
		document.form.county_parrish_borough.focus();
		return false;
	}
	if(document.form.Site_Address_Same.checked == true)
	{
		var strsitecit = document.form.site_city.value;
		if(strsitecit=="") {
			alert('Please enter your City');
			document.form.site_city.focus();
			return false;
		}
		var strsitesta = document.form.site_state1.value;
		if(strsitesta=="") {
			alert('Please enter your State');
			document.form.site_state1.focus();
			return false;
		}
		var strsitecpb = document.form.site_county_parrish_borough.value;
		if(strsitecpb=="") {
			alert('Please enter your County - Parrish - Borough');
			document.form.site_county_parrish_borough.focus();
			return false;
		}
	}
	var strother = document.form.building_use_other.value;
	if ( (document.form.building_use[0].checked == false)
    && (document.form.building_use[1].checked == false)
    && (document.form.building_use[2].checked == false)
	&& (document.form.building_use[3].checked == false)
	&& (document.form.building_use[4].checked == false)
	&& (document.form.building_use[5].checked == false)
	&& (document.form.building_use[6].checked == false)
	&& (document.form.building_use[7].checked == false)
	&& (document.form.building_use[8].checked == false)
	&& (document.form.building_use[9].checked == false)
	&& (document.form.building_use[10].checked == false)
	&& (document.form.building_use[11].checked == false)
	&& (document.form.building_use[12].checked == false)
	&& (strother == "") ){
       alert ("Please choose the primary use for your building");
       document.form.building_use[0].focus();
       return false;
    }
	/*if(document.form.call_after_quote[0].checked == true && document.form.phone.value == "")
	{
		alert ("Please enter your phone number so we can call as you requested.");
		document.form.phone.focus();
		return false;
	}*/
	var str = document.form.customer_email.value;
	var str2 = document.form.customer_email_confirm.value;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(str=="") {
		alert('Please enter your email address');
		document.form.customer_email.focus();
		return false;
	} 
	
		
		if(reg.test(str) == false) {
		  alert('Invalid email address! Please re-enter your email address');
		  document.form.customer_email.focus();
		  return false;
	   }
	
		if(str2=="") {
		alert('Please  re enter your email address');
		document.form.customer_email_confirm.focus();
		return false;
	} 
	
	if(str!=str2) {
		alert('The email addresses you have given do not match.Please check both email address you typed and correct your email address.');
		document.form.customer_email_confirm.focus();
		return false;
	} 
	
	
		return true;
	
}

function toggleOptions(toggle) {
	if (toggle == 1) {
		document.getElementById('SaveProposalCheckbox').style.display = 'none';
		document.getElementById('SaveProposalOptions').style.display = '';
		document.form.day_to_call.checked = false;
	}
	else if (toggle == 0) {
		document.getElementById('SaveProposalCheckbox').style.display = '';
		document.getElementById('SaveProposalOptions').style.display = 'none';

		document.getElementById('SaveProposalCheckboxT').style.display = '';
		document.getElementById('SaveProposalOptionsT').style.display = 'none';

	}
}
function toggleOptionsT(toggle) {
	if (toggle == 1) {
        document.getElementById('SaveProposalCheckboxT1').style.display = '';
		document.getElementById('SaveProposalOptionsT1').style.display = 'none';
		document.getElementById('SaveProposalCheckboxT').style.display = 'none';
		document.getElementById('SaveProposalOptionsT').style.display = '';
	}
	else if (toggle == 0) {
		document.getElementById('SaveProposalCheckboxT').style.display = '';
		document.getElementById('SaveProposalOptionsT').style.display = 'none';
	}
}
function toggleOptionsT1(toggle) {
	if (toggle == 1) {
        document.getElementById('SaveProposalCheckboxT').style.display = '';
		document.getElementById('SaveProposalOptionsT').style.display = 'none';
		document.getElementById('SaveProposalCheckboxT1').style.display = 'none';
		document.getElementById('SaveProposalOptionsT1').style.display = '';
	}
	else if (toggle == 0) {
		document.getElementById('SaveProposalCheckboxT1').style.display = '';
		document.getElementById('SaveProposalOptionsT1').style.display = 'none';
	}
}


function toggleChangedFlag() {
	document.form.SavedProposalChanged.value = 1
}

function toggleSaveDropDown(toggle) {
	if (toggle == 'off') {
		document.form.OverwriteTemplateID.disabled = true;
		document.form.SaveTemplateName.disabled = false;
	}
	else if (toggle == 'on') {
		document.form.OverwriteTemplateID.disabled = false;
		document.form.SaveTemplateName.disabled = true;
	}
}



<!-- Begin Popup Scripts
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=1,width=600,height=500');");
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// End -->
//-->


function ValidateEmail()
{
	var str = document.form.customer_email.value;
	var str2 = document.form.customer_email_confirm.value;
	if(str=="")
		{
			alert('Please enter your email address');
			document.form.customer_email.focus();
			return false;
		}
		else
		{
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			if(str!='')
				{
					if(reg.test(str) == false)
					{
		  				alert('Invalid email address! Please re-enter your email address');
		  				document.form.customer_email.focus();
		  				return false;
	   				}
				}
		}
		if(str2=="")
			{
				alert('Please re-enter your email address');
				document.form.customer_email_confirm.focus();
				return false;
			}
		else
			{
				if(str2!='')
				{
					if(str!=str2)
						{
							alert('The email addresses you have given do not match.Please check both email address you typed and correct your email address.');
							document.form.customer_email_confirm.focus();
							return false;
						}
						else
						{
							return true;
						}
				}
			}
}

function check_form(obj)
{
	if(document.form.firstname.value=='')
	{
		alert("Please enter your first name.");
		document.form.firstname.focus();
		return false;
	}
	if(document.form.lastname.value=='')
	{
		alert("Please enter your last name.");
		document.form.lastname.focus();
		return false;
	}
	
	
	if(document.form.projectnum.value=='')
	{
		alert("Please enter the project number.");
		document.form.projectnum.focus();
		return false;
	}
	if(document.form.projectnum.value!='')
	{
	var pr_num=document.form.projectnum.value;
	var project_array=pr_num.split("-");
	//alert(project_array[0]);
	
	var d = new Date();
	var curr_year = d.getFullYear();
	//alert(curr_year);
	var two_digit_year=curr_year-2000;
	
	//alert(two_digit_year);

	/*if(project_array[0]!="03" || project_array[0]!="04" || project_array[0]!="05" || project_array[0]!="06" || project_array[0]!="07" || project_array[0]!="08" || project_array[0]!="09")
	{
	alert('The initial two digit of project number should be between 03 and current year');
			document.form.customer_email.focus();
			return false;
	}*/
	var reg=/^(0[3-two_digit_year])$/;
		if(reg.test(project_array[0])==false)
		{
			alert('This is not a valid project number');
			document.form.customer_email.focus();
			return false;

		}
		

	}
	
	var str = document.form.customer_email.value;
	var str2 = document.form.customer_email_confirm.value;
		if(str=='')
		{
			alert('Please enter your email address');
			document.form.customer_email.focus();
			return false;
		}
		else
		{
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			if(str!='')
				{
					if(reg.test(str) == false)
					{
			  			alert('Invalid email address! Please re-enter your email address');
			  			document.form.customer_email.focus();
			  			return false;
		   			}
				}
		}
		if(str2=='')
		{
			alert('Please re-enter your email address');
			document.form.customer_email_confirm.focus();
			return false;
		}
		else
		{
			if(str2!='')
			{
				if(str!=str2)
				{
					alert('The email addresses you have given do not match.Please check both email address you typed and correct your email address.');
					document.form.customer_email_confirm.focus();
					return false;
				}
			}
	}
	
	

}








function addFile(tableID)
{


var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);

var cell1 = row.insertCell(0);
var element1 = document.createElement("input");

element1.type = "file";

cell1.appendChild(element1);

 

}

function removeFile(tableID)
{
var table = document.getElementById(tableID);
var rowCount = table.rows.length;

table.deleteRow(rowCount-1);

}







function validate(form)
{
var flag1=true;
var flag2=true;
var flag3=true;
var flag4=true;
var flag5=true;
var flag6=true;
var flag7=true;
var flag8=true;
var flag9=true;
var flag10=true;

if(document.getElementById("fname").value=='')
	{
		document.getElementById("fnameerror").style.visibility="visible";
		flag1=false;
	

		
	}
else
	{
	document.getElementById("fnameerror").style.visibility="hidden";
	flag1=true;
	}





if(document.getElementById("lname").value=='')
	{
		document.getElementById("lnameerror").style.visibility="visible";
		flag2=false;


		
	}
else
{
	document.getElementById("lnameerror").style.visibility="hidden";
	flag2=true;
	}





if(document.getElementById("email").value=='')
	{
		document.getElementById("emailerror").style.visibility="visible";
		flag3=false;


		
	}
else
{
	document.getElementById("emailerror").style.visibility="hidden";
	flag3=true;
	}



if(document.getElementById("phone").value=='')
	{
		document.getElementById("phoneerror").style.visibility="visible";
		flag4=false;


		
	}
else
	{
	document.getElementById("phoneerror").style.visibility="hidden";
	flag4=true;
	}






if(document.getElementById("country").value=='' )
	{
		
		document.getElementById("countryerror").style.visibility="visible";
		flag5=false;
	

		
	}
else
	{
	document.getElementById("countryerror").style.visibility="hidden";
	flag5=true;
	}




if(document.getElementById("address").value=='')
	{
		document.getElementById("addresserror").style.visibility="visible";
		flag6=false;
		

		
	}
else
	{
	document.getElementById("addresserror").style.visibility="hidden";
	flag6=true;
	}




if(document.getElementById("city").value=='')
	{
	document.getElementById("cityerror").style.visibility="visible";
	flag7=false;
	

		
	}
else
	{
	document.getElementById("cityerror").style.visibility="hidden";
	flag7=true;
	}




if(document.getElementById("state1").value=='')
	{
		document.getElementById("state1error").style.visibility="visible";
		flag8=false;
		

	}
else
	{
	document.getElementById("state1error").style.visibility="hidden";
	flag8=true;
	}




if(document.getElementById("zip").value=='')
	{
		document.getElementById("ziperror").style.visibility="visible";
		flag9=false;
	

		
	}
else
	{
	document.getElementById("ziperror").style.visibility="hidden";
	flag9=true;
	}

if(document.getElementById("county_parrish_borough").value=='')
	{
		document.getElementById("countyerror").style.visibility="visible";
		flag10=false;
	

		
	}
else
	{
	document.getElementById("countyerror").style.visibility="hidden";
	flag10=true;
	}



if (flag1==true && flag2==true && flag3==true && flag4==true && flag5==true && flag6==true && flag7==true && flag8==true && flag9==true && flag10==true )
{
	return true;
}

else
	{
	return false;
	}
}


var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "custom", {pattern:"00-0000", useCharacterMasking:true, validateOn:["change"]});

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "phone_number", {isRequired:false, useCharacterMasking:true});










function check_form1(form)
{
	
	if(document.productguide.firstname.value=="")
	{
		alert("Please enter your first name.");
		document.productguide.firstname.focus();
		
		return false;
	}
	if(document.productguide.lastname.value=='')
	{
		alert("Please enter your last name.");
		document.productguide.lastname.focus();
		
		return false;
	}
	if(document.productguide.address.value=='')
	{
		alert("Please enter your address.");
		document.productguide.address.focus();
		
		return false;
	}

	if(document.productguide.city.value=='')
	{
		alert("Please enter your city.");
		document.productguide.city.focus();
		
		return false;
	}

	if(document.productguide.state1.value=='')
	{
		alert("Please enter your state.");
		document.productguide.state1.focus();
		
		return false;
	}

	if(document.productguide.zip.value=='')
	{
		alert("Please enter your zip.");
		document.productguide.zip.focus();
		
		return false;
	}

	if(document.productguide.phone.value=='')
	{
		alert("Please enter your phone.");
		document.productguide.phone.focus();
		
		return false;
	}


	
	
	var str = document.productguide.customer_email.value;
	var str2 = document.productguide.customer_email_confirm.value;
		if(str=='')
		{
			alert('Please enter your email address');
			document.productguide.customer_email.focus();
			
			return false;
		}
		
	
	var initialThree=str.substring(0,4);

	if(initialThree=='www.'){
		
		alert("Email address cannot start with www.");
		document.productguide.customer_email.focus();
		
		return false;
	}
	
		else
		{
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			if(str!='')
				{
					if(reg.test(str) == false)
					{
			  			alert('Invalid email address! Please re-enter your email address');
			  			document.productguide.customer_email.focus();
						
			  			return false;
		   			}
				}
		}
		if(str2=='')
		{
			alert('Please re-enter your email address');
			document.productguide.customer_email_confirm.focus();
			
			return false;
		}
		else
		{
			if(str2!='')
			{
				if(str!=str2)
				{
					alert('The email addresses you have given do not match.Please check both email address you typed and correct your email address.');
					document.productguide.customer_email_confirm.focus();
					
					return false;
				}
			}
	}
	
return true;

}

function generateWord()
{

var text_st = new Array("ax6tbh", "cvr4io", "zs9y1s", 
"5k0psd", "v2bpoiz", "xplbdy", "gn16sxa", "mf4gma", 
"vbztrs", "fi3bmq");

var l = text_st.length;

var rnd_no = Math.floor(l*Math.random());

//alert(text_st[rnd_no]);
document.getElementById("randomWordDiv").innerText=text_st[rnd_no];

}

