<!-- common.js -->

function toggleButton(button, state) {
 button.className =  state ? "buttonOn" : "button";
}

function popShipping() {
 window.open("estimate_shipping.asp","SRFHawaii","height=200,width=500,status=no,toolbar=no,menubar=no,location=no")
}

function submitForm(page) {
 document.forms[0].action = page;
 document.forms[0].submit();
}

function trim(sString)  {
 while (sString.substring(0,1) == ' ') {
  sString = sString.substring(1, sString.length);
 }
 while (sString.substring(sString.length-1, sString.length) == ' ') {
  sString = sString.substring(0,sString.length-1);
 }
 return sString;
}

function isEmail(str) {
 // are regular expressions supported?
 var supported = 0;
 if (window.RegExp) {
  var tempStr = "a";
  var tempReg = new RegExp(tempStr);
   if (tempReg.test(tempStr)) supported = 1;
 }
 if (!supported) 
  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
 var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
 return (!r1.test(str) && r2.test(str));
}

function search(form) {
 location.href = "search_results.asp?keyword=" + form.Keyword.value
}

function matchComboBox(element_id, search_string) {
 element = document.getElementById(element_id);
 for (i=0;i<element.length;i++) {
  if (search_string==element.options[i].value || search_string==element.options[i].text) {
   element.selectedIndex = i;
  }
 }
}

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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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_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 getWindowWidth() {
 var myWidth = 0;
 if( typeof( window.innerWidth ) == 'number' ) {
  //Non-IE
  myWidth = window.innerWidth;
 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  //IE 6+ in 'standards compliant mode'
  myWidth = document.documentElement.clientWidth;
 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  //IE 4 compatible
  myWidth = document.body.clientWidth;
 }
 return myWidth;
}

function getWindowHeight() {
 var myHeight = 0;
 if( typeof( window.innerWidth ) == 'number' ) {
  //Non-IE
  myHeight = window.innerHeight;
 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  //IE 6+ in 'standards compliant mode'
  myHeight = document.documentElement.clientHeight;
 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  //IE 4 compatible
  myHeight = document.body.clientHeight;
 }
 return myHeight;
}

function toggleDropDownBoxes(iState) { // 1 hidden, 0 visible
 var selects = document.getElementsByTagName("select");
 for(var xx = 0; xx < selects.length; xx++) {
  selects[xx].style.visibility = iState ? "hidden" : "visible";
 }
}

var zip_codes = new Array(32)
zip_codes[0] = "96701"
zip_codes[1] = "96706"
zip_codes[2] = "96707"
zip_codes[3] = "96712"
zip_codes[4] = "96713"
zip_codes[5] = "96717"
zip_codes[6] = "96731"
zip_codes[7] = "96759"
zip_codes[8] = "96762"
zip_codes[9] = "96782"
zip_codes[10] = "96786"
zip_codes[11] = "96789"
zip_codes[12] = "96791"
zip_codes[13] = "96792"
zip_codes[14] = "96797"
zip_codes[15] = "96813"
zip_codes[16] = "96818"
zip_codes[17] = "96730"
zip_codes[18] = "96734"
zip_codes[19] = "96744"
zip_codes[20] = "96795"
zip_codes[21] = "96813"
zip_codes[22] = "96814"
zip_codes[23] = "96815"
zip_codes[24] = "96816"
zip_codes[25] = "96817"
zip_codes[26] = "96816"
zip_codes[27] = "96819"
zip_codes[28] = "96821"
zip_codes[29] = "96822"
zip_codes[30] = "96825"
zip_codes[31] = "96826"