var browserName = new String(navigator.appName);
var isOp=window.opera?1:0;
function show_div(i) {
        // alert(i);
    var d =  document.getElementById(i);

    if (d) {
        d.style.display = 'block';
    }
    d.onMouseOut = function() {
       d.style.display = 'none';
    }

}

function hide_div(i) {
       //  alert(i);
         var d =  document.getElementById(i);
         if (d) {
                 d.style.display = 'none';
         }
}
function fix_divs() {
        if (browserName != "Microsoft Internet Explorer") {
           var i;
           for (i=1; i<8; i++) {
                var d =  document.getElementById(i);
                if (d) {
                    d.style.left = (parseInt(d.style.left) - 1)+'px';
                }
           }
        }
}

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_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 preload_imgs() {
      MM_preloadImages('images/menu1.gif','images/menu1_over.gif','images/menu2.gif','images/menu2_over.gif','images/menu3.gif','images/menu3_over.gif','images/menu4.gif','images/menu4_over.gif','images/menu5.gif','images/menu5_over.gif','images/menu6.gif','images/menu6_over.gif','images/menu7.gif','images/menu7_over.gif');
}

function check_form() {
      var d = document.getElementById('error');
      var err = 0;
      var msg = "";
      if (document.cu.name.value == '') {
              err++;
              msg += '<li>Name field is required</li>';
              document.cu.name.focus();
      }
      if (document.cu.address.value == '') {
              err++;
              msg += '<li>Address field is required</li>';
      }
      if (document.cu.phone.value == '') {
              err++;
              msg += '<li>Phone field is required</li>';
              document.cu.phone.focus();
      } /*else {
              var re3 = /^\s*(\(?[0-9]{3}\)?)?\s*([0-9]{3})\s*-\s*([0-9]{4})\s*$/gi;
              val = document.cu.phone.value;
              if (val.length > 0 && !val.match(re3)) {
                  err++;
                  msg += "<li>Phone is invalid</li>";
                  document.cu.phone.focus();
              }
      } */
     /* if (document.cu.fax.value == '') {
              err++;
              msg += '<li>Fax field is required</li>';
              document.cu.fax.focus();
      } else {
              var re3 = /^\s*(\(?[0-9]{3}\)?)?\s*([0-9]{3})\s*-\s*([0-9]{4})\s*$/gi;
              val = document.cu.fax.value;
              if (val.length > 0 && !val.match(re3)) {
                  err++;
                  msg += "<li>Fax is invalid</li>";
                  document.cu.fax.focus();
              }
      } */
      if (document.cu.email.value == '') {
              err++;
              msg += '<li>Email field is required</li>';
              document.cu.email.focus();
      } else {
              var re3 = /^\s*([a-zA-Z0-9\._\-]{1,100})@([a-zA-Z0-9\.\-_]){1,100}\.([a-zA-Z]{2,4})\s*$/gi;
              val = document.cu.email.value;
              if (val.length > 0 && !val.match(re3)) {
                  err++;
                  msg += "<li>Email Address is invalid</li>";
                  document.cu.email.focus();
              }
      }
       if (document.cu.service.options[document.cu.service.selectedIndex].value == '') {
              err++;
              msg += '<li>Type of service requested field is required</li>';
              document.cu.service.focus();
      }
       if (document.cu.equipment.options[document.cu.equipment.selectedIndex].value == '') {
              err++;
              msg += '<li>Type of equipment field is required</li>';
              document.cu.equipment.focus();
      }
       if (document.cu.problem.value == '') {
              err++;
              msg += '<li>Brief description of problem field is required</li>';
              document.cu.problem.focus();
      }
      if (document.cu.billing_phone.value == '') {
            //  err++;
           //  msg += '<li>Billing Phone field is required</li>';
            //  document.cu.billing_phone.focus();
      }  /*else {
             var re3 = /^\s*(\(?[0-9]{3}\)?)?\s*([0-9]{3})\s*-\s*([0-9]{4})\s*$/gi;
              val = document.cu.billing_phone.value;
              if (val.length > 0 && !val.match(re3)) {
                  err++;
                  msg += "<li>Billing Phone is invalid</li>";
                  document.cu.phone.focus();
              }
      }  */



     if (err != 0) {
            if (browserName == "Microsoft Internet Explorer") {
                d.style.height = (19*err)+'px';
            } else {
                 d.style.height = (22*err)+'px';
            }
            //alert('err height = '+d.style.height);
            d.innerHTML = "<b>The following fields have not be correctly entered</b>:<ul compact style=\"margin: 0px; margin-left: 20px\">"+msg+"</ul>";
            d.style.display = 'block';
            if (browserName == "Microsoft Internet Explorer") {d.focus();}
            //else {d.ec.name.focus();}
           // var d2 = document.getElementById('under_menu');
           // d2.style.height = (427+parseInt(d.style.height)+18)+'px';
            //alert('under_menu height = '+d2.style.height);
            return false;
     }
     document.cu.submit();
     return true;

}

function open_popup(url, w, h) {
      var v=window.open(url, '', 'toolbar=0,status=0,menubar=0,scrollbars=0,fullscreen=no,width='+w+',height='+h+',resizable=1,top=50,left=50');
}