// JavaScript Document

//===================================================================================

//===================================================================================
//Common functions
//===================================================================================
/*************************************
Description:    
Author:            
Date:               
Parameters:         
return:             
*************************************/



function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=825,height=600,left = 176,top = 132');");
}

function popUpHow2(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=555,height=600,left = 176,top = 132');");
}

function pop360(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=400,height=400,left = 312,top = 184');");
}



function howManyChecked(whichForm,whichCheckBoxArray,myMax,myMin,whichQuestion)
{
        var _countChecked = 0;
        var err = 0;
        /* iterate through all the elements in the checkbox array */
        for(i=0;i<document[whichForm][whichCheckBoxArray].length;i++)
        {
                /* and check to see if each is checked */
                if(document[whichForm][whichCheckBoxArray][i].checked==true)
                        /* if it is, increment a counter */
                        { _countChecked++; }
        }
        /* is the count too high? */
        if(_countChecked > myMax)
                { alert('You may only select up to '+myMax+' '+whichQuestion+' for comparison.');
                        return false;}
        /* of is the count too low */
        else if(_countChecked < myMin)
                { alert('You must select at least '+myMin+' '+whichQuestion+' for comparison.');
                        return false;}
}

//form validate

function revValidateWash()
{
   
   if (document.review.revtext.value == "")
   { 
      alert('You must enter a review') 
      document.review.revtext.focus(); 
      return false; 
   }

var btn1 = valButton(document.review.rateoverall);
if (btn1 == null)
 {
 alert('You must give a overall rating');
 return false;
 }
var btn2 = valButton(document.review.ratefunction);
if (btn2 == null)
 {
 alert('You must give a flush rating');
 return false;
 }
var btn3 = valButton(document.review.rateinstall);
if (btn3 == null)
 {
 alert('You must give a installation rating');
 return false;
 }
}

function revValidate()
{

   if (document.review.revtext.value == "")
   { 
      alert('You must enter a review') 
      document.review.revtext.focus(); 
      return false; 
   }

var btn1 = valButton(document.review.rateoverall);
if (btn1 == null)
 {
 alert('You must give a overall rating');
 return false;
 }
var btn2 = valButton(document.review.rateflush);
if (btn2 == null)
 {
 alert('You must give a flush rating');
 return false;
 }
var btn3 = valButton(document.review.rateinstall);
if (btn3 == null)
 {
 alert('You must give a installation rating');
 return false;
 }
}

// Radio Button Validation
// copyright Stephen Chapman, 15th Nov 2004,14th Sep 2005
// you may copy this function but please keep the copyright notice with it
function valButton(btn) {
var cnt = -1;
for (var i=btn.length-1; i > -1; i--) {
   if (btn[i].checked) {cnt = i; i = -1;}
   }
if (cnt > -1) return btn[cnt].value;
else return null;

}

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}



function loadobjs()
	{
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++)
	{
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1)
	{ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1)
	{ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1)
	{ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!="")
	{
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}