/*onBlur="if (PositiveInteger(this) == true) {
          if (CreditModCheck(this) == false) {
             alert('Invalid Card Number');
          }
       }"
*/
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

// Image Overload

function onImageOn(img) {
   img.src = imageon.src;
}

function onImageOff(img) {
   img.src = imageoff.src;
}


function viewform(m) {
   var w = 600;
   var h = 600;
   var scroll = 'no';
   var settings;
   var LeftPosition;
   var TopPosition;
   var win;

   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;
   settings = settings + ',resizable=no,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no';

   win = window.open(m, 'pre', settings);
   win.name = 'name';
   win.focus();
}

function popup2(m) {
  var scroll = 'yes';
  var settings;
  var win;


  settings = 'scrollbars='+scroll;
  settings = settings + ',resizable=yes,maximize=yes,status=no,toolbar=no,directories=no,menubar=no,location=no';

  win = window.open(m, 'pre', settings);
  win.name = 'name';
  win.focus();
}


function check_action_form() {

  if (!document.action_form.get_ref_category.value) {
     alert("Please select a system!");
     document.action_form.get_ref_category.focus();
     return false;
  }

  if (!document.action_form.get_ref_item_list.value) {
     alert("Please select a category!");
     document.action_form.get_ref_item_list.focus();
     return false;
  }

  document.action_form.category_id.value = document.action_form.get_ref_category.value;
  document.action_form.ref_item_list.value = document.action_form.get_ref_item_list.value;

  return true;
}


function checkUserInfoStep1() {


  if (!document.UserForm.get_fname.value) {
      alert("Please enter First Name!");
      document.UserForm.get_fname.focus();
     return false;
  }

  if (!document.UserForm.get_lname.value) {
      alert("Please enter Last Name!");
      document.UserForm.get_lname.focus();
     return false;
  }


  if (!document.UserForm.get_address.value) {
      alert("Please enter Address!");
      document.UserForm.get_address.focus();
     return false;
  }


  if (!document.UserForm.get_city.value) {
      alert("Please enter City!");
      document.UserForm.get_city.focus();
     return false;
  }

  if (!document.UserForm.get_ref_state.value) {
      alert("Please choose state/province!");
      document.UserForm.get_ref_state.focus();
     return false;
  }


  if (!document.UserForm.get_postal_code.value) {
      alert("Please enter Postal/Zip code!");
      document.UserForm.get_postal_code.focus();
     return false;
  }


  if (!document.UserForm.get_phone.value) {
      alert("Please enter Phone!");
      document.UserForm.get_phone.focus();
     return false;
  }



 if (!document.UserForm.get_shipping_address.value) {
      alert("Please enter Shipping Address!");
      document.UserForm.get_shipping_address.focus();
     return false;
  }

 if (!document.UserForm.get_shipping_city.value) {
      alert("Please enter Shipping City!");
      document.UserForm.get_shipping_city.focus();
     return false;
  }

  if (!document.UserForm.get_shipping_ref_state.value) {
      alert("Please choose shipping state/province!");
      document.UserForm.get_shipping_ref_state.focus();
     return false;
  }


  if (!document.UserForm.get_shipping_postal_code.value) {
      alert("Please enter Shipping Postal/Zip code!");
      document.UserForm.get_shipping_postal_code.focus();
     return false;
  }


  if (!document.UserForm.get_email.value) {
      alert("Please enter Email!");
      document.UserForm.get_email.focus();
     return false;
  }




  adresse = document.UserForm.get_email.value;
  var place = adresse.indexOf("@",1);
  var point = adresse.indexOf(".",place+1);

  if ((place > -1)&&(adresse.length >2)&&(point > 1))
  {

  }
    else
  {
    alert('Please use valid email address');
    document.UserForm.get_email.focus();
    return false;
  }



  if (!document.UserForm.get_name.value) {
      alert("Please enter Username!");
      document.UserForm.get_name.focus();
     return false;
  }


  if (!document.UserForm.get_pasw_1.value) {
      alert("Please enter password!");
      document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (!document.UserForm.get_pasw_2.value) {
      alert("Please confirm password!");
      document.UserForm.get_pasw_2.focus();
     return false;
  }

  if (document.UserForm.get_pasw_1.value != document.UserForm.get_pasw_2.value) {
      alert("Password and confirm password not match");
      document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (document.UserForm.get_pasw_1.value.length < 6) {
     alert("The password should be more than 6 symbols");
     document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (document.UserForm.get_phone.value.length < 7 || document.UserForm.get_phone.value.length > 32 ) {
     alert("Phone number must be between 7 and 32 characters long");
     document.UserForm.get_phone.focus();
     return false;
  }

  return true;
}


function checkUserInfoStep2() {


  if (!document.UserForm.get_address.value) {
      alert("Please enter Address!");
      document.UserForm.get_address.focus();
     return false;
  }


  if (!document.UserForm.get_city.value) {
      alert("Please enter City!");
      document.UserForm.get_city.focus();
     return false;
  }

  if (!document.UserForm.get_ref_state.value) {
      alert("Please choose state/province!");
      document.UserForm.get_ref_state.focus();
     return false;
  }


  if (!document.UserForm.get_postal_code.value) {
      alert("Please enter Postal/Zip code!");
      document.UserForm.get_postal_code.focus();
     return false;
  }


  if (!document.UserForm.get_phone.value) {
      alert("Please enter Phone!");
      document.UserForm.get_phone.focus();
     return false;
  }



 if (!document.UserForm.get_shipping_address.value) {
      alert("Please enter Shipping Address!");
      document.UserForm.get_shipping_address.focus();
     return false;
  }

 if (!document.UserForm.get_shipping_city.value) {
      alert("Please enter Shipping City!");
      document.UserForm.get_shipping_city.focus();
     return false;
  }

  if (!document.UserForm.get_shipping_ref_state.value) {
      alert("Please choose shipping state/province!");
      document.UserForm.get_shipping_ref_state.focus();
     return false;
  }


  if (!document.UserForm.get_shipping_postal_code.value) {
      alert("Please enter Shipping Postal/Zip code!");
      document.UserForm.get_shipping_postal_code.focus();
     return false;
  }

  return true;
}


function checkUserInfoStep3() {
 var flag = false;



 if (!document.UserForm.get_ref_question.value) {
     alert("Please fill 'How did you find us' field!");
     document.UserForm.get_tos.focus();
     return false;
 }


 if (!document.UserForm.get_tos.checked) {
     alert("You can open membership account if you agree with our TOS and check box for agreeement!");
     document.UserForm.get_tos.focus();
     return false;
 }

 return true;
}


function changecardtype() {
   if (document.orderform.trnCardType.value == "AMEX") {
       document.orderform.trnCardNumber.maxLength=15;
   } else {
       document.orderform.trnCardNumber.maxLength=16;
   }
}

function CheckOrderForm() {

 if (!document.orderform.trnCardOwner.value) {
     alert("Please fill Name on Card!");
     document.orderform.trnCardOwner.focus();
     return false;
 }


 if (!document.orderform.trnCardType.value) {
     alert("Please fill Card Type!");
     document.orderform.trnCardType.focus();
     return false;
 }

 if (!document.orderform.trnCardNumber.value) {
      alert('Invalid Credit Card Number');
     return false;
 }

  if (PositiveInteger(document.orderform.trnCardNumber) == true) {
    if (CreditModCheck(document.orderform.trnCardNumber) == false) {
      alert('Invalid Credit Card Number');
      return false;
    }
  }
  else{
    return false;
  }

  var nowDate = new Date();
  var nowYear = nowDate.getYear();
  var nowMonth = nowDate.getMonth() + 1;
  var expYear = document.orderform.trnExpYear.value;
  var expMonth = document.orderform.trnExpMonth.value;


  if (expYear == "05") {
     expYear = 2005;
  }

  if (expYear == "06") {
     expYear = 2006;
  }

  if (expYear == "07") {
     expYear = 2007;
  }

  if (expYear == "08") {
     expYear = 2008;
  }

  if (expYear == "09") {
     expYear = 2009;
  }


  if (expYear == "10") {
     expYear = 2010;
  }

  if (expYear == "11") {
     expYear = 2011;
  }

  if (expYear == "12") {
     expYear = 2012;
  }

  if (expYear == "13") {
     expYear = 2013;
  }

  if (expYear == "14") {
     expYear = 2014;
  }

  if (expYear == "15") {
     expYear = 2015;
  }


  if (nowYear == 0)
  {
     nowYear = 2000;
  }

  if (nowYear < 1900)
  {
     nowYear = nowYear + 1900;
  }

  if (expYear <= nowYear)
  {
     if (expMonth < nowMonth)
     {
        alert("According to the date you have entered, your credit card has expired")
        document.orderform.trnExpMonth.focus();
        return false;
     }
  }

 return true;
}



function checkCCInfo() {

 if (!document.ccform.get_cc_type.value) {
      alert("Please enter Card Type!");
      document.ccform.get_cc_type.focus();
     return false;
  }


 if (!document.ccform.get_cc_num.value) {
      alert("Please enter Card #!");
      document.ccform.get_cc_num.focus();
     return false;
  }

 if (!document.ccform.get_cc_expire_month.value) {
      alert("Please enter Card Expire Date!");
      document.ccform.get_cc_expire_month.focus();
     return false;
  }

 if (!document.ccform.get_cc_expire_year.value) {
      alert("Please enter Card Expire Date!");
      document.ccform.get_cc_expire_year.focus();
     return false;
  }

 if (!document.ccform.get_cc_code.value) {
      alert("Please enter Verification Code!");
      document.ccform.get_cc_code.focus();
     return false;
  }



  return true;
}



function QuickLogin() {

   if (!document.loginform.username.value) {
      alert("Please enter user name!");
      document.loginform.username.focus();
     return false;
  }


   if (!document.loginform.password.value) {
      alert("Please enter password!");
      document.loginform.password.focus();
     return false;
  }

  return true;
}


function SelectWishList(mark) {

  for (i = 0; i < document.sent_item_form.elements.length; i++) {
    var item = document.sent_item_form.elements[i];
    if (item.name == "wish_list_id[]") {
       item.checked = mark;
     };
   }
}


function InputUserInfo() {
  if (!document.UserForm.get_name.value) {
      alert("Please enter Username!");
      document.UserForm.get_name.focus();
     return false;
  }

  return true;
}


function checkUserInfo() {

  if (!document.UserForm.get_name.value) {
      alert("Please enter Username!");
      document.UserForm.get_name.focus();
     return false;
  }


  if (!document.UserForm.get_pasw_1.value) {
      alert("Please enter password!");
      document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (!document.UserForm.get_pasw_2.value) {
      alert("Please confirm password!");
      document.UserForm.get_pasw_2.focus();
     return false;
  }

  if (document.UserForm.get_pasw_1.value != document.UserForm.get_pasw_2.value) {
      alert("Password and confirm password not match");
      document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (document.UserForm.get_pasw_1.value.length < 6) {
     alert("The password should be more than 6 symbols");
     document.UserForm.get_pasw_1.focus();
     return false;
  }



  if (!document.UserForm.get_fname.value) {
      alert("Please enter First Name!");
      document.UserForm.get_fname.focus();
     return false;
  }

  if (!document.UserForm.get_lname.value) {
      alert("Please enter Last Name!");
      document.UserForm.get_lname.focus();
     return false;
  }


  if (!document.UserForm.get_address.value) {
      alert("Please enter Address!");
      document.UserForm.get_address.focus();
     return false;
  }


  if (!document.UserForm.get_city.value) {
      alert("Please enter City!");
      document.UserForm.get_city.focus();
     return false;
  }

  if (!document.UserForm.get_ref_state.value) {
      alert("Please choose state/province!");
      document.UserForm.get_ref_state.focus();
     return false;
  }


  if (!document.UserForm.get_postal_code.value) {
      alert("Please enter Postal/Zip code!");
      document.UserForm.get_postal_code.focus();
     return false;
  }


  if (!document.UserForm.get_phone.value) {
      alert("Please enter Phone!");
      document.UserForm.get_phone.focus();
     return false;
  }


  if (!document.UserForm.get_email.value) {
      alert("Please enter Email!");
      document.UserForm.get_email.focus();
     return false;
  }



  adresse = document.UserForm.get_email.value;
  var place = adresse.indexOf("@",1);
  var point = adresse.indexOf(".",place+1);

  if ((place > -1)&&(adresse.length >2)&&(point > 1))
  {

  }
    else
  {
    alert('Please use valid email address');
    document.UserForm.get_email.focus();
    return false;
  }





 if (!document.UserForm.get_shipping_address.value) {
      alert("Please enter Shipping Address!");
      document.UserForm.get_shipping_address.focus();
     return false;
  }

 if (!document.UserForm.get_shipping_city.value) {
      alert("Please enter Shipping City!");
      document.UserForm.get_shipping_city.focus();
     return false;
  }

  if (!document.UserForm.get_shipping_ref_state.value) {
      alert("Please choose shipping state/province!");
      document.UserForm.get_shipping_ref_state.focus();
     return false;
  }


  if (!document.UserForm.get_shipping_postal_code.value) {
      alert("Please enter Shipping Postal/Zip code!");
      document.UserForm.get_shipping_postal_code.focus();
     return false;
  }


 if (!document.UserForm.get_tos.checked) {
      alert("You can open membership account if you agree with our TOS and check box for agreeement!");
      document.UserForm.get_tos.focus();
     return false;
 }

 return true;
}


function checkUserAff() {

  if (!document.UserForm.get_name.value) {
      alert("Please enter Username!");
      document.UserForm.get_name.focus();
     return false;
  }


  if (!document.UserForm.get_pasw_1.value) {
      alert("Please enter password!");
      document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (!document.UserForm.get_pasw_2.value) {
      alert("Please confirm password!");
      document.UserForm.get_pasw_2.focus();
     return false;
  }

  if (document.UserForm.get_pasw_1.value != document.UserForm.get_pasw_2.value) {
      alert("Password and confirm password not match");
      document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (document.UserForm.get_pasw_1.value.length < 6) {
     alert("The password should be more than 6 symbols");
     document.UserForm.get_pasw_1.focus();
     return false;
  }


  if (!document.UserForm.get_lname.value) {
      alert("Please enter Contact Person Name!");
      document.UserForm.get_lname.focus();
     return false;
  }


  if (!document.UserForm.get_address.value) {
      alert("Please enter Address!");
      document.UserForm.get_address.focus();
     return false;
  }


  if (!document.UserForm.get_city.value) {
      alert("Please enter City!");
      document.UserForm.get_city.focus();
     return false;
  }

  if (!document.UserForm.get_ref_state.value) {
      alert("Please choose state/province!");
      document.UserForm.get_ref_state.focus();
     return false;
  }


  if (!document.UserForm.get_phone.value) {
      alert("Please enter Phone!");
      document.UserForm.get_phone.focus();
      return false;
  }


  if (!document.UserForm.get_email.value) {
      alert("Please enter Email!");
      document.UserForm.get_email.focus();
      return false;
  }



  adresse = document.UserForm.get_email.value;

  var place = adresse.indexOf("@",1);
  var point = adresse.indexOf(".",place+1);

  if ((place > -1)&&(adresse.length >2)&&(point > 1))
  {

  }
    else
  {
    alert('Please use valid email address');
    document.UserForm.get_email.focus();
    return false;
  }


 if (!document.UserForm.get_affl.checked) {
      alert("You can open affiliate account if you agree with our TOS and check box for agreeement!");
      document.UserForm.get_affl.focus();
      return false;
 }

 return true;
}


function checkSubaccountInfo() {

  if (!document.UserForm.get_name.value) {
      alert("Please enter Username!");
      document.UserForm.get_name.focus();
     return false;
  }


  if (!document.UserForm.get_pasw_1.value) {
      alert("Please enter password!");
      document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (!document.UserForm.get_pasw_2.value) {
      alert("Please confirm password!");
      document.UserForm.get_pasw_2.focus();
     return false;
  }

  if (document.UserForm.get_pasw_1.value != document.UserForm.get_pasw_2.value) {
      alert("Password and confirm password not match");
      document.UserForm.get_pasw_1.focus();
     return false;
  }

  if (document.UserForm.get_pasw_1.value.length < 6) {
     alert("The password should be more than 6 symbols");
     document.UserForm.get_pasw_1.focus();
     return false;
  }



  if (!document.UserForm.get_fname.value) {
      alert("Please enter First Name!");
      document.UserForm.get_fname.focus();
     return false;
  }

  if (!document.UserForm.get_lname.value) {
      alert("Please enter Last Name!");
      document.UserForm.get_lname.focus();
     return false;
  }


  if (!document.UserForm.get_email.value) {
      alert("Please enter Email!");
      document.UserForm.get_email.focus();
     return false;
  }



  adresse = document.UserForm.get_email.value;
  var place = adresse.indexOf("@",1);
  var point = adresse.indexOf(".",place+1);

  if ((place > -1)&&(adresse.length >2)&&(point > 1))
  {

  }
    else
  {
    alert('Please use valid email address');
    document.UserForm.get_email.focus();
    return false;
  }





 if (!document.UserForm.get_shipping_address.value) {
      alert("Please enter Shipping Address!");
      document.UserForm.get_shipping_address.focus();
     return false;
  }

 if (!document.UserForm.get_shipping_city.value) {
      alert("Please enter Shipping City!");
      document.UserForm.get_shipping_city.focus();
     return false;
  }

  if (!document.UserForm.get_shipping_ref_state.value) {
      alert("Please choose shipping state/province!");
      document.UserForm.get_shipping_ref_state.focus();
     return false;
  }


  if (!document.UserForm.get_shipping_postal_code.value) {
      alert("Please enter Shipping Postal/Zip code!");
      document.UserForm.get_shipping_postal_code.focus();
     return false;
  }

   return true;
}


function checkGiftUserInfo() {


  if (!document.GiftUserForm.get_email.value) {
      alert("Please enter recipient email!");
      document.GiftUserForm.get_email.focus();
     return false;
  }

  if (!document.GiftUserForm.get_confirm_email.value) {
      alert("Please enter confirm email!");
      document.GiftUserForm.get_confirm_email.focus();
     return false;
  }


  adresse = document.GiftUserForm.get_email.value;
  var place = adresse.indexOf("@",1);
  var point = adresse.indexOf(".",place+1);

  if ((place > -1)&&(adresse.length >2)&&(point > 1))
  {

  }
    else
  {
    alert('Please use valid email address');
    document.GiftUserForm.get_email.focus();
    return false;
  }


  if (document.GiftUserForm.get_email.value != document.GiftUserForm.get_confirm_email.value) {
      alert("Email and confirm email not match");
      document.GiftUserForm.get_email.focus();
     return false;
  }

  if (!document.GiftUserForm.get_from.value) {
      alert("Please enter yuor own email!");
      document.GiftUserForm.get_from.focus();
     return false;
  }

  adresse = document.GiftUserForm.get_from.value;
  var place = adresse.indexOf("@",1);
  var point = adresse.indexOf(".",place+1);

  if ((place > -1)&&(adresse.length >2)&&(point > 1))
  {

  }
    else
  {
    alert('Please use valid email address');
    document.GiftUserForm.get_email.focus();
    return false;
  }

  return true;
}


function confirm_del() {
  var reply = confirm("This will permanantly delete this record!");

  if(reply) {
     return true;
   } else {
     return false;
   }
}


function onSubaccountMaster(act) {
  if ( document.UserForm.get_master.checked) {
    flag = 1;
  } else {
    flag = "";
  }

  window.location="subaccount.php?act=" + act + "&get_master="+flag;
}


function NothingSend(act) {
   document.sent_item_form.act.value=act;
   document.sent_item_form.submit();
  return true;
}

// Old routine
/*
function SelectAuto(act) {

  if ( document.UserForm.get_auto_fill_shipping.checked) {
       document.UserForm.get_shipping_address.value = document.UserForm.get_address.value;
       document.UserForm.get_shipping_address2.value = document.UserForm.get_address2.value;
       document.UserForm.get_shipping_city.value =  document.UserForm.get_city.value;
       document.UserForm.get_shipping_postal_code.value = document.UserForm.get_postal_code.value;

       if (act == "admin_user_add_form" || act == "admin_user_mod_form" || act == "subaccount_add_form" || act == "subaccount_mod_form") {
       } else if (act == "affiliate_add_form") {
         document.UserForm.action = "register.php?act=affiliate_add_form";
       } else if (act == "buy_item") {
         document.UserForm.action = "order.php";
       } else {
         document.UserForm.action = "register.php#shipping";
       }

       onCountryChange(act);

  } else {
       document.UserForm.get_shipping_address.value ="";
       document.UserForm.get_shipping_address2.value ="";
       document.UserForm.get_shipping_city.value = "";
       document.UserForm.get_shipping_postal_code.value = "";
  }

}
*/

function SelectAuto(act) {

  if ( document.UserForm.get_auto_fill_shipping.checked) {
       document.UserForm.get_shipping_address.value = document.UserForm.get_address.value;
       document.UserForm.get_shipping_address2.value = document.UserForm.get_address2.value;
       document.UserForm.get_shipping_city.value =  document.UserForm.get_city.value;
       document.UserForm.get_shipping_postal_code.value = document.UserForm.get_postal_code.value;

       if (act != "step1") {
         document.UserForm.get_shipping_ref_country.value = document.UserForm.get_ref_country.value;
       }

       document.UserForm.get_shipping_ref_state.value = document.UserForm.get_ref_state.value;

  } else {
       document.UserForm.get_shipping_address.value ="";
       document.UserForm.get_shipping_address2.value ="";
       document.UserForm.get_shipping_city.value = "";
       document.UserForm.get_shipping_postal_code.value = "";
       document.UserForm.get_shipping_ref_state.value = "";
  }

}

function SelectAutoAff(act) {

  if ( document.UserForm.get_auto_fill_shipping.checked) {
       document.UserForm.get_shipping_address.value = document.UserForm.get_address.value;
       document.UserForm.get_shipping_address2.value = document.UserForm.get_address2.value;
       document.UserForm.get_shipping_city.value =  document.UserForm.get_city.value;
       document.UserForm.get_shipping_postal_code.value = document.UserForm.get_postal_code.value;
       document.UserForm.get_shipping_phone.value = document.UserForm.get_phone.value;
       document.UserForm.get_shipping_fax.value = document.UserForm.get_fax.value;
       document.UserForm.get_shipping_email.value = document.UserForm.get_email.value;

       document.UserForm.get_pay_name.value = document.UserForm.get_lname.value;

       if (act == "admin_user_add_form" || act == "admin_user_mod_form" || act == "subaccount_add_form" || act == "subaccount_mod_form") {
       } else if (act == "affiliate_add_form") {
         document.UserForm.action = "register.php?act=affiliate_add_form";
       } else if (act == "buy_item") {
         document.UserForm.action = "order.php";
       } else {
         document.UserForm.action = "register.php#shipping";
       }

       onCountryChange(act);
  } else {
       document.UserForm.get_shipping_address.value ="";
       document.UserForm.get_shipping_address2.value ="";
       document.UserForm.get_shipping_city.value = "";
       document.UserForm.get_shipping_postal_code.value = "";
  }

}


function onCountryChange(act) {
  document.UserForm.act.value=act;
  document.UserForm.submit();
  return true;
}


function setSelectOptions(the_form, the_select, do_check) {
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    } // end for

    return true;
}


function viewform2(m, w, h) {
   alter=(settings);
   var scroll = 'yes';
   var settings;
   var LeftPosition;
   var TopPosition;
   var win;

   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

   settings = 'height='+h+', width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;
   settings = settings + ', resizable=yes, maximize=yes, status=no,toolbar=no,directories=no,menubar=no,location=no';

   win = window.open(m, 'pre', settings);
   win.name = 'name';
   win.focus();
}


function doPreview(param1, param2)
{

  if (dom) {
    var src = document.getElementById(param1).value;
  } else if (ie) {
    var src = document.all[param1].value;
  }

  if (src.charAt(1)==":") src = "file:/" + src;

  if (dom) {
    document.getElementById(param2).src=src;
  } else if (ie) {
    document.all[param2].src = src;
  }

}


function confirm_del() {
  var reply = confirm("This will permanantly delete this record!");

  if(reply) {
     return true;
   } else {
     return false;
   }
}

function select_esrb(mark) {
  for (i = 0; i < document.ParentalForm.elements.length; i++) {
    var item = document.ParentalForm.elements[i];
    if (item.name == "esrb[]") {
      item.checked = mark;
     };
   }
}


opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
ie = (document.all && !opera)? true : false;
dom = (document.getElementById && !ie && !opera)? true : false;

var expiration = new Date();
expiration.setTime(expiration.getTime() + 3600*3600*3600);


function showtranscript(elemId,displayValue) {

  if (dom) {

      if (displayValue) {
         document.getElementById(elemId).style.display = displayValue;
         return 0;
      }

      if (document.getElementById(elemId).style.display == "none") {
         document.getElementById(elemId).style.display = "block";
      } else if (document.getElementById(elemId).style.display == "block") {
         document.getElementById(elemId).style.display = "none";
      }

  } else if (ie) {


    if (displayValue) {
       window.document.all[elemId].style.display =  displayValue;
       return 0;
    }

    if (document.all[elemId].style.display == "block") {
       document.all[elemId].style.display = "none";
    } else if (document.all[elemId].style.display == "none") {
       document.all[elemId].style.display = "block";
    }

  }
}

function display(cookie_name, id) {
    var template_category_cookie;

    template_category_cookie = GetCookie(cookie_name);

    if (template_category_cookie) {
       SetCookie(cookie_name, "1", expiration, "", "","")
       showtranscript(id, 'block');
    } else {
       SetCookie(cookie_name, "", expiration, "", "","")
       showtranscript(id, 'none');
    }

    return true;
}


function onCookieChange(cookie_name, id) {

  if (dom) {
      if (document.getElementById(id).style.display == "none") {
         SetCookie(cookie_name, "", expiration, "", "","")
      } else if (document.getElementById(id).style.display == "block") {
         SetCookie(cookie_name, "1", expiration, "", "","")
      }

  } else if (ie) {

    if (document.all[id].style.display == "block") {
       SetCookie(cookie_name, "1", expiration, "", "","")
    } else if (document.all[id].style.display == "none") {
       SetCookie(cookie_name, "", expiration, "", "","")
    }

  }
}


function SetCookie(name, value, expires, path, domain, secure) {

   var mycookie = name + "=" + escape(value);
   var myexpires = new Date();
   myexpires.setTime(myexpires.getTime() + 5000);
   mycookie = mycookie + "; myexpires=" + myexpires.toGMTString();
   document.cookie = mycookie;
}


function GetCookie(name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;

   while (i < clen) {
     var j = i + alen;
     if (document.cookie.substring(i, j) == arg)  return getCookieVal (j);
     i = document.cookie.indexOf(" ", i) + 1;
     if (i == 0) break;
   }

   return null;
}


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}


function checkTellaFriend() {

  if (!document.TellaFriendForm.get_sender.value) {
      alert("Please enter your email!");
      document.TellaFriendForm.get_sender.focus();
      return false;
  }

  if (!document.TellaFriendForm.get_email1.value && !document.TellaFriendForm.get_email2.value && !document.TellaFriendForm.get_email3.value ) {
      alert("Please enter friend email!");
      document.TellaFriendForm.get_email1.focus();
      return false;
  }


  if (!document.TellaFriendForm.get_subject.value) {
      alert("Please enter subject!");
      document.TellaFriendForm.get_subject.focus();
      return false;
  }


  if (!document.TellaFriendForm.get_body.value) {
      alert("Please enter message!");
      document.TellaFriendForm.get_body.focus();
      return false;
  }


}

function checkReferaFriend() {

  if (!document.ReferaFriendForm.get_email1.value && !document.ReferaFriendForm.get_email2.value && !document.ReferaFriendForm.get_email3.value ) {
      alert("Please enter friend email!");
      document.ReferaFriendForm.get_email1.focus();
      return false;
  }

}



function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

var preloadFlag = false;
function preloadImages() {
  if (document.images) {
    preloadFlag = true;
  }
}

function changeImages() {
  if (document.images && (preloadFlag == true)) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}

function checkBasket() {
  for(var i = 0; i <= document.basket.elements.length - 1; i++){
    if (document.basket.elements[i].className == "formfields"){
      if (isNaN(parseInt(document.basket.elements[i].value))){
        alert('Please enter only numeric values!');
        document.basket.elements[i].focus();
        return false;
      }
    }
  }

  //document.basket.submit();

  return true;
}

function left_advanced_search_form_clear() {
  document.left_advanced_search_form.get_name.value = "";
  document.left_advanced_search_form.get_keyword.value = "";
  document.left_advanced_search_form.get_ref_actor.value = "";
//  document.left_advanced_search_form.get_ref_studio.value = "";
  document.left_advanced_search_form.get_ref_action.value = "";
}

function CheckAdvancedSearch() {
  if (
      !document.left_advanced_search_form.get_name.value 
      && !document.left_advanced_search_form.get_keyword.value 
      && !document.left_advanced_search_form.get_ref_actor.value 
      && !document.left_advanced_search_form.get_ref_action.value
     ) 
  {
      alert("Please select search criterias!");
      document.left_advanced_search_form.get_name.focus();
      return false;
  }


  if (document.left_advanced_search_form.get_name.value.indexOf("%") != -1) {
      alert("Delete symbol % from title");
      return false;
  }
  if (document.left_advanced_search_form.get_keyword.value.indexOf("%") != -1) {
      alert("Delete symbol % from keyword");
      return false;
  }

  return true;
}

function rent_it(form) {
	form.submit()
  /*$.prompt('Are you sure want to rent this movie?',{ buttons: { 'Rent it': true, 'Cancel': false },
           callback: function(v, m){
	         if (v==true)
	           form.submit()
	   } });*/
}

function prompt_del_q(url) {
	window.location = url;
	/*$.prompt('Are you sure want to delete this movie from Queue?',{ buttons: { 'Delete': true, 'Cancel': false },
        callback: function(v, m){
		  if (v)
			  window.location = url; 
	    } });*/ 	
}

function hidden_button(elemId,hidden_items){
   document.getElementById(elemId).style.display = "none";
   document.getElementById(hidden_items).style.display = "none";
   
}