<insert><name>main_functions_trans</name></insert><!--POST
//131
  //---------------------------------------------------//
 //--------- Define Initial Variables ----------//
//--------------------------------------------------//

var msgVersion = user.attr("msgVersion");
var firstName       = initCap(user.attr ("firstName"), "Valued Customer");
var eMail = user.attr("eMail");
var uid             = user.attr("id").toString();
var segment         = uid.substr(uid.length - 2);
var mmid = masterinfo.getID();
var listsource;
var omniture;
var mailingProgram  = user.attr("mailingProgram");
var isMB = false;

var jobnum = "hhos_default";     //JOB NUMBER : VERIFY AS THIS VALUE IS INSERTED INTO LINKS.
var showOffers = "false";     //Set to true if this is a sale message
var isPhone = false;         //Replaces the "Clearance" button with a "Phone" button, this is for PALM messages
var phone = "1-866-433-2028";
var audience = "";       //Displays the audience that recieves
var facePage = "Hphome";     //The FacePage is the facebook page to link to.  "Hphome" is the standard.
var twitterPage = "hpdeals";     //The twitterPage is the twitter page to link to.  "hpdirect" is the standard.

//The leverage is a Shopping (HHOS) Message that goes to an HPN Newsgram Audience
//There are some difference from the regular shopping message, so set this variable to true for leverage
var leverage = false;
var commercial = false;
var clientDivision = "";

  //---------------------------------------------------//
 //------ END Define Initial Variables ------//
//--------------------------------------------------//




  //--------------------------------------------------//
 //-----------     Get Master Info     ----------//
//--------------------------------------------------//

//Assigns all Master Information


/*****************************************************/
//Possible Message Types to use
//hhos_2
//hhos_1
//MB_1
//hpn
//-----  Older Types -----//
//hhos_old
//microbiz
/*****************************************************/

var messageTemplateArray = new Array("hhos_2","hhos_1","MB_1","hpn","hhos_old","microbiz");

/*****************************************************/
//Possible Message Division Available
//HHOS - Home Shopping
//HHOSIB - Home Shopping Installed Base
//MB - MicroBiz - Microbiz Consumer
//MBCOMM - Microbiz Commercial
//MBIB - Microbiz Consumer Installed Base
//HPN - HP Newsgram
/*****************************************************/

var messageTypeArray = new Array("HHOS","HHOSIB","MB","MBCOMM","MBIB","HPN");

var sqlAttribute = "getMasterInfo";
var division;
var description;



var getMasterInfoCachedTable = CachedTableFactory.create(sqlAttribute, mmid);
while (getMasterInfoCachedTable.getNext()) {
  division = getMasterInfoCachedTable.getValue("DIVISION");
  description = getMasterInfoCachedTable.getValue("DESCRIPTION") + "";
}

/*
multitable.setID(sqlAttribute, mmid);

while (multitable.getNext(sqlAttribute)){
    division = multitable.getValue(sqlAttribute, "DIVISION");
    description = multitable.getValue(sqlAttribute, "DESCRIPTION") + "";
}

document.write("division: " + division + "<BR>");
document.write("description: " + description + "<BR>");
*/


/*****************************************************/
/*****************Start TCMP**************************/
/*****************************************************/
var isNB = false;
var isPC = false;
var isPRINTER = false;
var Batchid;
var CID;
var TransactionID;
var Purchasedate;
var ProductRegDate;
var Purchase_or_reg;
var Repeat_or_norepeat;
var Division;
var Microbiz;
var mailingProgram;
var mvp;
var accessory;
var beats;
var product_category;
var web_category;
var ckm_reg_only;
var last_subscription_date;
var datecreated;
var rfc_user_score;
var nmlp;
var supc;


var TCMPSqlAtt = "TCMPinfo";
multitable.setID3(TCMPSqlAtt, mmid, uid, uid);

while (multitable.getNext(TCMPSqlAtt)){
	Batchid                 = multitable.getValue(TCMPSqlAtt, "Batchid");
	CID                     = multitable.getValue(TCMPSqlAtt, "CID");
	TransactionID           = multitable.getValue(TCMPSqlAtt, "TransactionID");
	Purchasedate            = multitable.getValue(TCMPSqlAtt, "Purchasedate");
	ProductRegDate          = multitable.getValue(TCMPSqlAtt, "ProductRegDate");
	Purchase_or_reg         = multitable.getValue(TCMPSqlAtt, "Purchase_or_reg");
	Repeat_or_norepeat      = multitable.getValue(TCMPSqlAtt, "Repeat_or_norepeat");
	Division                = multitable.getValue(TCMPSqlAtt, "Division");
	Microbiz                = multitable.getValue(TCMPSqlAtt, "Microbiz");
	mailingProgram          = multitable.getValue(TCMPSqlAtt, "mailingProgram");
	mvp                     = multitable.getValue(TCMPSqlAtt, "mvp");
	accessory               = multitable.getValue(TCMPSqlAtt, "accessory");
	beats                   = multitable.getValue(TCMPSqlAtt, "beats");
	product_category        = multitable.getValue(TCMPSqlAtt, "product_category");
	web_category            = multitable.getValue(TCMPSqlAtt, "web_category");
	ckm_reg_only            = multitable.getValue(TCMPSqlAtt, "ckm_reg_only");
	last_subscription_date  = multitable.getValue(TCMPSqlAtt, "last_subscription_date");
	datecreated             = multitable.getValue(TCMPSqlAtt, "datecreated");
	rfc_user_score          = multitable.getValue(TCMPSqlAtt, "rfc_user_score");
	nmlp                    = multitable.getValue(TCMPSqlAtt, "nmlp");
	supc                    = multitable.getValue(TCMPSqlAtt, "supc");
}

if(product_category == "notebook pcs")
isNB = true;

if(product_category == "desktop pcs" || product_category == "options and accessories for desktop pcs")
isPC = true;

if(product_category == "Printer" || product_category == "printers")
isPRINTER = true;


if(isNB || isPC)
	templateColor = "black";

if(Microbiz == 1)
{
	isMB = true;
	if(description == "HHOS")
		description = "MB";
	else
		description = "MBIB";
}

if(mvp == 1)
mvp = true;

if(ckm_reg_only == 1)
ckm_reg_only = true;

/*****************************************************/
/*****************END TCMP****************************/
/*****************************************************/

var debug = false;

if(debug){
document.write("<font color='#FFFFFF'>");
document.write("Batchid        = " + Batchid + "<br>");
document.write("CID            = " + CID     + "<br>");
document.write("TransactionID  = " + TransactionID  + "<br>");
document.write("Purchasedate   = " + Purchasedate   + "<br>");
document.write("ProductRegDate = " + ProductRegDate + "<br>");
document.write("Purchase_or_reg    = " + Purchase_or_reg    + "<br>");
document.write("Repeat_or_norepeat = " + Repeat_or_norepeat + "<br>");
document.write("Division           = " + Division           + "<br>");
document.write("Microbiz           = " + Microbiz           + "<br>");
document.write("mailingProgram     = " + mailingProgram     + "<br>");
document.write("mvp                = " + mvp                + "<br>");
document.write("accessory          = " + accessory          + "<br>");
document.write("beats              = " + beats              + "<br>");
document.write("product_category   = " + product_category   + "<br>");
document.write("web_category       = " + web_category       + "<br>");
document.write("ckm_reg_only       = " + ckm_reg_only       + "<br>");
document.write("last_subscription_date = " + last_subscription_date + "<br>");
document.write("datecreated            = " + datecreated            + "<br>");
document.write("rfc_user_score         = " + rfc_user_score         + "<br>");
document.write("nmlp                   = " + nmlp                   + "<br>");
document.write("supc                   = " + supc                  + "<br>");
document.write("</font>");
}


//Example description:  "98790|1000|1000|1000|HHOSIB|hhos_2";

  //--------------------------------------------------------------//
 //-----  Set Message Type By Description  --------//
//-------------------------------------------------------------//

//Split By Description
//Info is added to the description field
var aoidArray = new Array();
if(description != null){

     var newMessageDivision = "HHOS";  //Default

     var descriptionArray = description.split("|");

     for(var i=0; i < descriptionArray.length; i++){
         var val = cleanData(descriptionArray[i]);
         //If Is Not A Number Else
         if(isNaN(val * 1)){
             if(contains(messageTemplateArray,val)){ //Check if this is in message Template array - If so, set it
                 messageType = val;
             } else if(contains(messageTypeArray,val)){ //Check if this is in message TYPE array - if so, assign a template
                 clientDivision = val;  //Sets Client Division
                 messageType = templateDefaults(val);
                 if(val == "HHOSIB" || val == "MBIB"){
                    leverage = "true";
                 }

                 if(val == "MBCOMM"){ //Sets Values for Commercial Version
                    commercial = "true";
	                mailingProgram = "General Store";
                    audience = "Small Business Direct";
                 }

                 if(val == "MB"){ //Sets Values for Commercial Version
	                mailingProgram = "General Store";
                 }

             } else { //Otherwise, Evaluate the given expression
                 eval(val);
             }
         }else{
             //Is Numeric, append to Array
             aoidArray.push(val * 1);
         }

     }
}



  //--------------------------------------------------------------//
 //----  END Message Type By Description  -------//
//-------------------------------------------------------------//




if(isNB)
{
	if(!isMB && !leverage)     // HHOS
	{
		aoidArray = new Array("122089", "122093", "122090", "122091");
	}
	else if(!isMB && leverage) // HHOS IB
	{
		aoidArray = new Array("122092", "1000", "1000", "1000");
	}
	if(isMB && !leverage) // MB Cons
	{
		aoidArray = new Array("122094", "1000", "1000", "1000");
	}	
	if(isMB && leverage) // MB IB
	{
		aoidArray = new Array("122095", "1000", "1000", "1000");
	}
	if(commercial == "true")
	{
		aoidArray = new Array("122095", "1000", "1000", "1000");
	}
}
else if(isPC)
{
	if(!isMB && !leverage)     // HHOS
	{
		aoidArray = new Array("122089", "122093", "122090", "122091");
	}
	else if(!isMB && leverage) // HHOS IB
	{
		aoidArray = new Array("122092", "1000", "1000", "1000");
	}
	if(isMB && !leverage) // MB Cons
	{
		aoidArray = new Array("122094", "1000", "1000", "1000");
	}	
	if(isMB && leverage) // MB IB
	{
		aoidArray = new Array("122095", "1000", "1000", "1000");
	}
	if(commercial == "true")
	{
		aoidArray = new Array("122095", "1000", "1000", "1000");
	}
}
else if(isPRINTER)
{
	if(!isMB && !leverage)     // HHOS
	{
		aoidArray = new Array("126043", "126046", "126044", "126045");
	}
	else if(!isMB && leverage) // HHOS IB
	{
		aoidArray = new Array("126047", "1000", "1000", "1000");
	}
	else if(isMB && !leverage) // MB Cons
	{
		aoidArray = new Array("126048", "1000", "1000", "1000");
	}
	else if(isMB && leverage) // MB IB
	{
		aoidArray = new Array("126049", "1000", "1000", "1000");
	}
}


  //--------------------------------------------------//
 //--------- Define Message Type ----------//
//--------------------------------------------------//

// Define what type of message this is, Can be
//hhos_2
//hhos_1
//MB_1
//hpn
var version = "";
//var messageType = "hhos_2";


  //------------------------------------------------------//
 //-------- END Define Message Type --------//
//------------------------------------------------------//
//147
POST--><insert><name>message_vars_trans</name></insert><!--POST

var jobnum = "6010";  //Job Number for this campaign, example: "5421";


/************************************************************************
Building Exceptions for different programs and Templates
************************************************************************/

//Changes phone number if APP(AKA HPA)
var phone = "1-866-433-2028";
if (mailingProgram == "APP")
    phone = "1-866-433-2029";
if (messageType == "microbiz" || messageType == "MB_1" || clientDivision == "MB" || clientDivision == "MBCOMM" || clientDivision == "MBIB"){
    phone = "1-800-608-6947";
    var isMB = true;
}

if(messageType == "hpn"){
    phone = "1-888-917-8097";
}


//Define the JumpID
//This adds the Job Number to HHOS and Microbiz URLS, and also the userMail=epp to tiered versions
var jumpID = "";
if(mailingProgram == "EPP_HP" || mailingProgram == "EPP" || mailingProgram == "APP")
    jumpID = "hhos_" + jobnum + "&userMail=epp";
 else
    jumpID = "hhos_" + jobnum;

if (messageType == "microbiz" || messageType == "MB_1" || clientDivision == "MB" || clientDivision == "MBCOMM" || clientDivision == "MBIB"){
	/* if(mailingProgram == "EPP_HP" || mailingProgram == "EPP" || mailingProgram == "APP")
	jumpID = "hhos_" + jobnum + "MB" + "&userMail=epp";
	else */
	jumpID = "hhos_"+ jobnum + "MB";

	facePage = "hpsmallbusiness";
}


var priceArray1 = new Array("799.99","729.99","729.99","669.99");
var priceArray2 = new Array("530","530","530","490");
var priceArray3 = new Array("199.99","174.99","174.99","162.49");
var priceArray4 = new Array("22.99","20.99","20.99","20.99");
var priceArray5 = new Array("90","108","108","113");



var aoid = getByProgram(aoidArray, mailingProgram);  //Returns AOID


var price1 = getByProgram(priceArray1, mailingProgram);  //Returns Price
var price2 = getByProgram(priceArray2, mailingProgram);  //Returns Price
var price3 = getByProgram(priceArray3, mailingProgram);  //Returns Price
var price4 = getByProgram(priceArray4, mailingProgram);  //Returns Price
var price5 = getByProgram(priceArray5, mailingProgram);  //Returns Price


var disclaimerArray = new Array("","Savings achieved by combining HPA savings with instant savings. ","Savings achieved by combining EPP savings with instant savings. "," Savings achieved by combining HPEPP savings with instant savings. ");
var disclaimer1 = "";
if(!isMB)
{
	disclaimer1 = getByProgram(disclaimerArray, mailingProgram);  //Returns Disclaimer Addition
}



//Setting up audience information
//This is the title for the audience, example: HP Newsgram

var product_code = "";
var audience = "";
if (mailingProgram == "EPP_HP" && !isMB){
    audience = "HP Employee Purchase Program";
	imageTag = '&nbsp;&nbsp;<img src="http://media.4at5.net/email_domains/hhos/93540/images/tags_hpepp.png" border="0" style="display: inline;" align="absmiddle">';
	product_code = "EPP_HP_CN517A%23B1H";
} else if (mailingProgram == "EPP" && !isMB){
	audience = "Employee Purchase Program";
	imageTag = '&nbsp;&nbsp;<img src="http://media.4at5.net/email_domains/hhos/93540/images/tags_epp.png" border="0" style="display: inline;" align="absmiddle">';
	product_code = "EPP_00_CN517A%23B1H";
} else if (mailingProgram == "APP" && messageType != "hpn" && !isMB){
	audience = "HP Academy";
    imageTag = '&nbsp;&nbsp;<img src="http://media.4at5.net/email_domains/hhos/93540/images/tags_app.png" border="0" style="display: inline;" align="absmiddle">';
    document.from("HP Academy");  //set friendly from
    facePage = "HPstudents";
	twitterPage = "hpacademy";
	product_code = "EPP_00_CN517A%23B1H";
} else if (mailingProgram == "General Store"){
	audience = "Home and Home Office Store";
	imageTag = "";
	product_code = "CN517A%23B1H";
}

if (commercial){
	mailingProgram = "General Store";
    audience = "Small Business Direct";
}

if (leverage){
    audience = "HP Newsgram";
    mailingProgram = "General Store";
    jumpID = "IB_"+jobnum+"NG";
    if(!isMB){
        phone = "1-888-917-8097";
    }
}

if(messageType == "hpn"){
    audience = "HP Newsgram";
    mailingProgram = "General Store"; //General store is default
}

if(isMB && !leverage)
    audience = "Small Business Direct";

if(messageType == "microbiz" || messageType == "MB_1" || clientDivision == "MB" || clientDivision == "MBCOMM" || clientDivision == "MBIB") //Microbiz Friendly From
    document.from("HP Small Business Direct Store");  //set friendly from

//Append Espanol to Phone if not on new template
if(messageType != "hhos_2"){
    //phone = appendEspanol(phone,"text");
}

if (messageType == "hpn") {
    jobnum = "hpn_" + jobnum;
}
omniture = jobnum + "|" + mmid + "|" +urlArg;


/************************************************************************
END Building Exceptions for different programs and Templates
************************************************************************/

/************************************************************************
AOIDs
************************************************************************/

var aoid = getByProgram(aoidArray, mailingProgram);  //Returns AOID
var imageVal = getImageVal(mailingProgram);  //This is appended on each image to load _app or _hpepp, etc



/************************************************************************
SUBJECT LINES
************************************************************************/
if(templateColor == "white") { 

var subjectLine;
var TextHeadlineURL = "Text headline URL";
var title = "Share, Explore & Learn With HP";
var textHeadline = 'Share, Explore & Learn With HP';
subjectLine = "";

} else {

var subjectLine;
var title = "Love YOUR NEW HP Share, Explore & Learn With HP";
var textHeadline = 'Love YOUR NEW HP Share, Explore & Learn With HP';
subjectLine = "";

}
//document.subject(subjectLine);


var alt = "SEE THE GREAT DEALS WAITING FOR YOU AT HP HOME and HOME OFFICE STORE!";

//document.write("messageType: " + messageType + "<BR>");

POST--><!--POST if(messageType == "hpn"){ POST-->`audience`
http://www.hp.com?aoid=`aoid`&hhosnl=`jobnum`|`mmid`|`urlArg`
---------------------------------------------------------------

`textHeadline`
@HTML_PREVIEW_LINK&msgVersion=web

---------------------------------------------------------------<!--POST }else{ POST-->To ensure you receive your HP Home & Home Office Store offers,
please add news@mail.hpshopping.com to your address book.
Need help? Visit:
http://h30189.www3.hp.com/add_address.jsp
---------------------------------------------------------------
If you prefer to view this message in HTML format, please visit:
@HTML_PREVIEW_LINK&msgVersion=web
---------------------------------------------------------------

`audience`

---------------------------------------------------------------

`title`
@HTML_PREVIEW_LINK&msgVersion=web

---------------------------------------------------------------
<!--POST } POST--><insert><name>sub_footer_trans</name></insert>
<insert><name>footer_trans</name></insert>
