function loadPopUp( filename ) {
 var sFeatures;
 sFeatures ="toolbar='no',status='no',menubar='no',scrollbars='yes',resizeable='yes',width=600,height=600,top=" + ( screen.height / 2 -250) + ",left=" + ( screen.width / 2 -257 );
 window.open( filename , "misc",sFeatures,true );
}

function GetCategory(psField){
	if (psField.options[psField.selectedIndex].value!="empty"){
		document.location="products.asp?cat=" + psField.options[psField.selectedIndex].value + "&hierarchy=0";
	}
}

function isFieldEmpty(field)
{
  var re;
//  re = /(\b*\w{1,}\b)+/;
  if (field.value.length == 0) // !re.test(field.value)
  {
    return true;
  } else
    return false;
}

function isFieldEmailAddress(field) 
{
    var re;
    
    re = /\'|\""|<\w+.*>|;|\(|\)|\&|\+|\-{2,}|\\|\/|<|>/;
    if (re.test(field.value)) 
    {
      return false;
    } else {
	    re = /\w[-\w]*@\w[-\w]{0,61}\w\.\w{2,}/;
	    if (!re.test(field.value)) 
        {
          return false;
        } else
          return true;
    }
}

function isOriginValid (field) 
{
  var re; 
  
  re = /\s*([A-Za-z]{2})(?:\W|$)+/;
  if (re.test(field.value))   return true;
  re= /([\d]{5})/;
  if (re.test(field.value)) return true;
  return false;
}

function adjust_length() {
    var d = document;
    var hl, hr;
    
    hl = d.getElementById("pcm_col").offsetHeight;
    hr = d.getElementById("body_txt").offsetHeight;
    if (hr < hl) d.getElementById("right_col").style.height = hl + "px" ;
    return;
}

function isZipEmpty(f) {
  re = /[0-9]{5}-?[0-9]{0,4}/;
		if (!re.test(f.value)) {
			return false;
		} else 
			return true;
	}
  
function isPhoneFieldEmpty(f) {
  re = /\(?[0-9]{3}\)?[\s. \-]*[0-9]{3}[\s. \-]*[0-9]{4}/;
		if (!re.test(f.value)) {
			return false;
		} else 
			return true;
	}

function isStateEmpty(f) {
  re = /[A-Za-z]{2}/;
		if (!re.test(f.value)) {
			return false;
		} else 
			return true;
	}
  
function validatecontactform(f) {
   b = true;
  b = b && isFieldEmailAddress(f.email, "Please enter a valid email id");
}

function clearMe(f) {
	f.value = "";
	f.style.color = "inherit";
	return(true);
}

function validateSearchForm(f)
{
	var b = true;
	var msg = "";

	if( isFieldEmpty(f.st)|| f.st.value == "Product, Service, or Business") {

		msg = "Pleaser enter a product or service in the box\n";
		f.st.focus();
		b = false;
	}
	if (!isOriginValid(f.ad) || f.ad.value =="City and State or ZIP") {
		msg  +=  "Please enter a City and State combination or a valid ZIP code\n";
		if (b) {
			b=false;
			f.ad.focus();
		}
	}
	if (msg != "") {
		alert(msg);
	}
	return b;
}
/* DIV Swap */
function HideDIV(d) { document.getElementById(d).style.display = "none"; }
function DisplayDIV(d) { document.getElementById(d).style.display = "block"; }
/* MATCHING COLUMNS
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com
How it works: just apply the CSS class of 'column' to your pages' main columns.
*/
matchColumns=function(){ 
     var divs,contDivs,maxHeight,divHeight,d; 
     // get all <div> elements in the document 
     divs=document.getElementsByTagName('div'); 
     contDivs=[]; 
     // initialize maximum height value 
     maxHeight=0; 
     // iterate over all <div> elements in the document 
     for(var i=0;i<divs.length;i++){ 
          // make collection with <div> elements with class attribute 'container' 
          if(/\bcolumn\b/.test(divs[i].className)){ 
                d=divs[i]; 
                contDivs[contDivs.length]=d; 
                // determine height for <div> element 
                if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 					
                } 
                else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight;					 
                } 
                // calculate maximum height 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 
     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i++){ 
          contDivs[i].style.height=maxHeight + "px"; 
     } 
} 
// Runs the script when page loads 
window.onload=function(){ 
     if(document.getElementsByTagName){ 
          matchColumns();			 
     } 
} 
