<!--
// ----------------------------------------------
// Functions related to email 
// ----------------------------------------------
function cm_register(email, postcode, newsletter) {
    //var nlSub = 'N';
    //if (newsletter)
    //    nlSub = 'Y';
    //cmCreateRegistrationTag(email, email, null, null, postcode, newsletter, nlSub , 'Y');
}

function ValidateSeriesEnroll(frm) {
    if (!CheckRequired(frm.txtEmail, "Email Address"))
        return false;
    if (!CheckEmail(frm.txtEmail))
        return false;
    if (!CheckRequired(frm.txtEmailReenter, "Confirmation Email Address"))
        return false;
    if (!CheckEmail(frm.txtEmailReenter))
        return false;
    if (frm.txtEmail.value != frm.txtEmailReenter.value) {
        alert("Your confirmation e-mail address does not match with the original.");
        return false;
    }
    if (frm.optAge.checked == false) {
        alert("You must be age 13 or older to enter the sweepstakes.");
        return false;
    }
    if (frm.optIn.checked == true) {
        if (!CheckRequired(frm.txtFirstName, "First Name"))
            return false;
        if ( !ValidateString(frm.txtFirstName.value,rexFilter) ){
            alert("Please check the First Name (only letters, numbers and spaces are allowed).");
            return false;
        }
        if (!CheckRequired(frm.txtZip,"Zip code"))
            return false;
        if ( !ValidateString(frm.txtZip.value, rexZip + "|" + rexCAPostalCode) ) {
            alert("Please check the format of the zip code");
            return false;
        }
        if (frm.checkAdult.checked == false && frm.checkTeen.checked == false) {
            alert("Please check the version of the T.J.Maxx emails you would like to receive.");
            return false;
        }
    }
    return true;  
}
function ShowEmailSignUpFields(frm) {
    var signupFields = "";
    var signupCopy = "<label>first name</label><span style='font-size:16px'>&#8226;</span><br />";
    signupCopy = signupCopy + "<input name=txtFirstName type=text size=20 maxlength=50 style='border:1px solid #999;' ><br />";
    signupCopy = signupCopy + "<label>zip code</label><span style='font-size:16px;'>&#8226;</span><br />";
    signupCopy = signupCopy + "<input name=txtZip type=text size=20 maxlength=5  style='border:1px solid #999;' ><br />";
    signupCopy = signupCopy + "<input name=checkAdult type=checkbox value=A />adult version<span style='font-size:16px;'>&#8226;</span>";
    signupCopy = signupCopy + "<input name=checkTeen type=checkbox value=T />teen version<span style='font-size:16px;'>&#8226;</span>";
    signupFields = document.getElementById('signup');
    signupFields.innerHTML = signupCopy;
}

function validateSendFriend(frm) {
    if (!CheckRequired(frm.sender_name, "Sender's Name"))
        return false;
    if (!CheckRequired(frm.sender_email, "Sender's Email Address"))
        return false;
    if (!CheckEmail(frm.sender_email))
        return false;    
    if (!CheckRequired(frm.friend_name, "Friend's Name"))
        return false;
    if (!CheckRequired(frm.friend_email, "Friend's Email Address"))
        return false;
    if (!CheckEmail(frm.friend_email))        
        return false;
    return true;
}

function ValidateAdultEmail(frm) {
    if (!CheckRequired(frm.txtEmail, "Email Address"))
        return false;
    if (!CheckEmail(frm.txtEmail))
        return false;
    if (!CheckRequired(frm.txtEmailReenter, "Confirmation Email Address"))
        return false;
    if (!CheckEmail(frm.txtEmailReenter))
        return false;
    if (frm.txtEmail.value != frm.txtEmailReenter.value) {
        alert("Your confirmation e-mail address does not match with the original.");
        return false;
    }
    if (!CheckRequired(frm.txtFirstName, "First Name"))
        return false;
    if ( !ValidateString(frm.txtFirstName.value,rexFilter) ){
        alert("Please check the First Name (only letters, numbers and spaces are allowed).");
        return false;
    }
        
    if ( !ValidateString(frm.txtLastName.value,rexFilter) ){
        alert("Please check the Last Name (only letters, numbers and spaces are allowed).");
        return false;
    }
            
    if ( !ValidateString(frm.txtAddress.value,rexFilter) ){
        alert("Please check the Address (only letters, numbers and spaces are allowed).");
        return false;
    }
    
    if ( !ValidateString(frm.txtCity.value,rexFilter) ){
        alert("Please check the City (only letters, numbers and spaces are allowed).");
        return false;
    }
    
    if (!CheckRequired(frm.txtZip,"Zip code"))
        return false;
    if ( !ValidateString(frm.txtZip.value, rexZip + "|" + rexCAPostalCode) ) {
        alert("Please check the format of the zip code");
        return false;
    }
    if ( !ValidatePhoneNumber(frm.txtAreaCode.value,frm.txtPrefix.value,frm.txtExtension.value) ) {
        alert("Please check the Phone Number (only numbers are allowed ).");
        frm.txtAreaCode.focus();
        return false;
    }
    if (frm.optAge[0].checked == false  &&  frm.optAge[1].checked == false){
        alert("Are you age 13 or older? Please select Yes or No.");
        return false;
    }
    if (frm.chkTeen.checked == false  &&  frm.chkAdult.checked == false){
        alert("Which email would you like to receive? Please select 'Adult Email' or 'Teen Email'.");
        return false;
    }
    
    return true;
}

function validateUnsubForm(frm) {
    if (!CheckRequired(frm.txtEmail, "Email Address"))
        return false;
    if (!CheckEmail(frm.txtEmail))
        return false;
    return true;
}

function ValidateBusinessContact(f) {
    if (!CheckRequired(f.txtName, "Your Name"))
        return false;
    if ( !ValidateString(f.txtName.value,rexFilter) ){
        alert("Please check the Name (only letters, numbers and spaces are allowed).");
        return false;
    }
    if (!CheckRequired(f.txtPosition, "Your Position"))
        return false;
    if ( !ValidateString(f.txtPosition.value,rexFilter) ){
        alert("Please check the Position (only letters, numbers and spaces are allowed).");
        return false;
    }
    if (!CheckRequired(f.txtCompany, "Your Company Name"))
        return false;
    if ( !ValidateString(f.txtCompany.value,rexFilter) ){
        alert("Please check the Company Name (only letters, numbers and spaces are allowed).");
        return false;
    }
        
    if (!CheckRequired(f.txtPhone, "Your Business Phone"))
        return false;
    if ( !ValidateString(f.txtPhone.value,rexFormattedPhone ) ){
        alert("Please check the Business Phone (format is nnn-nnn-nnnn).");
        return false;
    }
    if ( f.TxtFax ) {
        if ( f.txtFax.value != "" ) {
            if ( !ValidateString(f.txtFax.value,rexFormattedPhone ) ){
                alert("Please check the Business Fax (format is nnn-nnn-nnnn).");
                return false;
            }
        }
    }
    if ( !CheckRequired(f.txtMessage, "Message") )
        return false;
    if ( !ValidateString(f.txtMessage.value,rexFilter) ){
        alert("Please check the Message (only letters, numbers, spaces and simple punctuation are allowed).");
        return false;
    }

    if (!CheckRequired(f.txtEmail, "Your Email Address"))
        return false;
    if (!CheckEmail(f.txtEmail))
        return false;
    
    if ( f.txtAddress ) {    
        if ( f.txtAddress.value != "" ) {
            if ( !ValidateString(f.txtAddress.value,rexFilter) ){
                alert("Please check the Address (only letters, numbers, spaces and simple punctuation are allowed).");
                return false;
            }
        }
    }
    return true;
}
// ----------------------------------------------
// Functions related to store locator
// ----------------------------------------------
function validateZip(frmZip){
    var txtBox = frmZip.postcode.value;
    if ( txtBox == "" || txtBox == "zip code") {
        frmZip.action='locator.asp';
        return true;
    }
    else {
        if (isNaN(txtBox)) {    
            frmZip.state.value = txtBox ;
            frmZip.action='search_results_state.aspx';    
            return true;
        }
        else {
            return true;
        }
    }
}
function validateForm(frmLocator){
    var message = "";
    if (frmLocator.postcode.value != "") {
        var postcode = frmLocator.postcode.value ;
        var zipPattern = new RegExp(rexZip + "|" + rexCAPostalCode);
        if (zipPattern.test(frmLocator.postcode.value)) {
            frmLocator.state.value = "";
            frmLocator.city.value = "";
            if (postcode.length == 6) {
                frmLocator.postcode.value = postcode.substr(0,3) + " " + postcode.substr(3,3);
            }
            return true;
        }
        else {
            message = "Please check the format of the zip code";
            alert(message);
            return false;
        }
    }
    else {
        var city = frmLocator.city.value;
        var state = frmLocator.state.value;
        if (state == "Choose" || state == "Other") {
            state = "";
        }
        if ( state != "" ) {
            if ( city == "" ) {
                frmLocator.action = "search_results_state.aspx";
            }
            frmLocator.postcode.value = "";
            return true;
        }
        else {
            message = "Please enter a zip code, a state, or a city and state";
            alert(message);
            return false;
        }
    }
}
// directions.aspx
function validatePage(addressForm) {
    if ( ! CheckRequired(addressForm.TextAddress, "Address") ) {
        return false;
    }
    if ( ! CheckPOBox(addressForm.TextAddress, true) ) {
        return false;
    }
        
    if (addressForm.TextPostcode.value == "") {
        if ( addressForm.TextCity.value == "" ) {
            alert("Either Zip, or City and State are required");
            return false;
        }
    }
    return true;
}
function createPrintable() {
    var newWindow;
    var content;
    var element;
    newWindow = window.open("","printable","scrollbars,menubar,resizable,width=600");
    content = "<html><head><!-- PageID 175 - published by RedDot 7.5 - 7.5.1.91 - 17701 --><title>Printable Directions</title>";
    content += "<link href='style.css' type='text/css' rel='stylesheet'>";
    content += "<body><table cellpadding=1 cellspacing=0 width=500>";
    if ( document.all ) {
        element = document.all.directions;
    }
    else {
        element = document.getElementById("directions");
    }
    var elHtml = new String (element.innerHTML);
    content += elHtml.replace(/absolute/i,"static") + "<br><br>";
    content += "</table></body></html>";
    newWindow.document.write(content);
    newWindow.document.close();
    newWindow.focus();
}

// ----------------------------------------------
// tracking for dept page(s)
// ----------------------------------------------
function updOmniDeptTracking(section) {
    s.pageName="TJM_"+section+".asp";
    var s_code=s.t();if(s_code)document.write(s_code);
    
}

// ----------------------------------------------
// miscellaneous
// ----------------------------------------------
function doHide(elementId) {
    document.getElementById(elementId).style.display = 'none';
}
function doShow(elementId) {
    document.getElementById(elementId).style.display = 'block';
}
function toggle( targetId ) { 
  if (document.getElementById){ 
        target = document.getElementById( targetId ); 
           if (target.style.display == "none"){ 
              target.style.display = ""; 
           } else { 
              target.style.display = "none"; 
           } 
     } 
} 
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
   var obj = document.layers ? document.layers[szDivID] :
   document.getElementById ?  document.getElementById(szDivID).style :
   document.all[szDivID].style;
   obj.visibility = document.layers ? (iState ? "show" : "hide") :
   (iState ? "visible" : "hidden");
}
//-->