// UnivisionWeb JavaScript Document
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_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_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 validate_inquiry(){
   if (isempty(document.inquiry.name,"Please enter a value in the \"Name\" field.")){
      return false}
   if (checkemail(document.inquiry.email)==false){
      return false}
   if (isempty(document.inquiry.question,"Please enter a value in the \"Question\" field.")){
      return false}
   return true;
}

function isempty(oField,cMessage){
   if (oField.value < '!') {
      alert(cMessage);
      oField.focus();
      return true}
   return false;
}


function checkemail(oField){
   var invalidaddress=new Array()
/*
   invalidaddress[0]="hotmail"
   invalidaddress[1]="rocketmail"
   invalidaddress[2]="yahoo"
   invalidaddress[3]="zdnetmail"
*/
   var invalidcheck=0
   var testresults
   var str=oField.value
   var filter=/^.+@.+\..{2,3}$/
   if (filter.test(str)){
      var tempstring=str.split("@")
      tempstring=tempstring[1].split(".")
      for (i=0;i<invalidaddress.length;i++){
         if (tempstring[0]==invalidaddress[i]){
            invalidcheck=1 ;
         }
      }
      if (invalidcheck!=1){
         testresults=true ;
      }
      else{
         alert("Please input a more official e-mail address.");
         testresults=false;
      }
   }
   else{
      alert("Please input a valid e-mail address.");
      testresults=false;
   }
   if (testresults == false){
      oField.focus();
   }
   return (testresults);
}
function isZipNumberBad(oField,cMessage){
   // Check for correct phone number
   reZipNumber = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
   if (!reZipNumber.test(oField.value)) {
      alert(cMessage);
      oField.focus();
      return true;
   }
   return false;
}
function confirmDelete(pk,name,page){
   reply = confirm( "Are you sure you want to delete " + name + " ?", "OK" );
   if(reply){
      window.location = page + "&delete=" + pk;
   }
}
function valccinfo(callingForm){
   if (isempty(callingForm.cc_fname,"Please enter a value in the \"First Name\" field!")){
      return false}
   if (isempty(callingForm.cc_lname,"Please enter a value in the \"Last Name\" field!")){
      return false}
   if (isempty(callingForm.cc_add1,"Please enter a value in the \"Address 1\" field!")){
      return false}
   if (isempty(callingForm.cc_city,"Please enter a value in the \"City\" field!")){
      return false}
   if (isempty(callingForm.cc_zip,"Please enter a value in the \"ZIP Code\" field!")){
      return false}
   if (isZipNumberBad(callingForm.cc_zip,"ZIP Code Is Not Valid!")){
      return false}
   if (isempty(callingForm.cc_number,"Please enter a value in the \"Card Number\" field!")){
      return false}
   if (isempty(callingForm.cc_cvv,"Please enter a value in the \"Card Verification Number\" field!")){
      return false}
   if (isempty(callingForm.s_email,"Please enter a value in the \"E Mail\" field!")){
      return false}
   if (checkemail(callingForm.s_email)==false){
      return false}
}
function same_as_contact(){
   document.order_form.s_fullname.value = document.order_form.cc_fname.value + " " + document.order_form.cc_lname.value;
   document.order_form.s_addr1.value = document.order_form.cc_add1.value;
   document.order_form.s_addr2.value = document.order_form.cc_add2.value;
   document.order_form.s_city.value = document.order_form.cc_city.value;
   document.order_form.s_state.value = document.order_form.cc_state.value;
   document.order_form.s_zip.value = document.order_form.cc_zip.value;
}

