<insert><name>main_functions_test</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 mailingProgram;
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>");
*/

//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";
                 }
             } else { //Otherwise, Evaluate the given expression
                 //eval(val);
             }
         }else{
             //Is Numeric, append to Array    
             aoidArray.push(val * 1);
         }
         
     }
}



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




  //--------------------------------------------------//
 //--------- 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_test</name></insert><!--POST



/************************************************************************
HHOS BACKGROUNDS
************************************************************************/

// BACKGROUND COLOR FOR BODY OF MESSAGE
var bodyBG = "#eaeaea";
// BACKGROUND COLOR FOR LINKS BLOCK IN FOOTER
var linksBG = "#000000";
// LINK TEXT COLOR FOR LINKS BLOCK IN FOOTER
var linksFont = "#FFFFFF";


bodyBackground = "#958d89";
innerBackground = "#d2d0ce";
articleBackground = "";


/************************************************************************
END HHOS BACKGROUNDS
************************************************************************/

var jobnum = "6047";  //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 = 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"){
    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"){
	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"){
	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(leverage || messageType == "hpn"){
    //Defines Omniture tagging for HPN messages
    var id = funcEnc(user.attr("id"));
    var ccmCkmId = funcEnc(funcNul(user.attr("ccmckmid")));
    var urlArg = id + "|" + ccmCkmId;
    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
************************************************************************/
var subjectLine;
var TextHeadlineURL = "http://----------Use The Main Hero Link Here-----------------------------&jumpid=em_r329_" + jumpID + "&aoid=" + aoid + "&email=" + listsource;
var title = "HP BEST GIFTS 4 Days To Save On Printers & Accessories";
var textHeadline = '<a href="' + TextHeadlineURL + '" style="color:#FFFFFF; text-decoration: none;"><font style="font-family: arial; color: rgb(214, 214, 214); font-size: 18px;" align="left" width="408"><font style="font-size: 12px; font-weight: bold; color: rgb(166, 166, 166);"> HP BEST GIFTS<br></font>4 Days To Save On Printers & Accessories</font></a>';
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.dyn?v=s
---------------------------------------------------------------
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_test</name></insert>
<insert><name>footer_test</name></insert>