//-- start code to include tce survey js file
document.write('<script src="http://welcome.hp-ww.com/cma/metrics/survey/ap_hho.js"><\/script>');
//-- end code to include TCE survey js file

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,width,height){
	win = open (url, 'popup', 'height='+height+',width='+width+',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://h50091.www5.hp.com/en/en/products/dj5160/index.asp";
rnd_general[2] = "/images/rnd_general/banner_dj3550.gif;HP deskjet 3550;http://h50091.www5.hp.com/en/en/products/dj3550/index.asp";
rnd_general[3] = "/images/rnd_general/banner_dj3650.gif;HP deskjet 3650;http://h50091.www5.hp.com/en/en/products/dj3650/index.asp";

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 = 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://h50011.www5.hp.com/scripts/click.asp?lid=ngc"
ad1url[2]="http://h50011.www5.hp.com/scripts/click.asp?lid=ngc"
ad1url[3]="http://h50011.www5.hp.com/scripts/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;
	}
}




function outofsite(url)
{
		window.location.href="outofsite.asp?url=" + url;
}

function openWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

var rnd_browsebuy = new Array();
rnd_browsebuy[1] = "<a href='http://h50055.www5.hp.com/ipg/supplies/th/print_efficiency.asp'><img src='/en/images_oov/print_eff_chiclet_01.gif' width='148' height='110' border='0' alt='See how HP&acute;s competitive edge in efficiency can save you ink and money'></a>";
rnd_browsebuy[2] = "<a href='http://h50055.www5.hp.com/ipg/supplies/th/print_efficiency.asp'><img src='/en/images_oov/print_eff_chiclet_02.gif' width='148' height='110' border='0' alt='Find out how efficient HP printing systems can save you ink and money'></a>";

function randomizer2(category) {
	rndimagenum = Math.ceil(Math.random() * (eval("rnd_" + category + ".length") - 1));
	eval ("items = rnd_" + category + "[" + rndimagenum + "];");
	rndswf = items;
	
	document.write(rndswf);
}


function jump() 
{
//	var index = document.dropdown.language.selectedIndex;
//	url = eval("document.dropdown.language.options[" + index + "].value");
//	window.location.href=(url);

	var index = document.dropdown.language.selectedIndex;
	var path = location.pathname;
	var url = "";

	if (path.search(/en/) == -1)
		url = path.replace(/th/,"en");
	else
		url = path.replace(/en/,"th");
				
	window.location.href=(url);
}
	
	
	
	
	
//-- Start code for dynamic tagging
function stripTitle() {
	var strToStrip = "HP Thailand 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	
	
function toggleTab(tabId, tabName){
	if(hideAllContent(tabName)){	
		document.getElementById(tabId+"-content").style.display = "block";
		document.getElementById(tabId+"-tab").className = "theme";
		document.getElementById(tabId+"-tab").innerHTML = tabName+"<span class=\"screenReading\"> - "+tabName+" - Selected </span>";
		if(SWFAddress.getValue() != tabId)
			SWFAddress.setValue(tabId);
	}
}

function hideAllContent(){
	var tabItems = document.getElementById("tabbedNav").getElementsByTagName("div");
	for (var i=0; i< tabItems.length; i++){
		var currTabId = tabItems[i].id;
		var tabClass = tabItems[i].className;
		var tabId = currTabId.substring(0, currTabId.indexOf("-tab"));
		document.getElementById(tabId+"-content").style.display = "none";
		if(tabClass.search(/theme/) != -1){
			//For selected tabs
			var contentInner = document.getElementById(tabId+"-tab").innerHTML;
			var idx = contentInner.toLowerCase().indexOf("<span");							
		}else{
			//For non-selected tabs			
			var anchorItems = document.getElementById(tabId+"-tab").getElementsByTagName("a");
			var contentInner = anchorItems[0].innerHTML;
			var idx = contentInner.toLowerCase().indexOf("<span");
		}		
		var tabName = contentInner.slice(0, idx);	
		document.getElementById(tabId+"-tab").className = "color666666bg";
		document.getElementById(tabId+"-tab").innerHTML = "&raquo; <a href=\"javascript:toggleTab('"+tabId+"', '"+tabName+"');\" class=\"colorFFFFFFbld\">"+tabName+"<span class=\"screenReading\"> - "+tabName+"</span></a>";
	}
	return true;
}

function initTabContent(){
	
	var swfAddressUrl = SWFAddress.getValue();	
	if(swfAddressUrl != "/"){
		var tabId = swfAddressUrl.substring(1);
		tabItems = document.getElementById("tabbedNav").getElementsByTagName("div");
		for (var i=0; i< tabItems.length; i++){
			var currtab = tabItems[i].id;
			var tabClass = tabItems[i].className;
			var posn = currtab.indexOf("-tab");
			var currTabId = currtab.substring(0, posn);			
			if(tabId == currTabId){
				if(tabClass.search(/theme/) != -1){
					//For selected tabs
					var contentInner = document.getElementById(tabId+"-tab").innerHTML;
					var idx = contentInner.toLowerCase().indexOf("<span");							
				}else{
					//For non-selected tabs			
					var anchorItems = document.getElementById(tabId+"-tab").getElementsByTagName("a");
					var contentInner = anchorItems[0].innerHTML;
					var idx = contentInner.toLowerCase().indexOf("<span");
				}		
				var tabName = contentInner.slice(0, idx);	
				toggleTab(tabId, tabName);
			}
		}
	}else{	
		var tabItems = document.getElementById("tabbedNav").getElementsByTagName("div");
		var firstTabId;
		for(var i = 0; i < tabItems.length; i++){
			var tabClass = tabItems[i].className;
			if(tabClass.search(/theme/) != -1){
				firstTabId = tabItems[i].id;
				break;
			}
		}
		
		//var firstTabId = tabItems[0].id;
		var contentInner = document.getElementById(firstTabId).innerHTML;
		var idx = contentInner.toLowerCase().indexOf("<span");
		var tabName = contentInner.slice(0, idx);	
		var posn = firstTabId.indexOf("-tab");
		var tabId = firstTabId.substring(0, posn);	
		toggleTab(tabId, tabName);
	}
}
	
	
	
	
	
	
	