﻿function SetTextOnFocus(theTextBox){
    if (theTextBox.value == 'Zip Code:' || theTextBox.value == 'Postal Code:') {
        theTextBox.value = '';
    }
}

function SetTextOnBlur(theTextBox){        
    if(theTextBox.value == ''){
        theTextBox.value = 'Zip Code:';
    }
}

function SetTextOnBlurWithCountry(theTextBox,usa) {
    if (theTextBox.value == '') {
        if (usa.checked == true)
         {
            theTextBox.value = 'Zip Code:';
         }
        else 
        {
            theTextBox.value = 'Postal Code:';
        }
    }
}

function EnterClick(buttonName,e) {
    var key;
    
    if(window.event)
        key = window.event.keyCode; //IE
    else
        key = e.which; //firefox

    if (key == 13) {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null) {
            btn.click();
            if(window.event)
            window.event.keyCode = 0;
        }
    }
}

function ValidateZipCode(rdId, RegExpId) {
    if (rdId.checked == true) {
        RegExpId.innerHTML = 'Invalid Zip Code';
        }
        else {
           
        RegExpId.innerHTML = 'Invalid Postal Code';
        
    }
}

function ZipCodeRegExpValidatorEnable(rdId, usaRegExp, canadaRegExp) 
{
    if (rdId.checked == true) {

        ValidatorEnable(usaRegExp, true);
        ValidatorEnable(canadaRegExp, false);
    }
    else
    {
        ValidatorEnable(usaRegExp, false);
        ValidatorEnable(canadaRegExp, true);
    }
}

function EnterClickValidate(buttonName, rdId, usaRegExp, canadaRegExp, e) {
    var key;

    if (window.event)
        key = window.event.keyCode; //IE
    else
        key = e.which; //firefox

    if (key == 13) {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null) {
            

            //-------------------------------------------
            if (document.getElementById(rdId).checked) {
                //alert('usa');
                ValidatorEnable(usaRegExp, true);
                ValidatorEnable(canadaRegExp, false);
                btn.click();
                if (window.event)
                    window.event.keyCode = 0;
            }
            else if (document.getElementById(rdId).checked==false)
            {
                //alert('canada');
                ValidatorEnable(usaRegExp, false);
                ValidatorEnable(canadaRegExp, true);
                btn.click();
                if (window.event)
                    window.event.keyCode = 0;
            }
            //--------------------

            

        }

    }



}
