
  
  
// VVVVVVVVVVVVVVVVVVV ExactTarget Code VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
// validates email
function validEmail(addemailvalue) {
    invalidChars = " /:,;"
    if (addemailvalue == "") {
        return false
    }
    for (i=0; i<invalidChars.length; i++) {
        badChar = invalidChars.charAt(i)
        if (addemailvalue.indexOf(badChar,0) != -1) {
            return false
        }
    }
    atPos = addemailvalue.indexOf("@",1)
    if (atPos == -1) {
        return false
    }
    if (addemailvalue.indexOf("@",atPos+1) != -1) {
        return false
    }
    periodPos = addemailvalue.indexOf(".",atPos)
    if (periodPos == -1) {
        return false
    }
    if (periodPos+3 > addemailvalue.length) {
        return false
    }
    return true
}
//check if year is in range.
function inRange(inputStr, lo, hi) {
    //var num = parseInt(inputStr, 10)
    if (inputStr < lo || inputStr > hi) {
        return false
    }
    return true
}

//check if year is valid
//function validateYear(field) {
//  today = new Date();
//    if (!inRange(field,1900,today.getFullYear()-13)) {
//      return false
//     }
//alert('this is true');
// return true
//}

function validateMonth(field, Month) {
    Mydate = new Date();
    theMonth = Mydate.getMonth();
	  //alert (Month + ':' + field + ':' +theMonth + ':' + (Mydate.getFullYear()-12)+ ':' + (Mydate.getFullYear()-13));
    //if (!inRange(field,1900,Mydate.getFullYear()-12)) {
    if ( field >= (Mydate.getFullYear()-12)) {
        return false;
    }
    else{//alert("I'm here")
        if (field == (Mydate.getFullYear()-13) && theMonth < Month){
            return false;
        }
    }
    return true
}
//<% For i = 0 to numBirthYears
//Response.Write("<option value='"&Year(Date())-i&"'>"&Year(Date())-i&"</option>")
//next %>
function checkForm() {
    var ok =true;
    setCheckboxValues();
    addr = document.getElementById('addressLong');
    cty = document.getElementById('cityLong');
    if (document.subscribeForm['Email Address'].value.toLowerCase() != document.subscribeForm['Email Address Confirm'].value.toLowerCase()) {
        alert("Your email addresses don't match, please reenter you email address.");
        document.subscribeForm['Email Address'].focus();
        ok = false;
    }
    else if (!validEmail(document.subscribeForm['Email Address'].value)) {
        alert('Please enter a valid Email Address.');
        document.subscribeForm['Email Address'].focus();
        ok = false;
    }
    else if (document.subscribeForm['First Name'].value.length <= 0) {
        alert('Please enter a valid First Name.');
        document.subscribeForm['First Name'].focus();
        ok = false;
    }
    else if (document.subscribeForm['lastName'].value.length <= 0) {
        alert('Please enter a valid Last Name.');
        document.subscribeForm['lastName'].focus();
        ok = false;
    }
    else if (document.subscribeForm['State Or Province'].value.length <= 0) {
        alert('Please enter a valid State/Province.');
        document.subscribeForm['State Or Province'].focus();
        ok = false;

    }else if (document.subscribeForm['Zip Code'].value.length <= 0) {
        alert('Please enter a valid Zip Code.');
        document.subscribeForm['Zip Code'].focus();
        ok = false;
    }  else if (addr != null){
        if (document.subscribeForm['addressLong'].value.length <= 0) {
            alert('Please enter a valid Address.');
            document.subscribeForm['addressLong'].focus();
            ok = false;
        }
    }

    if (cty != null){
        if (document.subscribeForm['cityLong'].value.length <= 0) {
            alert('Please enter a valid City.');
            document.subscribeForm['cityLong'].focus();
            ok = false;
        }
    }

    //if (!validateYear(document.subscribeForm.Birthday__Year.value)) {
    //alert('! Sorry, you must be at least 13 years old to use this service. Please ask a parent to sign-up to receive information from our site. \n' + 'The reason for this is because the U.S. Children’s Online Privacy Protection Act requires prior Verifiable Parental Consent before collection of personal information from children. ');
    //document.subscribeForm.Birthday__Year.focus();
    //return false;
    //}
    //alert(document.subscribeForm.Birthday__Year[document.subscribeForm.Birthday__Year.selectedIndex].value + ":" + document.subscribeForm.Birthday__Month[document.subscribeForm.Birthday__Month.selectedIndex].value);
    if(document.subscribeForm['Best of the Buzz'].checked || document.subscribeForm['Entertainment Buzz'].checked || document.subscribeForm['Food Wine Buzz'].checked || document.subscribeForm['TC Tix On Sale Today'].checked || document.subscribeForm['The Outburst'].checked || document.subscribeForm['American Express Cardmember'].checked) {
        if (!validateMonth(document.subscribeForm['Birthday Year'][document.subscribeForm['Birthday Year'].selectedIndex].value, document.subscribeForm['Birthday Month'][document.subscribeForm['Birthday Month'].selectedIndex].value ) || document.subscribeForm['Birthday Month'].value.length <= 0 || document.subscribeForm['Birthday Year'].value.length <= 0 ) {
            alert('! Sorry, you must be at least 13 years old to use this service. Please ask a parent to sign-up to receive information from our site. \n\n' + ' The U.S. Children\'s Online Privacy Protection Act requires prior Verifiable Parental Consent before collection of personal information from children. ');
            document.subscribeForm['Birthday Year'].focus();
            ok = false;
        }
    }

    return ok;
}


function setCheckboxValues(){
    var doc = document.subscribeForm;
    doc['Best of the Buzz'].value = (doc['Best of the Buzz'].checked ? "yes" : "no");
    doc['Entertainment Buzz'].value = (doc['Entertainment Buzz'].checked ? "yes" : "no");
    doc['Food Wine Buzz'].value = (doc['Food Wine Buzz'].checked ? "yes" : "no");
    doc['Shopping Buzz'].value = (doc['Shopping Buzz'].checked ? "yes" : "no");
    doc['TC Tix On Sale Today'].value = (doc['TC Tix On Sale Today'].checked ? "yes" : "no");
    doc['The Outburst'].value = (doc['The Outburst'].checked ? "yes" : "no");
    doc['American Express Cardmember'].value = (doc['American Express Cardmember'].checked ? "yes" : "no");
}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
