// Created 1/27/08 Monoson;   Last Updated 11/10/08 Hoffman

var NJWhichForm;
var NJStatus;
var NJEmail;

function NJCheckEmail(NJACRO, NJYorN) {   //  validate email address & pass true/ false to UpdateSubscription function

    NJWhichForm = NJACRO.toUpperCase();     // update global variable
    NJStatus = NJYorN;  //  Y=Subscribe N=Unsubscribe    // update global variable

    var NJWhichEmail = (NJWhichForm + 'email');
    var NJWhichEmail2 = (NJWhichForm + 'email2');

    NJEmail = document.getElementById(NJWhichEmail);    // update global variable
    var NJEmail2 = document.getElementById(NJWhichEmail2);  


    if ((NJEmail.value.indexOf("@") != "-1") && (NJEmail.value.indexOf(".") != "-1"))  {

        if (NJEmail.value != NJEmail2.value) {  // did the two emails entered match?
            window.alert("The email addresses did not match.  Please enter and confirm your address. ");   // fat fingers
            return false; 
        } 
        
        else { 
            return true; 
        } 
    } 

else { 
        window.alert("Please enter a valid email address."); 
        return false; 
    } 
} 


function NJUpdateSubscription() {     

    var NJID = '';
    var NJCAT = '';
    var NJURL = '';

    switch (NJWhichForm)	{ //  Assign ID & Category parameters EXACTLY as they are in the Preferences Form "Link Tree" page

    //case "BVA":
        //NJID = "10000188";						
       // NJCAT = "BusinessValuation%20Alert";
      //  break;	
				
    case "CBT":
        NJID = "10000189";						
        NJCAT = "CorporateBusiness%20Taxation Monthly";
        break;	

    case "CPM":
        NJID = "10000190";						
        NJCAT = "CPAPractice%20Management%20Forum";
        break;	

    case "FTW":
        NJID = "10000191";						
        NJCAT = "FederalTax%20Weekly";
        break;	

    case "ITJ":
        NJID = "10000192";						
        NJCAT = "InternationalTax%20Journal";
        break;	

    case "JPTE":
        NJID = "10000193";						
        NJCAT = "Journalof%20Passthrough%20Entities";
        break;	

    case "JPEP":
        NJID = "10000194";						
        NJCAT = "Journalof%20Practical%20Estate%20Planning";
        break;	

    case "JORP":
        NJID = "10000195";						
        NJCAT = "Journalof%20Retirement%20Planning";
        break;	

    case "JOST":
        NJID = "10000196";						
        NJCAT = "Journalof%20State%20Taxation";
        break;	

    case "JTPP":
        NJID = "10000197";						
        NJCAT = "Journalof%20Tax%20Practice%20and%20Procedure";
        break;	

    case "JTFP":
        NJID = "10000198";						
        NJCAT = "Journalof%20Taxation%20of%20Financial%20Products";
        break;	

    case "PTA":
        NJID = "10000199";						
        NJCAT = "PropertyTax%20Alert";
        break;	

    case "PAR":
        NJID = "10000200";						
        NJCAT = "PublicAccounting%20Report";
        break;	

    case "SUTA":
        NJID = "10000201";						
        //NJCAT = "Sales&%20Use%20Tax%20Alert";
        break;	

    case "SITA":
        NJID = "10000202";						
        NJCAT = "StateIncome%20Tax%20Alert";
        break;	

    case "STR":
        NJID = "10000203";						
        NJCAT = "StateTax%20Review®";
        break;	

    case "TSA":	
        NJID = "10000204";						
        NJCAT = "TaxShelter%20Alert";
        break;	

    case "TAXES":
        NJID = "10000205";						
        NJCAT = "TAXES-%20The%20Tax%20Magazine®";
        break;

    case "MATR":
        NJID = "10000241";						
        //NJCAT = "M&&ATax%20Report";
        break;	

  	
					
    default: 
        NJID = "";						
        NJCAT = "";						
    }						

    NJURL = 'https://support.cch.com/emailpreferences/public/email_preferences.asp?email=' + NJEmail.value + '&news_level=10&newsletter_id=' + NJID +   '&cfu_id=10000000&category_description=' + NJCAT + '&opt_in=' + NJStatus;

    this.location.href = NJURL;
}
// finis; time for another Starbucks...