<insert><name>main_functions</name></insert><!--POST

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

var msgVersion = user.attr("msgVersion");
var firstName       = initCap(user.attr ("firstName"), "Valued Customer");
var eMail = user.attr("eMail");
var userid          = user.attr("id");
var userID          = user.attr("id");
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 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 English/Espal"; 
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;

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


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

// Define what type of message this is, Can be
//hhos
//microbiz
//hpn

var messageType = "hhos";


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

POST--><insert><name>message_vars</name></insert><!--POST



/************************************************************************
HPN 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";


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

var aoid;
var store_name;
//define Job Number
var jobnum = "hpn_1018";
var imageVal = "";  //This is appended on each image to load _app or _hpepp, etc
var folder = "gs";  //This is the folder that images are stored in, changes between versions.
var printerVal = "";

if(messageType == "microbiz")
{
	facePage = "hpsmallbusiness";
}

//Settups AOIDs for different versions
if (mailingProgram == "EPP_HP"){
	aoid = "79552";
	imageVal = "_hpepp";
	printerVal = "EPP_00_";
} else if (mailingProgram == "EPP"){
	aoid = "83489";
	imageVal = "_epp";
	printerVal = "EPP_00_";
} else if (mailingProgram == "APP"){
	aoid = "79552";
	imageVal = "_app";
	printerVal = "EPP_00_";
} else if (mailingProgram == "General Store"){
	aoid = "83488";
	printerVal = "";
}

if (mmid == "1222065"){  //Commercial
	aoid = "83487";
	var commercial = true;
	imageVal = "";
	mailingProgram = "General Store";
    audience = "Small Business Direct";
}

if (mmid == "729959"){  //Leverage
	aoid = "83490";
	leverage = true;
	jobnum = "hpn_1018";
	imageVal = "";
	printerVal = "";
}
   

//Changes phone number if APP(AKA HPA)
var phone = "1-866-433-2028 English/Espal";
if (mailingProgram == "APP")
    phone = "1-866-433-2029 English/Espal";
if (messageType == "microbiz"){
    phone = "1-800-608-6947 English/Espal";
}
if(messageType == "hpn"){
    phone = "1-888-917-8097";
    aoid = "79555";
    }
     
//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 = jobnum + "&userMail=epp";
 else 
    jumpID = jobnum;
   
if (messageType == "microbiz"){
	if(mailingProgram == "EPP_HP" || mailingProgram == "EPP" || mailingProgram == "APP")
	jumpID = jobnum + "MB" + "&userMail=epp";
	else 
	jumpID = jobnum + "MB";
}
    
if (leverage){
    audience = "HP Newsgram";
    mailingProgram = "General Store";
    if(messageType != "microbiz"){
        phone = "1-888-917-8097 English/Espal";
        jumpID = jobnum+"NG";
    }
}
/************************************************************************
SUBJECT LINES
************************************************************************/
var textHeadline = "Reward Yourself!";
var subjectLine;

//document.subject(subjectLine);

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



/************************************************************************
LEGACY CODE
************************************************************************/

function isString(stringVal)
{
    var bool1 = true;
    var test1 = (typeof stringVal);
    if(test1 != "string")
        bool1 = false;
    return bool1;
}

function checkNull(str) {

	if(str == "" || str == " " || str == null) {
		str = " ";
	}
	
	return str;
}

var footNote = "";

/************************************************************************
MULTITABLE SCRIPT
************************************************************************/
var userID = user.attr("id");
var timeString = "8-14 days";
var arg = timeString + "|" + userID + "|";
multitable.setID("getGsmProductInfo", arg); 
var i = 0; 

while (multitable.getNext("getGsmProductInfo")) {  
 i++;   
var productNumber = multitable.getValue("getGsmProductInfo", "productNumber");     
var productName = multitable.getValue("getGsmProductInfo", "productName");     
var productSeries = multitable.getValue("getGsmProductInfo", "productSeries");
var productFamily = checkNull(multitable.getValue("getGsmProductInfo", "productSubCategory2"));
}

var aoid;

var hasPavDesktop = false;
var hasPavNotebook = false;
var hasCompPresDesktop = false;
var hasCompPresNotebook = false;
var hasMediaDesktop = false;
var hasOfficejetOrPSC = false;
var hasDeskjet = false;
var hasPhotosmartPhoto = false;
var hasPhotosmartAIO = false;
var hasDigitalCamera = false;
var hasPhotoScanner = false;
var hasTV = false;
var personalizedProduct = false;

if(isString(productFamily)){
/************************************************************************
AOID AND FAMILY SEGMENTATION
************************************************************************/

if (productFamily.indexOf("HP Pavilion Desktop PCs") > -1) {
aoid = 38814;
} else if (productFamily.indexOf("HP Pavilion Notebook PCs") > -1) {
aoid = 38815;
} else if (productFamily.indexOf("Compaq Presario Desktop PCs") > -1) {
aoid = 38816;
} else if (productFamily.indexOf("Compaq Presario Notebook PCs") > -1) {
aoid = 38817;
} else if (productFamily.indexOf("HP Media Center Desktop PCs") > -1) {
aoid = 38818;                
} else if (productFamily.indexOf("HP DeskJet Printers") > -1) {
aoid = 38819;
} else if (productFamily.indexOf("HP Deskjet All-in-one Products") > -1) {
aoid = 38820;
} else if (productFamily.indexOf("HP Deskjet Fax Products") > -1) {
aoid = 38821;
} else if (productFamily.indexOf("HP Photosmart All-In-One Products") > -1) {
aoid = 38822;
} else if (productFamily.indexOf("HP Photosmart Digital Cameras") > -1) {
aoid = 38823;
} else if (productFamily.indexOf("HP Photosmart Photo Scanners") > -1) {
aoid = 38824;
} else if (productFamily.indexOf("HP Flat Panel Televisions") > -1) {
aoid = 38825;
} else if (productFamily.indexOf("HP Digital projectors") > -1) {
aoid = 38826;
} else  {
aoid = 38813;
}

/************************************************************************
CODE TO DETERMINE PRODUCT PERSONALIZATION
************************************************************************/


if (productFamily.indexOf("HP Pavilion Desktop PCs") > -1) {
personalizedProduct = true;
hasPavDesktop = true;
} else if (productFamily.indexOf("HP Pavilion Notebook PCs") > -1) {
personalizedProduct = true;
hasPavNotebook = true;
} else if (productFamily.indexOf("Compaq Presario Desktop PCs") > -1) {
personalizedProduct = true;
hasCompPresDesktop = true;
} else if (productFamily.indexOf("Compaq Presario Notebook PCs") > -1) {
personalizedProduct = true;
hasCompPresNotebook = true;
} else if (productFamily.indexOf("HP Media Center Desktop PC") > -1) {
personalizedProduct = true;
hasMediaDesktop = true;
} else if ((productFamily.indexOf("HP PSC All-in-One Products") > -1) || (productFamily.indexOf("HP Officejet All-in-One Products") > -1) ) {
personalizedProduct = true;
hasOfficejetOrPSC = true;
} else if (productFamily.indexOf("HP DeskJet Printers") > -1) {
personalizedProduct = true;
hasDeskjet = true;
} else if (productFamily.indexOf("HP Deskjet All-in-One Products") > -1) {
personalizedProduct = true;
hasDeskjet = true;
} else if (productFamily.indexOf("HP Deskjet Fax Products") > -1) {
personalizedProduct = true;
} else if (productFamily.indexOf("HP Photosmart Photo Printers") > -1) {
personalizedProduct = true;
hasPhotosmartPhoto = true;
} else if (productFamily.indexOf("HP Photosmart All-in-One Products") > -1) {
personalizedProduct = true;
hasPhotosmartAIO = true;
} else if (productFamily.indexOf("HP Photosmart Digital Cameras") > -1) {
personalizedProduct = true;
hasDigitalCamera = true;
} else if (productFamily.indexOf("HP Photosmart Photo Scanners") > -1) {
personalizedProduct = true;
hasPhotoScanner = true;
} else if (productFamily.indexOf("HP Flat Panel Televisions") > -1) {
personalizedProduct = true;
hasTV = true;
} else {
personalizedProduct = false;
}

/*******************************************************************************
PRODUCT FAMILY STRING MANIPULATION TO MAKE SINGULAR AND PRODUCT PERSONALIZATION
*******************************************************************************/

var productFamilyLength = productFamily.length;

if (personalizedProduct) {

       if (productFamily.indexOf("HP Deskjet All-in-One Products") > -1) {
	
	   productFamily = "HP Deskjet All-In-One";
	   
	} else if (productFamily.indexOf("HP Deskjet Fax Products") > -1) {  
	   
	   productFamily = "HP Deskjet Printer";
	
	} else if (productFamily.indexOf("HP Photosmart All-in-One Products") > -1) {  
	   
	   productFamily = "HP Photosmart All-In-One";
	   
	} else if (productFamily.indexOf("HP Flat Panel Televisions") > -1) {  
	   
	   productFamily = "HP Television";
	   
        } else if (productFamily.indexOf("HP Photosmart Photo Printers") > -1) {  
	   
	   productFamily = "HP Photosmart Printer";

	} else { 
	
		productFamily = productFamily;
		
	} 

	if (productFamily.charAt(productFamilyLength - 1) == "s") {
	
	   productFamily = productFamily.substring(0,productFamilyLength - 1);
	
	} 

} else {

	productFamily = "new product from HP";
	

}
}

/************************************************************************
SUBJECT LINE
************************************************************************/
var subjectProduct;

if (personalizedProduct) {

	subjectProduct = productFamily;
	
} else {

	subjectProduct = "HP Product";
	
}

document.subject("Getting Started with your New " + subjectProduct);

/************************************************************************
END LEGACY CODE
************************************************************************/

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`

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

`textHeadline`
@HTML_PREVIEW_LINK&msgVersion=web

---------------------------------------------------------------
<!--POST } POST--><insert><name>sub_footer</name></insert>
<insert><name>footer</name></insert>