﻿// JScript File
//Check if valid Pin quantity is entered
function checkQuantity(txtBox,e)
{
  if(document.getElementById(txtBox).value.replace(" ","").replace(" ","").replace(" ","")=="" || parseInt(document.getElementById(txtBox).value)<1 || isNaN(document.getElementById(txtBox).value))
  {
     alert("Please enter a valid quantity to continue...");
     if(window.event)//IE
      event.returnValue=false;
     else//FireFox
       e.preventDefault();
  }           
}

//Replicate data if Same as Contact Information is checked
function replicate(a1,b1,chkBox) {
 if (document.getElementById(chkBox).checked) {
	    document.getElementById(a1).value = document.getElementById(b1).value;
	 }   
}

//Replicate data if Same as Contact Information is checked
function checksameascontact(a1,a2,a3,a4,a5,a6,a7,b1,b2,b3,b4,b5,b6,b7,chkBox) {
	if (document.getElementById(chkBox).checked) {
	    document.getElementById(a1).value = document.getElementById(b1).value;
	    document.getElementById(a2).value = document.getElementById(b2).value;
	    document.getElementById(a3).value = document.getElementById(b3).value;
	    document.getElementById(a4).value = document.getElementById(b4).value;
	    document.getElementById(a5).value = document.getElementById(b5).value;
	    document.getElementById(a6).value = document.getElementById(b6).value;
	    document.getElementById(a7).value = document.getElementById(b7).value;
	}
}

//Check the value of Credit Card
function check_cc_number(a1,a2){
 var val = document.getElementById(a1).value.substring(0,1);
  if (val !=""){
    if (val !=document.getElementById(a2).value && val !='x') {
        alert('Card Type not a match to Credit Card Number');
	    document.getElementById(a1).focus();
	  }   
   }	  
}

//Check validation code
function checkValidationCode(e)
{
    $(document).ready(function()
    {
       if ( $('#ctl00_ContentPlaceHolder1_txt_validation_code').val()=="")
          { 
               $('#ctl00_ContentPlaceHolder1_lbl_message').html('Please enter a valid code');
               if(window.event)//IE
                   event.returnValue=false;
                else//FireFox
                   e.preventDefault();
          }
    });
}

//Create mask
function showMask()
{
  $(document).ready(function()
    {
       var maskHeight = $(document).height();
       var maskWidth  = $(window).width();
      
       $('#mask').css({position:'absolute'});
       $('#mask').css({top:'0', left:'0', width:maskWidth , height:maskHeight, backgroundColor:'#b6b7bc'});     
       $('#mask').fadeIn("slow");	
       $('#mask').fadeTo("slow",0.7);
    });   
}

//Show validation window
function showValidation()
{
   $('#ctl00_ContentPlaceHolder1_txt_validation_code').attr('value','');

    showMask();
    
  $(document).ready(function()
    {
       setCenter();  
       $("#div_validation").show();
    });
}


//Align popup in center
function setCenter()
{
    var top = (($(window).height() / 2) - ($("#div_validation").outerHeight() / 2)) ;
    var left = (($(window).width() / 2) - ($("#div_validation").outerWidth() / 2)) ;
    if( top < 0 ) top = 0;
    if( left < 0 ) left = 0;
    
    // IE6 fix
    if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
	
    $('#div_validation').css({position:'fixed'}); 
    $("#div_validation").css({
        top: top + 'px',
        left: left + 'px',
        zIndex: '9999'
    });    
}

//Disable order button
//Disable double clicking 
function disable()
{
    document.getElementById("ctl00_ContentPlaceHolder1_btn_order").disabled = true;
}
