
var VPartA = "@", VPartB = "sepro.com", VPondPakPart = "pondpak";
var VPondPak = VPondPakPart + VPartA + VPartB;
var crip = null;

function NewPopupWindow(url)
{
	if((crip == null) || (crip.closed)) 
	{
		crip = window.open(url, 'popupwindow', 'toolbar=yes,directories=no,status=no,location=no,menubar=yes,scrollbars=yes,width=798,height=550,left=20,top=20,resizable=yes');
		crip.focus();
	}
	else
	{
		crip.location = url;
		crip.focus();
	}
}
var crip2 = null;
function NewPopupWindow_All(url)
{
	if((crip2 == null) || (crip2.closed)) 
	{
		crip2 = window.open(url, 'popupwindow2', 'toolbar=yes,directories=yes,status=yes,location=yes,menubar=yes,scrollbars=yes,width=798,height=550,left=20,top=20,resizable=yes');
		crip2.focus();
	}
	else
	{
		crip2.location = url;
		crip2.focus();
	}
}
var crip3 = null;
function CustomPopupWindow(url, width, height)
{
	if((crip3 == null) || (crip3.closed)) 
	{
		crip3 = window.open(url, 'popupwindow3', 'toolbar=no,directories=no,status=no,location=no,menubar=yes,scrollbars=yes,width='+width+',height='+height+',left=20,top=20,resizable=no');
		crip3.focus();
	}
	else
	{
		crip3.location = url;
		crip3.focus();
	}
}

function showTime()
{
	var now = new Date();
	var show = "no";
	var theMonthName = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	var theDate = now.getDate();
	var theMonth = now.getMonth();
	var theYear = now.getFullYear();
	var theHour = now.getHours();
	var theMinute = now.getMinutes();
	var theSecond = now.getSeconds();
	var theTime = ((theHour > 12) ? theHour - 12 : theHour);
	theTime+= ((theMinute < 10) ? ":0" : ":") + theMinute;
	theTime +=((theSecond < 10) ? ":0" : ":") + theSecond;
	theTime += (theHour >= 12) ? " pm" : " am";
	clockFace = theMonthName[theMonth] + ", " + theDate + " " + theYear + " " + theTime;
	if (document.layers)
	{
		document.layers.clockBox.document.write(clockFace);
		document.layers.clockBox.document.close();
		show = "yes";
	}
	if (document.all)
	{
		clockBox.innerHTML = clockFace;
		show = "yes";
	}
	if (document.getElementById)
	{
		document.getElementById("clockBox").innerText=clockFace;
		show = "yes";
	}
	if (show == "no")
	{
		clockBox.innerHTML = clockFace;
	}
	timerID = setTimeout("showTime()", 1000);
}

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) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("^/default.htm.htm"))>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); return x;
}

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_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 isDate(dateStr) {

    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?

    if (matchArray == null) {
        alert("Please enter date as mm/dd/yyyy.");
        return false;
    }

    month = matchArray[1]; // parse date into variables
    day = matchArray[3];
    year = matchArray[5];

    if (month < 1 || month > 12) { // check month range
        alert("Month must be between 1 and 12.");
        return false;
    }

    if (day < 1 || day > 31) {
        alert("Day must be between 1 and 31.");
        return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Month "+month+" doesn't have 31 days!")
        return false;
    }

    if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
            alert("February " + year + " doesn't have " + day + " days!");
            return false;
        }
    }
    return true; // date is valid
}

function echeck(str){
	var aResult = true;
	var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (str != "") {
		if (filter.test(str))
			aResult=true;
		else{
			alert("Please enter a valid E-mail Address");
			aResult=false;
		}
	}
	return (aResult)
}	

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
function isFloat (s)
{   var i;
	var decimalPointDelimiter = ".";
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return true;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;


    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }
    return true;
}
function toNumberFormat(X) {
	var T, S=new String(Math.round(X*100))
    while (S.length<3) S='0'+S
    return S.substr(0, T=(S.length-2)) + '.' + S.substr(T, 2)
}

function CheckContactUsForm()
{
	if (document.AContactUs.AFirstName.value == "")
	{
		alert("Please enter your First Name");
		return false;
	}
	else if (document.AContactUs.ALastName.value == "")
	{
		alert("Please enter your Last Name");
		return false;
	}
	else if (document.AContactUs.ACompanyName.value == "")
	{
		alert("Please enter your Company Name");
		return false;
	}
	else if (document.AContactUs.AStreetAddress.value == "")
	{
		alert("Please enter your Street Address");
		return false;
	}
	else if (document.AContactUs.ACity.value == "")
	{
		alert("Please enter your City");
		return false;
	}
	else if (document.AContactUs.AState.value == "")
	{
		alert("Please enter your State/Province");
		return false;
	}
	else if (document.AContactUs.APostalCode.value == "")
	{
		alert("Please enter your Postal Code");
		return false;
	}
	else if (document.AContactUs.ACountry.value == "")
	{
		alert("Please enter your Country");
		return false;
	}
	else if (document.AContactUs.APhone.value == "")
	{
		alert("Please enter your Phone");
		return false;
	}
	else if (!echeck(document.AContactUs.AEmailAddress.value))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function CheckPondPakCatalogForm()
{
	if (document.AContactUs.AName.value == "")
	{
		alert("Please enter your Name");
		return false;
	}
	else if (document.AContactUs.ACompanyName.value == "")
	{
		alert("Please enter your Company Name");
		return false;
	}
	else if (document.AContactUs.AStreetAddress.value == "")
	{
		alert("Please enter your Street Address");
		return false;
	}
	else if (document.AContactUs.ACity.value == "")
	{
		alert("Please enter your City");
		return false;
	}
	else if (document.AContactUs.AState.value == "")
	{
		alert("Please enter your State");
		return false;
	}
	else if (document.AContactUs.APostalCode.value == "")
	{
		alert("Please enter your Zip Code");
		return false;
	}
	else if (document.AContactUs.APhone.value == "")
	{
		alert("Please enter your Phone");
		return false;
	}
	else if (document.AContactUs.AEmailAddress.value == "")
	{
		alert("Please enter your E-mail Address");
		return false;
	}
	else if (!echeck(document.AContactUs.AEmailAddress.value))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function CheckPondPakMailingListForm() {
	if (document.icpsignup.fields_email.value == "")
	{
		alert("Please enter your E-mail Address");
		return false;
	}
	else if (!echeck(document.icpsignup.fields_email.value))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function CheckQuizForm()
{
	if (document.AQuizForm.AFullName.value == "")
	{
		alert("Please enter your Name");
		return false;
	}
	else if (document.AQuizForm.ACompany.value == "")
	{
		alert("Please enter your Company");
		return false;
	}
	else if (document.AQuizForm.AAddress.value == "")
	{
		alert("Please enter your Street Address");
		return false;
	}
	else if (document.AQuizForm.ACity.value == "")
	{
		alert("Please enter your City");
		return false;
	}
	else if (document.AQuizForm.AState.value == "")
	{
		alert("Please enter your State/Province");
		return false;
	}
	else if (document.AQuizForm.AZip.value == "")
	{
		alert("Please enter your Zipcode");
		return false;
	}
	else if (document.AQuizForm.APhone.value == "")
	{
		alert("Please enter your Phone");
		return false;
	}
	else if (!echeck(document.AQuizForm.AEmail.value))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function CheckChallengeForm()
{
	if (document.AChallengeForm.AFullName.value == "")
	{
		alert("Please enter your Name");
		return false;
	}
	else if (document.AChallengeForm.ACompany.value == "")
	{
		alert("Please enter your Company");
		return false;
	}
	else if (document.AChallengeForm.AAddress.value == "")
	{
		alert("Please enter your Street Address");
		return false;
	}
	else if (document.AChallengeForm.ACity.value == "")
	{
		alert("Please enter your City");
		return false;
	}
	else if (document.AChallengeForm.AState.value == "")
	{
		alert("Please enter your State/Province");
		return false;
	}
	else if (document.AChallengeForm.AZip.value == "")
	{
		alert("Please enter your Zipcode");
		return false;
	}
	else if (document.AChallengeForm.APhone.value == "")
	{
		alert("Please enter your Phone");
		return false;
	}
	else if (!echeck(document.AChallengeForm.AEmail.value))
	{
		return false;
	}
	else if (document.AChallengeForm.ARenovateAgent.value == "")
	{
		alert("Please enter your Renovate Agent");
		return false;
	}
	else if (document.AChallengeForm.ARenovateAgentCityState.value == "")
	{
		alert("Please enter your Renovate Agent's City and State");
		return false;
	}
	else if (document.AChallengeForm.ARenovateGallons.value == "")
	{
		alert("Please enter the number of gallons purchased");
		return false;
	}
	else if (document.AChallengeForm.ARenovateDate.value == "")
	{
		alert("Please enter the date of purchase");
		return false;
	}
	else
	{
		return true;
	}
}

function CheckDemoForm()
{
	if (document.ADemoForm.AFullName.value == "")
	{
		alert("Please enter your Name");
		return false;
	}
	else if (document.ADemoForm.ACompany.value == "")
	{
		alert("Please enter your Company");
		return false;
	}
	else if (document.ADemoForm.AAddress.value == "")
	{
		alert("Please enter your Street Address");
		return false;
	}
	else if (document.ADemoForm.ACity.value == "")
	{
		alert("Please enter your City");
		return false;
	}
	else if (document.ADemoForm.AState.value == "")
	{
		alert("Please enter your State/Province");
		return false;
	}
	else if (document.ADemoForm.AZip.value == "")
	{
		alert("Please enter your Zipcode");
		return false;
	}
	else
	{
		return true;
	}
}

function CalculateSize()
{
	var PLength = document.ACalculator.APoolLength.value;
	var PWidth = document.ACalculator.APoolWidth.value;
	if (PLength == "") {
		PLength = 0;	
		document.ACalculator.APoolLength.value = 0;
	}
	if (PWidth == "") {
		PWidth = 0;	
		document.ACalculator.APoolWidth.value = 0;
	}
	if (!isFloat(PLength)) {
		alert("Please enter a valid Pool Length");
	}
	else if (!isFloat(PWidth)) {
		alert("Please enter a valid Pool Width");
	}
	else {		
		var PArea = PLength * PWidth;
		var PAreaAcres = PArea/43560;
		document.ACalculator.APoolSize.value = toNumberFormat(PAreaAcres);
	}
}