function printerfriendly()
{
	document.write ("<img src=\"http://welcome.hp-ww.com/img/hpweb_1-2_prnt_icn.gif\" width=\"19\" height=\"13\" alt=\"\" border=\"0\"><a href=\"http://www.hp.com/cgi-bin/pf-new.cgi?IN=" + location.href + "\" class=\"udrlinebold\">Printable version</a>");
}

function compaq_printerfriendly()
{
	document.write ("<img src=\"http://welcome.hp-ww.com/img/cpq_topnav_print_icon.gif\" width=\"14\" height=\"13\" alt=\"printable version\" border=\"0\"><img src=\"http://welcome.hp-ww.com/img/s.gif\" width=\"3\" height=\"1\" border=\"0\" alt=\"\"><a href=\"http://www.hp.com/cgi-bin/pf-new.cgi?in=" + location.href + "\" class=\"cpqUdrlinebold\">printable version</a>");
}
function popup(url,wh,ht) {
	win = open (url, 'popup', 'height='+ht+',width='+wh+',scrollbars=yes,toolbars=no,left=0,top=0');
	win.focus();
}
// Randomiser Advertisement on right nav

var rnd_general = new Array();

rnd_general[1] = "/images/rnd_general/banner_deskjet5160.gif;HP deskjet 5160;http://h50031.www5.hp.com/products/dj5160/index.shtml";
rnd_general[2] = "/images/rnd_general/psc1210_random.jpg;HP psc 1210;http://h50025.www5.hp.com/hpcom/au_en/10_38_77_537summary.html";
rnd_general[3] = "/images/rnd_general/banner_dj3550.gif;HP deskjet 3550;http://h50031.www5.hp.com/products/dj3550/index.shtml";
rnd_general[4] = "/images/rnd_general/banner_dj3650.gif;HP deskjet 3650;http://h50031.www5.hp.com/products/dj3650/index.shtml";

function randomizer(category) {
	rndimagenum = Math.ceil(Math.random() * (eval("rnd_" + category + ".length") - 1));
	eval ("items = rnd_" + category + "[" + rndimagenum + "].split(';');");
	rndimage = items[0];
	imgalttext = items[1];
	imglink = items[2];
	document.write("<a href='" + imglink + "'><img src='" + rndimage + "' alt='" + imgalttext + "' border=0></a>");
}

// ROTATING HOME PROMOTION GRAPHICS

var totalpics = 1; // ALWAYS total number of pics - 1
var ct1 = 0;  // column 1 counter to start at 0

var ad1 = new Array(); // array of images for column 1
ad1[0]="/images/chiclet_australia.jpg";
ad1[1]="/images/chiclet_promo.jpg";

var ad1url = new Array(); // array of urls for column1, the url order follows ada order
ad1url[0]="/bigbang/luckydraw.shtml"
ad1url[1]="/promotions.shtml"

var url1 = ad1url[0];

// Start Rotating Images in each column

// Rotating Column 1 graphics
function cyclec1() {
/*
	if (document.images) {
		if (document.promo1.complete) {
			
			document.promo1.src=ad1[ct1];
			url1 = ad1url[ct1];
			if (ct1==totalpics) {
				ct1=0;
			}
			else {
				ct1++;
			}
		}
		setTimeout("cyclec1()", 5000);
	}
*/
}

// Putting Column 1 graphics url
function geturl1() {
	if (!url1.indexOf("http://")) {
		if(url1==ad1url[1])
		window.open(url1);
		else
		{
		parent.location.href=url1;
		}
	}
	else {
		parent.location.href = url1;
	}
}
// Start added by alan for ap survey 20 aug 2003
var expDays = 365; // number of days the cookie should last
/**var surveyURL = "http://h50031.www5.hp.com/survey/index.html";

function openSurvey()
{//v2.0
	var count = GetCookie('count');
	if (count == null)
	{
		// creates new cookie for counter
		SetCookie('count', 1, exp);
		// creates new cookie for last visit
		SetCookie('lastvisit', new Date(), exp);
	}
	else if (count < 2) // have yet taken the survey
	{
		var lastvisit = new Date(GetCookie('lastvisit'));
		var now = new Date();
		var diff = now.getTime() - lastvisit.getTime();
		var mindiff = Math.floor(diff / (1000 * 60));
		if (mindiff >= 30) // last visit was more than 30mins ago
		{
			window.open(surveyURL,"survey","scrollbars=yes,width=600,height=700");
			count++;
			SetCookie('count', count, exp);
		}
		else
			SetCookie('lastvisit', new Date(), exp);
		
	}
}**/

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function When(info)
{
	var rightNow = new Date()
	var WWHTime = 0;
	WWHTime = GetCookie('lastvisit')
	WWHTime = WWHTime * 1
	var lastHereFormatting = new Date(WWHTime);
	var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
	var lastHereInDateFormat = "" + lastHereFormatting;
	var dayOfWeek = lastHereInDateFormat.substring(0,3)
	var dateMonth = lastHereInDateFormat.substring(4,11)
	var timeOfDay = lastHereInDateFormat.substring(11,16)
	var year = lastHereInDateFormat.substring(23,25)
	var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay
	SetCookie ("lastvisit", rightNow.getTime(), exp)
	return WWHText
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) +  ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function amt(){
	var count = GetCookie('count')
	if(count == null) {
		SetCookie('count','1')
		return 1
	}
	else {
		var newcount = parseInt(count) + 1;
		DeleteCookie('count')
		SetCookie('count',newcount,exp)
		return count
	}
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
	var count = GetCookie('count');
	if (count == null) {
		count=1;
		SetCookie('count', count, exp);
		
		window.open(page, "", windowprops);
	}
	else {
		count++;
		SetCookie('count', count, exp);
	}
}

//openSurvey();
// End added by alan for ap survey 20 aug 2003


//-- Start code for dynamic tagging
function stripTitle() {
	var strToStrip = "HP Singapore Home & Home Office - ";
	var title = document.title;
	
	var stripped = title.substring(strToStrip.length);
	
	if (stripped.indexOf("#")!=-1) {
		var temp = stripped.split("#");
		stripped = temp[0];
	}
	
	return stripped;
}


function retrieveLang() {
	if (document.getElementsByTagName){
		return window.document.documentElement.lang;
	}
}


function retrieveCty() {
	if (document.getElementsByTagName) {
		var metaTags=document.getElementsByTagName("META");
		var meta;

		for (var i=0; i<metaTags.length; i++) {
			if (metaTags[i].tagName == "META") {	
				meta = metaTags[i];
				if (meta.name == "target_country") {
					return meta.content.toLowerCase();
					}
			}
		}
	}
}


function mapFolderNumToName(folderNum) {
	var folderName = "";
	var url = document.URL.split('://');
	var temp = url[1].split('/');
	
	for (x=0; x<temp.length; ++x){
		if(x==parseInt(folderNum)) {
			folderName = returnfoldervalue(temp[x]);
		}
	}
	
	if(!(folderName.length>0)) {
		folderName = "*";
	}
	
	return folderName;
}


function returnfoldervalue(valfolder){
	var pos_val=valfolder.indexOf('.');
	
	if(pos_val>0) {
		return(valfolder.substring(0, pos_val));
	} 
	else {
		return(valfolder);
	}
}
//-- End code for dynamic tagging
