// Custom scripts for GreatWay Roofing
// www.ebendesign.com
//

function fixChild(one,two)
{
	if (document.getElementById(one))
	{
		var lh = document.getElementById(one).offsetHeight;
		var rh = document.getElementById(two).offsetHeight;
		var nh = Math.max(lh, rh);
		var anh = nh - 181;
		document.getElementById(one).style.height = anh+"px";
		document.getElementById(two).style.height = nh+"px";
	}
}

function fixHome(one,two)
{
	if (document.getElementById(two))
	{
		var lh = document.getElementById(one).offsetHeight;
		var rh = (document.getElementById(two).offsetHeight + 60);
		var nh = Math.max(lh, rh);
		//var anh = nh + 60;
		document.getElementById(one).style.height = nh+"px";
		document.getElementById(two).style.height = nh+"px";
	}
}

var panels = new Array();
function hideThem()
{
	hideAll();
}

function showThem(selectage)
{
	if (panels.length > 0)
	{
		hideAll();	
	}
	panels[0] = selectage;
	showPanels();
}

function showPanels()
{
	document.getElementById(panels[0]).className = "selected";
	alert(panels[0]);
}

function hideAll()
{
	document.getElementById(panels[0]).className = "";	
}

function doMap(mapTab)
{
	document.getElementById("tab1").style.display = "none";
	document.getElementById("tab2").style.display = "none";
	document.getElementById(mapTab).style.display = "block";
}

function validateForm(gawEstimate) 
{
	var reason = "";
	reason += chkEmptyName(gawEstimate.name);
	reason += chkEmptyAddress(gawEstimate.address);
	reason += chkCity(gawEstimate.city);
	reason += chkZip1(gawEstimate.zip1);
	reason += chkPhone(gawEstimate.phone);
	reason += chkEmail(gawEstimate.email);
	if (reason != "") 
	{
		alert("There were errors submitting the form:\n\n" + reason);
		return false;
	}
	return true;
}
function chkEmptyName(fld) 
{
	var error = "";
	if (fld.value.length == 0) 
	{
		fld.style.background = '#ffffcc';
		error = "Your name is required!\n"
	} else 
	{
		fld.style.background = 'White';
	}
	return error;
}
function chkEmptyAddress(fld) 
{
	var error = "";
	if (fld.value.length == 0) 
	{
		fld.style.background = '#ffffcc';
		error = "Your address is required!\n"
	} else 
	{
		fld.style.background = 'White';
	}
	return error;
}
function chkCity(fld) 
{
	var error = "";
	if (fld.value == "") 
	{
		fld.style.background = '#ffffcc';
		error = "Your city is required\n"
	} else 
	{
		fld.style.background = 'White';
	}
	return error;
}
function chkZip1(fld) 
{
	var error = "";
	if (fld.value == "") 
	{
		fld.style.background = '#ffffcc';
		error = "Your postal code is required\n"
	} else 
	{
		fld.style.background = 'White';
	}
	return error;
}
function chkPhone(fld) 
{
	var error = "";
	if (fld.value == "") 
	{
		fld.style.background = '#ffffcc';
		error = "You must enter a valid phone number!\n";
	} else 
	{
		fld.style.background = 'White';
	}
	return error;
}
function chkEmail(fld) 
{
	var error = "";
	if (fld.value == "") 
	{
		fld.style.background = '#ffffcc';
		error = "Your email address is required!\n";
	} else 
	{
		fld.style.background = 'White';
	}
	return error;
}