﻿// Copyright MarketVelocity 2008
// All rights are reserved. Reproduction or transmission in whole or in part, in
// any form or by any means, electronic, mechanical or otherwise, is prohibited
// without the prior written consent of the copyright owner.
//             
//      Date           Dev            Comments
//		----------     ----------     --------------------------------------------------------------
//      7-July-06      MVN             File created
//      30-August-07   MVN             TNP-1551, 1552 Fixed media bonus validation issue
//      19-February-08 AAS             TNP-1683 Validate purchase date and purchase amount
//      27-February-08 JM              For Multiple Session Issue.
//      20-March-08    AAS             TNP 1698 Hp custom quote updates
//      15-July-08     VP              TNP 1831 Opening new window For Menu Links.
//      08-Sep-08       VP             TNP 1772 Check the email addressess count
//      26-Sep-08      US              TNP - 1900 HP Quote Tool Page- Continue Button Issue. Added method HPGotoTerms.
//      26-Sep-08      US              TNP - 1896 Added common sales rep javascript fucntion i.e. GeneratePDF,CheckLogin,ConfirmMsg.
//      11-Aug-09      TB              TNP - 2209 HP Registration Page perform zip/postal code validation. 
/*Put this function in to common.js*/
//Added for multiple Session Issue.
if(window.name == '')
{
    //window.location.href = '/InValidAccess.aspx';
}
function hidestatus(){
window.status='Done';
return true}
function IsNumeric(strString)
{
    var strValidChars = "0123456789.";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
     }
    return blnResult;
}
   
function IsAlphaNumeric(strString)
{
    var strValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
     }
    return blnResult;
}

function ValidateQty(sender, args)
{
    var sValue = args.Value;       
    if (isNaN(sValue) || sValue <= 0 || (sValue.indexOf('.') != -1))
    {
        args.IsValid = false;
        return;
    }
    args.IsValid = true;
}

function ValidateUSZip(sender, args)
{
    var sValue = args.Value;            
    if (!IsNumeric(sValue))
    {
        args.IsValid = false;
        return;
    }
    if (sValue.length != 5)
    {
        args.IsValid = false;
        return;
    } 
    args.IsValid = true;
}

function ValidateCanadaZip(sender, args)
{
    var sValue = args.Value;        
    if (sValue.length != 6 && sValue.length != 7)
    {
        args.IsValid = false;
        return;
    }
   
   if (sValue.length == 6 )
   {
        if (IsNumeric(sValue))
        {
            args.IsValid = false;
            return;
        }
        
        if (!IsAlphaNumeric(sValue))
        {
            args.IsValid = false;
            return;
        }
    }
   if (sValue.length == 7 )
   {
        if (IsNumeric(sValue))
        {
            args.IsValid = false;
            return;
        }
        if (!(sValue.charAt(3)==' '))
        {
            args.IsValid = false;
            return;
        }
        if (!(IsAlphaNumeric(sValue.substring(0,3)) && isNaN(sValue.substring(0,3))))
        {
            args.IsValid = false;
            return;
        }
        if (!(IsAlphaNumeric(sValue.substring(4,7)) && isNaN(sValue.substring(4,7))))
        {
            args.IsValid = false;
            return;
        }
    }
    
    args.IsValid = true;
  
}

function ValidateUSCanadaZip(sender, args)
{
    var sValue = args.Value;        
    if (sValue.length != 7 && sValue.length != 6 && sValue.length != 5)
    {
        args.IsValid = false;
        return;
    }
        
    if (sValue.length == 5)
    {
        if (!IsNumeric(sValue))
        {
            args.IsValid = false;
            return;
        }
    }
    
    if (sValue.length == 6)
    {
        if (IsNumeric(sValue))
        {
            args.IsValid = false;
            return;
        }
        
        if (!IsAlphaNumeric(sValue))
        {
            args.IsValid = false;
            return;
        }
    }
   if (sValue.length == 7 )
   {
        if (IsNumeric(sValue))
        {
            args.IsValid = false;
            return;
        }
        if (!(sValue.charAt(3)==' '))
        {
            args.IsValid = false;
            return;
        }
        if (!(IsAlphaNumeric(sValue.substring(0,3)) && isNaN(sValue.substring(0,3))))
        {
            args.IsValid = false;
            return;
        }
        if (!(IsAlphaNumeric(sValue.substring(4,7)) && isNaN(sValue.substring(4,7))))
        {
            args.IsValid = false;
            return;
        }
    }
 
    args.IsValid = true;
}

function Confirmation(cboValue)
{        
    if(cboValue.value == "0")
    {
        alert("Please select quote to delete");
        return false;    
    }
    else
    {        
        var UserInput = confirm('Delete selected quote?');
        if(UserInput)
            return true;            
        else
            return false;
    }
}

function change(v)
{
    for(i = 0; i < document.forms["aspnetForm"].elements.length; i ++)
    {
        elm = document.forms["aspnetForm"].elements[i] 
        if (elm.type == 'radio' && elm.name.match("\\$one")!= null) 
        { 
                if (elm.value == v.value) 
                { 
                    elm.checked = true; 
                }
                else
                {
                    elm.checked = false; 
                } 
        } 
    }            
}

function Validate()
{
    var flag;
    flag = false;
    for(i = 0; i < document.forms["aspnetForm"].elements.length; i ++)
    {
        elm = document.forms["aspnetForm"].elements[i] 
        if (elm.type == 'radio' && elm.name.match("\\$one")!= null) 
        { 
            if(elm.checked == true)
                flag = true;
        } 
    }
    if(flag == false)
    {
        alert("Please select at least one address");
        return false;
    }
    return true;
}      

function ValidateZip(sender, args)
{
   var sValue = args.Value;        
    if (sValue.length < 5)
    {
        args.IsValid = false;
        return;
    }
    args.IsValid = true;
}

    

function ChangePurchaseQty(tradeInQtyID, promoQtyID)
{
    promoQtyID.value = tradeInQtyID.value;        
}          

function OpenWindow(sPage, keyValue, width, height)
{
    window.open(sPage,keyValue,'toolbar=0,width='+ width + ',height=' + height + ',resizable=1,scrollbars=1');
    return false;        
}


function ValidateCheckBox(sender, args)
    {
        if (document.getElementById("ctl00_ContentPlaceHolder_chkEmail").checked == false && document.getElementById("ctl00_ContentPlaceHolder_chkPhone").checked == false && document.getElementById("ctl00_ContentPlaceHolder_chkMail").checked == false && document.getElementById("ctl00_ContentPlaceHolder_chkContact").checked == false)
        {
            args.IsValid = false;
            return;
        }        
    }
    
        
    function DontContact()
    {
        var chkEmail = document.getElementById("ctl00_ContentPlaceHolder_chkEmail");
        var chkPhone = document.getElementById("ctl00_ContentPlaceHolder_chkPhone");
        var chkMail = document.getElementById("ctl00_ContentPlaceHolder_chkMail");
        var chkContact = document.getElementById("ctl00_ContentPlaceHolder_chkContact");
        var rdHTML = document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormat_0");
        var rdText = document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormat_1");
    
        if(chkContact.checked == true)
        {
            chkEmail.checked = false;
            chkPhone.checked = false;
            chkMail.checked = false;
            rdHTML.checked = false;
            rdText.checked = false;
        }               
    }
    function ContactMe()
    {
        var chkEmail = document.getElementById("ctl00_ContentPlaceHolder_chkEmail");
        var chkPhone = document.getElementById("ctl00_ContentPlaceHolder_chkPhone");
        var chkMail = document.getElementById("ctl00_ContentPlaceHolder_chkMail");
        var chkContact = document.getElementById("ctl00_ContentPlaceHolder_chkContact");
        var rdHTML = document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormat_0");
        var rdText = document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormat_1");

        if(chkEmail.checked == true || chkPhone.checked == true || chkMail.checked == true)
        {
            chkContact.checked = false;
        }   
        
        if (chkEmail.checked == true && rdText.checked == false)
        {
            rdHTML.checked = true;           
        }
        if (chkEmail.checked == false)
        {
            rdHTML.checked = false;
            rdText.checked = false;            
        }
    }
    function CheckEmail()
    {
        document.getElementById("ctl00_ContentPlaceHolder_chkEmail").checked = true;
        document.getElementById("ctl00_ContentPlaceHolder_chkContact").checked = false;
    }
    function ValidateEmailFormat()
    {
        
        if (document.getElementById("ctl00_ContentPlaceHolder_EmailNew_0").checked == true)
        {
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_0").checked = true;
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_0").disabled = false;
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_1").disabled = false;
        }
        if (document.getElementById("ctl00_ContentPlaceHolder_rblEmailNew_1").checked == true)
        {
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_0").disabled = true;
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_0").checked = false;            
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_1").disabled = true;
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_1").checked = false;
        }        
    }
    
    function ValidateEmail()
    {
        if (document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_0").checked == true ||
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailFormatNew_1").checked == true )
        {            
            document.getElementById("ctl00_ContentPlaceHolder_rblEmailNew_0").checked = true;            
        }
    }


function ValidateMultiLoc(tRadioID, tRFVID1) 
        {                           
            //tRFVID.enabled = tRadioID.checked;                                     
            tRFVID1.enabled = tRadioID.checked;
        }
        
 function ShowTab(iTab)
    {
	    var oFrm = document.forms['frmTab'];
    	
	    if(iTab==1)
	    {
		    oFrm.action = "Terms.aspx?hdnTerms=1"; 
	    }
	    else
	    {
	        oFrm.action = "Terms.aspx?hdnTerms=2";
	    }

	    oFrm.submit();
    }
    
    function Printform()
    {
        window.print();
        return false;
    }
    
    function ValidateLargeTradeFields(sender, args)
    {
        var sValue = args.Value;
        if ( sValue == "0" )
        {
            args.IsValid = false;
            document.location = '#TimeOfTrade';
            return;
        }        
        args.IsValid = true;
    }
    
    function ValidateMaxQty(sender, args)
    {
        var sValue = args.Value;                  
        var iMax = parseInt(document.getElementById("ctl00_ContentPlaceHolder_hdMaxQty").value);
        if (isNaN(sValue) || sValue <= 0 || (sValue.indexOf('.') != -1))
        {
            args.IsValid = true;
            return;
        }
        else if (sValue > 1 && sValue <= iMax)
        {
            document.getElementById("ctl00_ContentPlaceHolder_txtQuantity").value = 1;
            args.IsValid = false;
            return;            
        }
        args.IsValid = true;
    }
    //Update Total Purchase Ports based on quantity changes
    function UpdatePurchasePorts(txtPromoQty, hdnPurchasePorts, txtTotalPurchasePorts)
    {
        if (hdnPurchasePorts.value != '')
        {
            txtTotalPurchasePorts.value = txtPromoQty.value * hdnPurchasePorts.value;
        }
    }
    
    
    function ValidatePassword(sender, args)
    {
	    var sInput = args.Value;	    
	    if(sInput.length >= 3 && sInput.length <=14)
	    {
		    args.IsValid = true;
            return;
	    }
	    else
		    args.IsValid = false;
            return;
    }

    function ValidateSalesRepEmail(sender, args)
    {
        var sEmail = args.Value;
        if((sEmail.indexOf("hp.com") != -1 || sEmail.indexOf("marketvelocity.com") != -1) && sEmail.indexOf("@") != -1)
        {
            args.IsValid = true;
            return;
        }
        args.IsValid = false;
    }
    
    function ValidateSalesRepLogOnName(sender, args)
    {
        var sLogin = (args.Value);        
        if((sLogin.substring(0,1) == "0" || sLogin.substring(0,1) == "1" || 
            sLogin.substring(0,1) == "2" || sLogin.substring(0,1) == "N"
            || sLogin.substring(0,1) == "n"
            )
            && (sLogin.length == 8)
          )
        {
            if(!isNaN(sLogin.substring(1,8)))
            {
                args.IsValid = true;
                return;
            }
        }
        args.IsValid = false;
        
    }
    
     // CRR_20060921 Start: Added validations per HP XP EVA Promotion requirements
    function ValidateWordCharacter(sender, args)
    {
	    //validate [a-zA-Z0-9]
	    var sInput = args.Value;
	    var result = sInput.match(/[a-zA-Z0-9]/);		//check to see if the field is blank
	    if(result != null)
	    {
		    args.IsValid = true;
            return;
	    }
	    else
		    args.IsValid = false;
            return;
		    
    }

    function ValidatePhoneNumber(sender, args)
    {
	    //validate [a-zA-Z0-9]
        var sInput = args.Value;
	    var result = sInput.match(/[a-zA-Z0-9]/g);		//check to see if the field is blank
	    if((result != null) && (result.length) > 9)		//must be ten digits or characters
	    {
		    args.IsValid = true;
            return;
	    }
	    else
		    args.IsValid = false;
            return;
    }
    // 
    
    function ResetErrorMsg()
    {
        if(document.aspnetForm.ctl00_ContentPlaceHolder_drpCustCategory.options[document.aspnetForm.ctl00_ContentPlaceHolder_drpCustCategory.selectedIndex].value != "0")
        {
           document.getElementById("ctl00_ContentPlaceHolder_spCatErrorMessage").innerHTML = "";
        }
        if(document.aspnetForm.ctl00_ContentPlaceHolder_drpTimeOfTrade.options[document.aspnetForm.ctl00_ContentPlaceHolder_drpTimeOfTrade.selectedIndex].value != "0")
        {
           document.getElementById("ctl00_ContentPlaceHolder_spTimeErrorMessage").innerHTML = "";           
        }   
        if(document.getElementById("ctl00_ContentPlaceHolder_txtMultipleLoc").value != '')      
        {
            document.getElementById("ctl00_ContentPlaceHolder_spLocErrorMsg").innerHTML = ""; 
        }
        else
        {
            document.getElementById("ctl00_ContentPlaceHolder_spLocInvalidErrorMsg").innerHTML = "";                 
        }
    }
    function ResetErrorMsgFromButton()
    {
           if(document.getElementById("ctl00_ContentPlaceHolder_spCatErrorMessage")!=null)
	   {
	   document.getElementById("ctl00_ContentPlaceHolder_spCatErrorMessage").innerHTML = ""; 
           }   
            if(document.getElementById("ctl00_ContentPlaceHolder_spTimeErrorMessage")!=null)
           {
           document.getElementById("ctl00_ContentPlaceHolder_spTimeErrorMessage").innerHTML = ""; 
           }
	  if(document.getElementById("ctl00_ContentPlaceHolder_spLocErrorMsg")!=null)
	   {
           document.getElementById("ctl00_ContentPlaceHolder_spLocErrorMsg").innerHTML = "";            
	   }
           if(document.getElementById("ctl00_ContentPlaceHolder_spFileMsg") != null) 
           {
             document.getElementById("ctl00_ContentPlaceHolder_spFileMsg").innerHTML = "";                 
           }
           //   AAS_1698_20080320 Start: Hide validation error messeges in option1 and option2 sections when option 3 submit button is clicked
           if(document.getElementById("ctl00_ContentPlaceHolder_spFileMsgSection1") != null) 
           {
             document.getElementById("ctl00_ContentPlaceHolder_spFileMsgSection1").innerHTML = "";                 
           }
           if(document.getElementById("ctl00_ContentPlaceHolder_spFileMsgSection2") != null) 
           {
             document.getElementById("ctl00_ContentPlaceHolder_spFileMsgSection2").innerHTML = "";                 
           }
           //   AAS_1698_20080320 End: Hide validation error messeges in option1 and option2 sections when option 3 submit button is clicked
    }
    
    // This function is specifically for HP Update and Save Promotion            
    function ValidateQtyForHPMakeUpgrade_ClientValidate(source, args)     
    {           
        var hdMaxQty = document.getElementById("ctl00_ContentPlaceHolder_hdMaxQty");                     
        var sValue = args.Value; 
        
        if (sValue > parseInt(hdMaxQty.value))
        {               
            alert('This promotion is limited to ' +  hdMaxQty.value + ' items.');            
            args.IsValid = false;            
        }
        else
        {
            args.IsValid = true;
        }        
    }
        
    function ValidateModelDescription(sender, args)
    {
        var sInput = args.Value;
        var strValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.#-() ";
        var strChar;
        var blnResult = true;
        
        if (sInput.length == 0) blnResult = false;

        //  test strString consists of valid characters listed above
        for (i = 0; i < sInput.length && blnResult == true; i++)
        {
            strChar = sInput.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
                {
                    blnResult = false;
                }
         }
        args.IsValid = blnResult;
        return;
    }
        
      
    function SaveBasket()
    {
        var aName = "";
        aName = prompt('Please choose a name for this quote list:', aName);
       
        if(aName == null)
        {
            return false;
        }
        else if(aName.replace(/^\s+|\s+$/g,"") == "")
        {
            alert("Please enter name for this quote.");
            SaveBasket();
            return false;
        }
        
        if(IsAlphaNumeric(aName.replace(/\s/g, "")))
        {
          document.getElementById("ctl00_ContentPlaceHolder_hdnSaveQuote").value = aName.replace(/^\s+|\s+$/g,"");
          //document.forms['aspnetForm'].submit();
       
        }
        else        
        {
             alert("Please enter valid quote name. Quote name should have only alpha numeric characters.");
             SaveBasket();             
        }        
    }
    function OpenSaveQuote()
    {
        var bSave = confirm('To save the content of current quote list press the Cancel button, \n' +
		        'and then save the quote list. Else, Press the OK button to load a saved quote list.')
        if(bSave)		//display the template list
        {
	        var rtn = window.showModalDialog('/LoadBasket.aspx','_blank','dialogWidth:400px;dialogHeight:125px;menubar:no;scrollbars:no;resizable:no;location:no;status:no;help:no');
	        if (rtn)
	        {	            
	            var rtnArray = rtn.split(';');	           	            		            
		         if (rtnArray[0])
		        {
		            document.getElementById("ctl00_ContentPlaceHolder_hdnSavedCartID").value = rtnArray[0];	
		            document.getElementById("ctl00_ContentPlaceHolder_hdnReturnQuoteName").value = rtnArray[1];
		            __doPostBack('ctl00_ContentPlaceHolder_btnOpen','');			        
			        //document.forms['aspnetForm'].submit();
			        //WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00_ContentPlaceHolder_btnOpen", "", true, "openQuote", "", false, false));
		        }
	        }
        }
    }
    
    //MVN_1551,1552 20070830 Start: Added media bonus validation    
    
    function ValidateMediaBonus(sender, args)
    {
        
        var sValue = args.Value;
        var rdText = document.getElementById("ctl00_ContentPlaceHolder_txtQuantity");    
        if(parseInt(sValue) > 0 && parseFloat(rdText.value) > 1)   
        {
            args.IsValid = false;
            return;
        }
        args.IsValid = true;
    }
    //MVN_1551,1552 20070830 End: Added media bonus validation
    //  AAS_1683_20080219 Start: Added date validation    
    function isDateValid(fld)
    {
        var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;    
        if (fld.match(RegExPattern))
        {
            return true; 
        } 
        else 
        {
            return false;
        } 

    }
    function ValidatePurchaseDate(sender, args)
    {
        var sValue = args.Value;
        if (isDateValid(sValue))
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }     
    }
//  AAS_1683_20080219 End: Added date validation

//  AAS_1683_20080219 Start: Added purchase amount numeric validation
    function ValidateMoney(sender,args)
    {
        var sValue = args.Value;
        var RegExPattern = /^\d+$/;
       
        if (sValue.match(RegExPattern ))
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
    }
//  AAS_1683_20080219 End: Added purchase amount numeric validation

//  VP_1831_20080715 Start: Function to open new window and disabling postabck on original control
    function OpenWindowForMenu(url,obj)
    {       
       window.open(url);
       obj.onload('return false'); 
    }
//  VP_1831_20080715 End
   
  //  VP_1772_20080908 Start:check the count of email addressess
  function ValidateEmailCount(sender,args)
  {
      var sValue = args.Value; 
      var count= sValue.length - sValue.replace(/@/g,"").length
      
      if (count <= 100)
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
            }
  }  
  
  //US 1900_20080926 HP Quote Tool Page- Continue Button Issue
//Please do not delete this function beacause it gets access from hp page content.
function HPGotoTerms()
{
    var oContinue = window.document.getElementById("ctl00_ContentPlaceHolder_btnContinue");
    if (oContinue != null)
    { 
        window.location = "../../Terms.aspx"; 
    }
    else
    {
        var oError = window.document.getElementById("ctl00_ContentPlaceHolder_spHPDesignJetSnH");
        if (oError != null)
        {
        	var tMsg = oError.innerHTML;
        	tMsg = tMsg.replace("<BR>","");
        	tMsg = tMsg.replace("<br>","");
        	alert (tMsg);
        }
        else
        {
        	alert ("You can not complete quote action due to error.");
        }
    }
 }
 
 

    
function CheckLogin()
{     
      if(sLogin =='0')
      {
         var bConfirm = ConfirmMsg();
         if(bConfirm)
         {
         window.location.href="SalesRepLogin.aspx";
         }                
      }
      else
      {
      OpenSaveQuote();
      }
}

function ConfirmMsg()
{
    var bSave = confirm("Please Login to save/open quote");            
    return bSave;
}           

    //Custome validator to validate zip code based on the coutry selection i.e. US/Canada
    function ValidateCountryZip(sender, args)
    {
        var objCountry = document.getElementById('ctl00_ContentPlaceHolder_drpCountry');
        var sZipCode = document.getElementById('ctl00_ContentPlaceHolder_txtZip');
        var sSpanZipMessage = document.getElementById('spnValidator');
        
        if(sZipCode.value!="")
        {
            if (objCountry.value == '1')    //If selected country is US.
            {
                var RegExPattern = /^\d{5}(-\d{4})?$/;
                if (!sZipCode.value.match(RegExPattern))
                {
                    sSpanZipMessage.style.cssText = "display: block"; //throw validation
                    args.IsValid = false;
                    return;
                } 
            }
            else if (objCountry.value == '2')   //If selected country is Canada.
            {
                var RegExPattern = /^[A-Za-z]\d[A-Za-z]\s?\d[A-Za-z]\d$/;
                if (!sZipCode.value.match(RegExPattern))
                {
                    sSpanZipMessage.style.cssText = "display: block"; //throw validation
                    args.IsValid = false;
                    return;
                } 
            }
        }
        sSpanZipMessage.style.cssText = "display: none";
        args.IsValid = true;
    }
    

