var whichProd = "";
var cat = "";
var fromCookie = 0;
var metas = document.getElementsByTagName("meta");
var tmp = null;
var pretmp = null;
var tmpVal = null;
var recCookie = false;

	
function trimAll(sString) {
	if (sString != null){
		while (sString.substring(0,1) == ' ') {
			sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' ') {
			sString = sString.substring(0,sString.length-1);
		}
	}
	return sString;
}


function Get_Cookie( name ) {
		
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) {
		return null;
	}
	
	var end = document.cookie.indexOf( ";", len );	
	if ( end == -1 ) end = document.cookie.length;	
	return unescape( trimAll(document.cookie.substring( len, end ) ));
}



for (var i = 0; i < metas.length; i++) {	
	if (metas[i].name == "product_service_name"){
		var product_meta_index = i;
		if ( Get_Cookie('smbRMcookie') ) {
			tmp = Get_Cookie('smbRMcookie');
			pretmp = Get_Cookie('smbRMcookie');
			productcookiedefined = true;
			tmp = trimAll(tmp);
			tmp = tmp.replace(/\_/g,' ');
			tmp = 'entry_page/'+tmp; //added to meet Cyndi's new requirements for this page only.
			metas[i].content = tmp;
			fromCookie = 1;
		} else {
			tmp = null;
		}		
	}	
}

// /sbso/index_evo.html and /sbso/index.html
var urlpathname = location.pathname;

if (fromCookie == 1 && urlpathname == "/sbso/index.html") {	
	document.write("<scr"+"ipt language=\"JavaScript\" type=\"text\/javascript\" src=\"http:\/\/www.hp.com\/country\/js\/hpweb_syn_con.js\"><\/scr"+"ipt>");
}

var urlString = document.location.href;
var urlString = urlString.toLowerCase();

var myDate = new Date;
myDate.setDate(myDate.getDate()+28);

if (urlString.indexOf('topiccode=psg') > 0) { 
	whichProd='PSG';
	if (tmp == null) {
		document.cookie = 'smbRMcookie=notebooks_tablet_pcs/notebook_pcs; expires='+myDate+'; path=/'; 
	}
} else if (urlString.indexOf('topiccode=ipg') > 0) { 
	whichProd='IPG';
	if (tmp == null) {
		document.cookie = 'smbRMcookie=printing_and_multifunction; expires='+myDate+'; path=/'; 
	}
} else if (urlString.indexOf('topiccode=tsg') > 0) {     
	whichProd='TSG';
	if (tmp == null) {
		document.cookie = 'smbRMcookie=servers; expires='+myDate+'; path=/';
	}
}

if ( tmp != null && tmp != "null" && tmp != "" ) {
	tmpVal = tmp.toLowerCase();
}



if (whichProd == "") {     
	if (tmpVal) {    
		if (tmpVal.indexOf("printing") > 0 || tmpVal.indexOf("multifunction") > 0 || tmpVal.indexOf("supplies") > 0 || tmpVal.indexOf("accessories") > 0 || tmpVal.indexOf("doityourself") > 0 || tmpVal.indexOf("fax") > 0 || tmpVal.indexOf("copiers") > 0 || tmpVal.indexOf("scanners") > 0 || tmpVal.indexOf("photography") > 0 || tmpVal.indexOf("camera") > 0 || tmpVal.indexOf("photo studios") > 0 ) {
			whichProd='IPG';
		} else if (tmpVal.indexOf("handhelds") > 0 || tmpVal.indexOf("calculators") > 0 || tmpVal.indexOf("handheld") > 0 || tmpVal.indexOf("pcs") > 0 || tmpVal.indexOf("desktops") > 0 || tmpVal.indexOf("workstations") > 0 || tmpVal.indexOf("desktop") > 0 || tmpVal.indexOf("notebooks") > 0 || tmpVal.indexOf("wireless") > 0 || tmpVal.indexOf("tablet") > 0 || tmpVal.indexOf("notebook") > 0 || tmpVal.indexOf("workstation") > 0) {
			whichProd='PSG';
		} else if (tmpVal.indexOf("servers") > 0 || tmpVal.indexOf("storage") > 0) {
			whichProd='TSG';
		}
	}
}


if ( tmpVal == "" || tmpVal == null || tmpVal == 'null' || tmpVal == undefined || tmpVal == 'undefined' ) {
	tmpVal = "";
}


if ( tmpVal.indexOf("accessories") >= 0 || tmpVal.indexOf("suppl") >= 0 || tmpVal.indexOf("doityourself") >= 0 ) {
	cat = "supplies";	
} else if ( tmpVal.indexOf("calculator") >= 0 || tmpVal.indexOf("handheld") >= 0 ) {
	cat = "handhelds";
} else if ( tmpVal.indexOf("large") >= 0 || tmpVal.indexOf("design") >= 0 ) {
	cat = "large";
} else if ( tmpVal.indexOf("photo printer") >= 0 || tmpVal.indexOf("inkjet") >= 0 || tmpVal.indexOf("color laserjet") >= 0 || tmpVal.indexOf("color hp laserjet") >= 0 ) {
	cat = "color_printers";
} else if ( tmpVal.indexOf("black and white multifunction") >= 0 || tmpVal.indexOf("all-in-one") >= 0 || tmpVal.indexOf("all in one") >= 0 ) {
	cat = "multifunction";
} else if ( tmpVal.indexOf("black and white") >= 0 ) {
	cat = "bw_printers";
} else if ( tmpVal.indexOf("multifunction") >= 0 ) {
	cat = "multifunction";
} else if ( tmpVal.indexOf("scanner") >= 0 ) {
	cat = "scanners";
} else if ( tmpVal.indexOf("server") >= 0 ) {
	cat = "servers";
} else if ( tmpVal.indexOf("storage") >= 0 ) {
	cat = "storage";
} else if ( tmpVal.indexOf("bw") >= 0 || tmpVal.indexOf("black") >= 0 ) {
	cat = "bw_printers";
} else if ( tmpVal.indexOf("color") >= 0 ) {
	cat = "color_printers";
} else if ( tmpVal.indexOf("monitor") >= 0 ) {
	cat = "monitors";
} else if ( tmpVal.indexOf("service") >= 0 ) {
	cat = "service";
} else if ( tmpVal.indexOf("services") >= 0 ) {
	cat = "services";
} else if ( tmpVal.indexOf("multifunction") >= 0 || tmpVal.indexOf("copiers") >= 0 || tmpVal.indexOf("fax") >= 0 ) {
	cat = "multifunction";
} else if ( tmpVal.indexOf("desktop pc") >= 0 ) {
	cat = "desktops";
} else if ( tmpVal.indexOf("workstation") >= 0 ) {
	cat = "workstations";
} else if ( tmpVal.indexOf("notebook") >= 0 || tmpVal.indexOf("tablet") >= 0 || tmpVal.indexOf("wireless") >= 0) {
	cat = "notebooks";
} else if ( tmpVal.indexOf("desktop") >= 0 || tmpVal.indexOf("pc") >= 0 ) {
	cat = "desktops";
} 
  else
	cat == "";

	
if ( cat == "" || cat == null || cat == " " || cat == 'null' || cat == undefined || cat == 'undefined') {
	cat = "day";
} else {
	recCookie = true;
}







var currentTime = new Date();
var day = currentTime.getDate();

//alert("Temp: "+tmpVal+"\nCat: "+cat+"\nDay: "+day);



	