//Start added by Alan Sim 12 Aug 2003 for Sg promotion
function printerfriendly()
{
	document.write ("<img src=\"http://thenew.hp-ww.com/img/hpc60_topnav_print_icon.gif\" width=\"20\" height=\"13\" alt=\"printable version\" border=\"0\"><a href=\"http://www.hp.com/cgi-bin/pf-new.cgi?in=" + location.href + "\"><strong>printable version</strong></a>");
}
//End added by Alan Sim 12 Aug 2003 for Sg promotion

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] = "http://welcome.hp-ww.com/img/s.gif; ; ";
rnd_general[2] = "http://welcome.hp-ww.com/img/s.gif; ; ";
rnd_general[3] = "http://welcome.hp-ww.com/img/s.gif; ; ";
rnd_general[4] = "http://welcome.hp-ww.com/img/s.gif; ; ";
rnd_general[5] = "http://welcome.hp-ww.com/img/s.gif; ; ";

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];
	// STOP RANDOMIZER ADS FROM DISPLAYING BELOW RIGHT PROMO CHICLETS.
	// document.write("<a href='" + imglink + "'><img src='" + rndimage + "' alt='" + imgalttext + "' border=0></a>");
}

// ROTATING HOME PROMOTION GRAPHICS

var totalpics = 3; // 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_promo.jpg";
ad1[1]="/images/chiclet_ng1.gif";
ad1[2]="/images/chiclet_ng2.gif";
ad1[3]="/images/chiclet_ng3.gif";

var ad1url = new Array(); // array of urls for column1, the url order follows ada order
ad1url[0]="/promotions.asp"
ad1url[1]="http://h20424.www2.hp.com/program/scripts/ap/en/click.asp?lid=ngc"
ad1url[2]="http://h20424.www2.hp.com/program/scripts/ap/en/click.asp?lid=ngc"
ad1url[3]="http://h20424.www2.hp.com/program/scripts/ap/en/click.asp?lid=ngc"

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
// 30 Aug 2005 (Desmond Low) stop old Informative survey
var expDays = 365; // number of days the cookie should last
var surveyURL = "http://dialogue.informative.com/hp/hho/sg";

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=400"); // prevent survey window from appearing
			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