if (hp==1) imgDir=""
else imgDir="../"

var arrContentBGColor = new Array();
var arrLinkBGColor = new Array();
var arrLinkBGColor2 = new Array();
var arrLinkBGColor3 = new Array();
arrContentBGColor['red'] = "#CF4DBB";
arrContentBGColor['green'] = "#48A600";
arrContentBGColor['yellow'] = "#FFAD00";
arrContentBGColor['orange'] = "#B33808";
arrContentBGColor['blue'] = "#074CA7";
arrContentBGColor['lblue'] = "#18BCF1";

arrLinkBGColor['red'] = "#76239A";
arrLinkBGColor['green'] = "#154A04";
arrLinkBGColor['yellow'] = "#FFAD00";
arrLinkBGColor['orange'] = "#B33808";
arrLinkBGColor['blue'] = "#1C4287";
arrLinkBGColor['lblue'] = "#18BCF1";

arrLinkBGColor2['red'] = "#CF4DBB";
arrLinkBGColor2['green'] = "#8AA582";
arrLinkBGColor2['yellow'] = "#FFAD00";
arrLinkBGColor2['orange'] = "#B33808";
arrLinkBGColor2['blue'] = "#8EA1C3";
arrLinkBGColor2['lblue'] = "#18BCF1";

arrLinkBGColor3['red'] = "#F4A600";
arrLinkBGColor3['green'] = "#EB3D03";
arrLinkBGColor3['yellow'] = "#48A600";
arrLinkBGColor3['orange'] = "#48A600";
arrLinkBGColor3['blue'] = "#EB3D03";
arrLinkBGColor3['lblue'] = "#18BCF1";

// Function for change language
// 01/2006 : for the Simplified Chinese version, link to chinapaint.com.cn
function ChangeLanguage(objThis) {
	var sTargetLanguage = objThis;
	var sSelfPath = "";
	var sRedirectPath = "";
	

   	if (sTargetLanguage == "gb" )
        {       self.location = "http://www.chinapaint.com.cn";
        	return; 
        }

	sSelfPath += document.location;
	// special handling for architecture and industrial product search result page	
	if(sSelfPath.indexOf("arch_query.asp") != -1) {
		sSelfPath = sSelfPath.replace("arch_query.asp", "selector.asp#a01");
	} else if(sSelfPath.indexOf("ind_query.asp") != -1) {
		sSelfPath = sSelfPath.replace("ind_query.asp", "industrial.asp#a01");
	}

	// special handling for individual news page (amended 08/2005), direct back to news index page
	if(sSelfPath.indexOf("shownews.asp") != -1) {
		//sSelfPath = sSelfPath.replace("shownews.asp", "default.asp");
		sSelfPath = sSelfPath.substring(0, sSelfPath.indexOf("shownews.asp") ) + "default.asp";
        }

	if(sSelfPath.indexOf("/eng/") != -1) {
		sRedirectPath = sSelfPath.replace(/(\/eng\/)/, "/" + sTargetLanguage + "/");
		if (sRedirectPath.indexOf("/eng/") != -1) sRedirectPath = sRedirectPath.replace(/(\/eng\/)/, "/" + sTargetLanguage + "/");
	} else if(sSelfPath.indexOf("/big5/") != -1) {
		sRedirectPath = sSelfPath.replace(/(\/big5\/)/, "/" + sTargetLanguage + "/");
		if (sRedirectPath.indexOf("/big5/") != -1) sRedirectPath = sRedirectPath.replace(/(\/big5\/)/, "/" + sTargetLanguage + "/");
	} else if(sSelfPath.indexOf("/gb/") != -1) {
		sRedirectPath = sSelfPath.replace(/(\/gb\/)/, "/" + sTargetLanguage + "/");
		if (sRedirectPath.indexOf("/gb/") != -1) sRedirectPath = sRedirectPath.replace(/(\/gb\/)/, "/" + sTargetLanguage + "/");
	}
	
	//alert(sRedirectPath);
	self.location = sRedirectPath;
}

// Browser Detector ----
function BrowserMaster() {
	this.ver=navigator.appVersion;
	this.ua=navigator.userAgent;
	this.mac=(this.ua.indexOf("Mac")!=-1)?1:0;
	this.win=(this.ua.toUpperCase().indexOf("WINDOWS")!=-1)||(this.ua.toUpperCase().indexOf("WINNT")!=-1)?1:0;
	this.x11=(this.ua.toUpperCase().indexOf("X11")!=-1)?1:0;
	this.dom=document.getElementById?1:0;
	this.ie55=(this.ver.indexOf("MSIE 5.5")>-1 && this.dom)?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5.0")>-1 && this.dom)?1:0; 
	this.ie4=(document.all && !this.dom)?1:0; 
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0; 
	//this.bw=this.ie5?'ie5':this.ie4?'ie4':this.ns4?'ns4':this.ns5?'ns5':'';
	this.bw=this.ie55?'ie55':this.ie5?'ie5':this.ie4?'ie4':this.ns4?'ns4':this.ns5?'ns5':'';
//	alert(this.ver);
	return this;
}

bw=new BrowserMaster();

// Image Swaper ----
if (hp!=1) {
	var imageDir = "../images/content_page/";
	var imageNames = new Array("menu_01","menu_02","menu_03","menu_04","menu_05","menu_06","menu_07","menu_08","menu_09","cubesAbout01","cubesAbout02","cubesAbout03","cubesAbout04","cubesAbout05","cubesProducts01","cubesProducts02","cubesProducts03","cubesProducts04","cubesPainting01","cubesPainting02");
	var menuArray = new Array("sAbout","sProducts","sPainting");
}

var onImg = new Array();
var offImg = new Array();
for (var i = 0; i < imageNames.length; i++) {
	refName = imageNames[i];
	if (refName.substr(0,4)=='cube') {
		imgName = imageDir + refName.substr(0,4) + ".gif";
		imgHLName = imageDir +refName.substr(0,4) + "_on.gif";
	} else {
		imgName = imageDir + refName + ".gif";
		imgHLName = imageDir + refName + "_on.gif";
	}
	onImg[refName] = new Image();
	offImg[refName] = new Image();
	onImg[refName].src = imgHLName;
	offImg[refName].src = imgName;
}

function on(imgName,layerName) {
	if (loaded>=3) {
		if (bw.ns4&&layerName!=null) window.document.layers[layerName].document.images[imgName].src=onImg[imgName].src
		else document[imgName].src = onImg[imgName].src
	}
}

function off(imgName,layerName) {
	if (loaded>=3) {
		if (bw.ns4&&layerName!=null) window.document.layers[layerName].document.images[imgName].src=offImg[imgName].src
		else document[imgName].src = offImg[imgName].src
	}
}

// Menu Shower --
lastMenu = null;
rightX = 0;
leftX = 0;
function showlayer(LayerName) {
	if (bw.ns4) document.layers[LayerName].visibility="visible"
	else if (bw.ns5) document.getElementById(LayerName).style.visibility="visible"
	else document.all(LayerName).style.visibility="visible"
}
function hidelayer(LayerName) {
	if (bw.ns4) document.layers[LayerName].visibility="hidden"
	else if (bw.ns5) document.getElementById(LayerName).style.visibility="hidden"
	else document.all(LayerName).style.visibility="hidden"
}
function hideAll() {
	for (var i = 0; i < menuArray.length; i++) {
		hidelayer(menuArray[i]);
	}
}
function showit(LayerName,tHeight) {
	var submenu
	if (bw.ns4) {
		submenu = document.layers[LayerName];
		if (lastMenu != null && lastMenu != submenu) hideAll();
		leftX  = submenu.left = menuAbLeft;
		rightX = leftX + submenu.clip.width;
		topY = submenu.top = menuAbTop + tHeight*menuGap;
		bottomY = submenu.top+submenu.clip.height;
		submenu.visibility = "visible";
	} else if (bw.ns5) {
		submenu=document.getElementById(LayerName)
		if (lastMenu != null && lastMenu != submenu) hideAll();
		submenu.style.left=menuAbLeft;
		submenu.style.top=menuAbTop+tHeight*menuGap;
		leftX  = submenu.offsetLeft;
		rightX = leftX + submenu.offsetWidth;
		topY = submenu.offsetTop;
		bottomY = submenu.offsetTop+submenu.offsetHeight;
		submenu.style.visibility = "visible";
	} else if (bw.ie5) {  
  		// ie5.x
		submenu=document.all[LayerName]
		if (lastMenu != null && lastMenu != submenu) hideAll();
		leftX  = submenu.style.posLeft = menuAbLeft;
		rightX = leftX + submenu.offsetWidth;
		topY = submenu.style.posTop = menuAbTop + tHeight*menuGap;
		bottomY = submenu.style.posTop+submenu.offsetHeight;
		submenu.style.visibility = "visible";
	} else if (bw.ie55) { 
		submenu=document.all[LayerName]
		if (lastMenu != null && lastMenu != submenu) hideAll();
		leftX  = submenu.style.posLeft = menuAbLeft;
		rightX = leftX + submenu.offsetWidth;
		topY = submenu.style.posTop = menuAbTop - menuTopGap + tHeight*menuGap;
		bottomY = submenu.style.posTop+submenu.offsetHeight;
		submenu.style.visibility = "visible";
	} else {  // ie6.0 and above
		submenu=document.all[LayerName]
		if (lastMenu != null && lastMenu != submenu) hideAll();
		leftX  = submenu.style.posLeft = menuAbLeft;
		rightX = leftX + submenu.offsetWidth;
		//topY = submenu.style.posTop = menuAbTop - menuTopGap + tHeight*menuGap;
		topY = submenu.style.posTop = menuAbTop + tHeight*menuGap;
		bottomY = submenu.style.posTop+submenu.offsetHeight;
		submenu.style.visibility = "visible";
	}
	lastMenu = submenu;
}

function updateIt(e) {

	if (bw.ns4) {
		var x = e.pageX;
		var y = e.pageY;
		menuLeft=document.layers['posit'].pageX;
		menuTop=document.layers['posit'].pageY;
	} else if (bw.ns5) {
		var x = e.pageX;
		var y = e.pageY;
		menuLeft=document.getElementById('posit').offsetLeft;
		menuTop=document.getElementById('posit').offsetTop;
	} else if (bw.ie4 || bw.ie5) {
		var x = document.body.scrollLeft+window.event.clientX;
		var y = document.body.scrollTop+window.event.clientY;
		var left = 0;
		var top = 0;
		var el = document.all['posit'];
		do {
			left += el.offsetLeft;
			top += el.offsetTop;
		}	while ((el = el.offsetParent));
		//alert(top);
		menuLeft=left;
		menuTop=top;
	} else if (bw.ie55) { 
		var x = document.body.scrollLeft+window.event.clientX;
		var y = document.body.scrollTop+window.event.clientY;
		var left = 0;
		var top = 0;
		var el = document.all['posit'];
		var sSelfPath = "";	
		do {
			left += el.offsetLeft;
			top += el.offsetTop;
		}	while ((el = el.offsetParent));
		menuLeft=left;
		menuTop=top;
	} else {  // ie 6.0 and above
		var x = document.body.scrollLeft+window.event.clientX;
		var y = document.body.scrollTop+window.event.clientY;
		var left = 0;
		var top = 0;
		var el = document.all['posit'];
		var sSelfPath = "";	
		do {
			left += el.offsetLeft;
			top += el.offsetTop;
		}	while ((el = el.offsetParent));
		//top = top + menuTopGap;
		//alert(top);
		menuLeft=left;
		menuTop=top;
	}
	menuAbLeft=menuLeft+menuLeftGap;
	menuAbTop=menuTop+menuBottomGap-2;
	if (x > rightX || x < menuLeft) hideAll();
	// following remarked due to incompatible to certain builds of ie6.0sp1
	// else if (y > bottomY || y < topY) hideAll();
}

// Initial the Page ----
function NS4ResizeCheck() {
  if(pendingReload&&(innerWidth!=origWidth||innerHeight!=origHeight)) {
    pendingReload=false;
    location.reload();
  }
}

// Style sheet (English styles differs for IE and Netscape ------
if (bw.ns4&bw.win) 
   { fs01en='10px'; fs02en='11px'; fs03en='12px'; fs04en='12px'; fs05en='17px'; fs06en='11px';}
else 
   { fs01en='9px';  fs02en='10px'; fs03en='11px'; fs04en='11px'; fs05en='16px'; fs06en='10px';}

ff01en='Verdana, Arial, Helvetica, sans-serif'

// old settings
// if (lan=="big5") {fs01='9pt';fs02='9pt';fs03='9pt';fs04='12pt';fs05='12pt';ff01='PMingLiU'}
// else if (lan=="gb") {fs01='9pt';fs02='9pt';fs03='9pt';fs04='12pt';fs05='12pt';ff01='MS Song'}
// else {fs01=fs01en;fs02=fs02en;fs03=fs03en;fs04=fs04en;fs05=fs05en;ff01=ff01en}

if (lan=="big5")    
   {fs01='9pt'; fs02='9pt'; fs03='9pt'; fs04='11pt'; fs05='12pt'; fs06='9pt';  ff01='·s²Ó©úÅé, PMingLiU'}
else if (lan=="gb") 
   {fs01='9pt'; fs02='9pt'; fs03='9pt'; fs04='11pt'; fs05='13pt'; fs06='10pt'; ff01='ËÎÌå,MS Song'}
else 
   {fs01=fs01en;fs02=fs02en;fs03=fs03en; fs04=fs04en; fs05=fs05en; fs06=fs06en; ff01=ff01en}


//overall style
if (hp==1) inStyle=''+
	'.bodyClass {background-color:'+arrBGColor[sColorPrefix]+'}'+
	'.image11 {background-image:url(images/'+sColorPrefix+'_11.gif)}'+
	'.image12 {background-image:url(images/'+sColorPrefix+'_12.gif)}'+
	'.image13 {background-image:url(images/'+sColorPrefix+'_13.gif)}'+
	'.image22 {background-image:url(images/'+sColorPrefix+'_22.gif)}'+
	''
else inStyle=''+
	'.subBG {background-color:'+arrContentBGColor[sContentColor]+'}'+
	'.topBG {background-image:url(../../images/'+sContentColor+'_top_right.gif)}'+
	'.menuBG {background-image:url(../../images/'+sContentColor+'_menu_bg.gif)}'+
	'.menuBGText {background-image:url(../images/content_page/'+sContentColor+'_menu_text_bg.gif)}'+
	'.bottomBG {background-image:url(../../images/'+sContentColor+'_bottom.gif)}'+
	'TD.subMenu {color:'+arrLinkBGColor[sContentColor]+'; font-family:'+ff01+'; font-size: '+fs02+';}'+
	'SPAN.subMenu {color:'+arrLinkBGColor2[sContentColor]+'; font-family:'+ff01+'; font-size: '+fs02+';}'+
	'A.subMenu {color:'+arrLinkBGColor[sContentColor]+'; font-family:'+ff01+'; font-size: '+fs02+';text-decoration:none}'+
	'A.subMenu:hover {color:'+arrLinkBGColor2[sContentColor]+'; font-family:'+ff01+'; font-size: '+fs02+';}'+
	'SPAN.Title1 {color:'+arrLinkBGColor3[sContentColor]+'; font-family:'+ff01+'; font-size: '+fs05+'; font-weight: bold;}'+
	'SPAN.Title2 {color:'+arrLinkBGColor3[sContentColor]+'; font-family:'+ff01+'; font-size: '+fs04+'; font-weight: bold;}'+
	''

document.write(''+
	'<STYLE TYPE="text/css">'+
	'A {color:#993333; text-decoration: none;}'+
	'A:hover {color:#FF0000;  text-decoration: underline;}'+

	'TD.menuS {font-family:'+ff01+'; font-size:'+fs03+'; color:#333333}'+
	'A.menuS {font-family:'+ff01+'; font-size:'+fs03+'; color:#333333; text-decoration:none}'+
	'A.menuSS {font-family:'+ff01+'; font-size:'+fs03+'; color:#FFFFFF; text-decoration:none}'+
	'A.menuS:hover {color:#000000}'+

	'A.BottomLink {text-decoration: none; color: #FFFFFF; font-size: '+fs01+';}'+
	'A.BottomLink:active {text-decoration: none; color: #FFFFFF; font-size: '+fs01+';}'+
	'A.BottomLink:hover {text-decoration: none; color: #FFFFFF; font-size: '+fs01+';}'+

	'.Content {color: #000000; font-family:'+ff01+'; font-size: '+fs04+';}'+
	'.Content2 {color: #000000; font-family:'+ff01+'; font-size: '+fs06+';}'+
	'SPAN.Copyright {color: #FFFFFF; font-family:'+ff01+'; font-size: '+fs01+';}'+
	'SPAN.CopyrightEn {color: #FFFFFF; font-family:'+ff01en+'; font-size: '+fs01en+';}'+
	'SELECT {background-color: #FFFFFF; border-bottom: black 1px inset; border-left: black 1px solid; border-right: black 1px inset; border-top: black 1px solid; color: #000000; font-family: Verdana, Arial, Helvetica; font-size: 8pt; vertical-align: top;}'+
	'INPUT.Text {background-color: #FFFFFF; border-bottom: black 1px inset; border-left: black 1px solid; border-right: black 1px inset; border-top: black 1px solid; color: #000000; font-family: Verdana, Arial, Helvetica; font-size: 8pt; maring: 0pt; padding-bottom: 0pt; padding-left: 0pt; padding-right: 0pt; padding-top: 0pt; vertical-align: top;}'+
	'.formArea {font-family:'+ff01+'; font-size: '+fs01+'}'+
	inStyle+
	'</STYLE>'+
	''
)

// The scripts below has been moved to the html page
function init() {
	if (bw.ns4) {
		origWidth=innerWidth;
		origHeight=innerHeight;
		pendingReload=true;
		setInterval("NS4ResizeCheck()",100);
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove=updateIt;
	} else if (bw.ns5) {
		document.body.addEventListener("mousemove", updateIt, false);
	} else {
		document.body.onmousemove=updateIt;
	}
}

function constructSubMenu(name, url, title) {
//	LayerName=name.substr(0,name.length-2);
	tempBegin='<A HREF="'+url+'" TARGET="_top" CLASS="menuS" ';
	tempEnd='>'+title+'</A>&nbsp; ';
	tempMouseOver='ONMOUSEOVER="on(\'cube'+name+'\')" ';
	tempMouseOut='ONMOUSEOUT="off(\'cube'+name+'\')" ';
	z=tempBegin+tempMouseOver+tempMouseOut+tempEnd
	return z
}

function constructMenu(name, top, left, zIndex, smN) {
	z='<DIV ID="'+name+'" STYLE="position:absolute; top:'+top+'px; left:'+left+'px; z-index:'+zIndex+'; visibility:hidden; background-color:#DCDCDC; layer-background-color:#DCDCDC; border:solid 1px #666666; background-image:url(../images/space.gif)">'+
		'<TABLE CELLPADDING="0" CELLSPACING="5" BORDER="0" BGCOLOR="#DCDCDC">'
	for (i=1; i<=smN; i++) {
		z+='<TR><TD><IMG SRC="'+imgDir+'images/content_page/cube.gif" BORDER="0" NAME="cube'+name+'0'+i+'"></TD><TD CLASS="menuS" NOWRAP><P CLASS="menuS">'+eval(name+'0'+i+'Item')+'</P></TD></TR>'
		if (i!=smN) z+='<TR><TD COLSPAN="2" BACKGROUND="'+imgDir+'images/cellbg.gif" HEIGHT="1"><IMG SRC="'+imgDir+'images/cellbg.gif" BORDER="0"></TD></TR>'
	}
	z+='</TABLE>'+
	'</DIV>'
	return z
}

function popup(url, popW, popH) {
	popWidth=popW?popW:400;
	popHeight=popH?popH:580;
	x=Math.round(Math.random()*10000000);
	popName=x.toString();
	window.open(url, popName, "width="+popWidth+",height="+popHeight+",location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no")
}

if (bw.ns4) {
	origWidth=innerWidth;
	origHeight=innerHeight;
	pendingReload=true;
	setInterval("NS4ResizeCheck()",100);
	window.captureEvents(Event.MOUSEMOVE);
}

function selfreload() {
	location.reload();
}

loaded++;