// Preloading Mouseover Buttons
//---------- For the Main Nave Bar.
loadImage1 = new Image();
loadImage1.src = "http://www.cn.moldmasters.com/img/menu_home_over.gif";
staticImage1 = new Image();
staticImage1.src = "http://www.cn.moldmasters.com/img/menu_home_norm.gif";

loadImage2 = new Image();
loadImage2.src = "http://www.cn.moldmasters.com/img/menu_solutions_over.gif";
staticImage2 = new Image();
staticImage2.src = "http://www.cn.moldmasters.com/img/menu_solutions_norm.gif";

loadImage3 = new Image();
loadImage3.src = "http://www.cn.moldmasters.com/img/menu_support_over.gif";
staticImage3 = new Image();
staticImage3.src = "http://www.cn.moldmasters.com/img/menu_support_norm.gif";

loadImage4 = new Image();
loadImage4.src = "http://www.cn.moldmasters.com/img/menu_sales_over.gif";
staticImage4 = new Image();
staticImage4.src = "http://www.cn.moldmasters.com/img/menu_sales_norm.gif";

loadImage5 = new Image();
loadImage5.src = "http://www.cn.moldmasters.com/img/menu_case_over.gif";
staticImage5 = new Image();
staticImage5.src = "http://www.cn.moldmasters.com/img/menu_case_norm.gif";

loadImage6 = new Image();
loadImage6.src = "http://www.cn.moldmasters.com/img/menu_about_over.gif";
staticImage6 = new Image();
staticImage6.src = "http://www.cn.moldmasters.com/img/menu_about_norm.gif";

loadImage7 = new Image();
loadImage7.src = "http://www.cn.moldmasters.com/img/menu_resources_over.gif";
staticImage7 = new Image();
staticImage7.src = "http://www.cn.moldmasters.com/img/menu_resources_norm.gif";

function preselect_topnavbar(){
	var sPathNav = window.location.pathname;
	var sPathNav2 = sPathNav.substring(sPathNav.lastIndexOf('/') + 1);
	var finalStrNav = sPathNav;
	
	finalStrNav = finalStrNav.replace(sPathNav2, "");
	document.write("<span style='color:white;'>"+ finalStrNav +"</span>");
	
	switch(finalStrNav) {	
		case '/industry/': document['image1'].src = loadImage1.src; break
		case '/needs/': document['image1'].src = loadImage1.src; break
		case '/product/product/': document['image2'].src = loadImage2.src; break
		case '/product/solution/': document['image2'].src = loadImage2.src; break
		case '/product/temperature/': document['image2'].src = loadImage2.src; break
		case '/support/': document['image3'].src = loadImage3.src; break
		case '/support/facilities/': document['image6'].src = loadImage6.src; break
		case '/case/': document['image5'].src = loadImage5.src; break
		case '/about/': document['image6'].src = loadImage6.src; break
		case '/resources/': document['image7'].src = loadImage7.src; break
		case '/sales/africa/': document['image4'].src = loadImage4.src; break
		case '/sales/asia/': document['image4'].src = loadImage4.src; break
		case '/sales/australia/': document['image4'].src = loadImage4.src; break
		case '/sales/europe/': document['image4'].src = loadImage4.src; break
		case '/sales/northamerica/': document['image4'].src = loadImage4.src; break
		case '/sales/southamerica/': document['image4'].src = loadImage4.src; break
		default:   ; break     
	}
}
//-------- 
//--------End of Preloading buttons
// --BEGINING OF THE DROPDOWN MENUS'S
//***********************************************
//* DD Tab Menu script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
//* This notice MUST stay intact for legal use
//* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
//***********************************************/
// --------- FIRST MENU FOR MAIN IMAGE BAR TO DROP DOWN TO SUB CATS ------------//
var initialtab2=[1, "0"]
var turntosingle2=0
var disabletablinks2=0
var previoustab2=""

//if (turntosingle2==1)
//document.write('<style type="text/css">\n#submenus{display: none;}\n</style>')

function expandcontent2(cid2, aobject2, i){
if (disabletablinks2==1)
aobject2.onclick=new Function("return false")
if (document.getElementById){
highlighttab2(aobject2)
if (turntosingle2==0){
if (previoustab2!="")
document.getElementById(previoustab2).style.display="none"
document.getElementById(cid2).style.display="block"
previoustab2=cid2
SetTopImageOver(i)
}
}
}

function expandcontent_pre(cid2, aobject2, i){
if (disabletablinks2==1)
aobject2.onclick=new Function("return false")
if (document.getElementById){
highlighttab2(aobject2)
if (turntosingle2==0){
if (previoustab2!="")
document.getElementById(previoustab2).style.display="none"
document.getElementById(cid2).style.display="block"
previoustab2=cid2
SetTopImageOver(i)
}
}
}

function highlighttab2(aobject2){
if (typeof tabobjlinks2=="undefined")
collecttablinks2()
for (i=0; i<tabobjlinks2.length; i++)
tabobjlinks2[i].className=""
aobject2.className="current"
}

function collecttablinks2(){
var tabobj2=document.getElementById("tablist2")
tabobjlinks2=tabobj2.getElementsByTagName("A")
}

function do_onload2(){
collecttablinks2()
expandcontent2(initialtab2[1], tabobjlinks2[initialtab2[0]-1])
}

//if (window.addEventListener)
//window.addEventListener("load", do_onload2, false)
//else if (window.attachEvent)
//window.attachEvent("onload", do_onload2)
//else if (document.getElementById)
//window.onload=do_onload2
//---------------------------------------------------
//------------END OF FIRST MENU-----------------------

// --------- SECOND MENU DROP DOWNS ------------//
//----------------------------------------------//
var initialtab=[1, "0"]
var turntosingle=0
var disabletablinks=0
var previoustab=""

//if (turntosingle==1)
//document.write('<style type="text/css">\n#tabcontentcontainer{display: none;}\n</style>')

function expandcontent(cid, aobject){

if (disabletablinks==1)
aobject.onclick=new Function("return false")
if (document.getElementById){
highlighttab(aobject)
if (turntosingle==0){
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
previoustab=cid
}
}
}

function highlighttab(aobject){
if (typeof tabobjlinks=="undefined")
collecttablinks()
for (i=0; i<tabobjlinks.length; i++)
tabobjlinks[i].className=""
aobject.className="current"
}

function collecttablinks(){
var tabobj=document.getElementById("submenus")
tabobjlinks=tabobj.getElementsByTagName("A")
}

function do_onload(){
collecttablinks()
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}

//if (window.addEventListener)
//window.addEventListener("load", do_onload, false)
//else if (window.attachEvent)
//window.attachEvent("onload", do_onload)
//else if (document.getElementById)
//window.onload=do_onload
//-- END OF SECOND MENU -->

<!--IMAGE UTILITIES-->
function SetTopImageOver(i) {
	if (i!=1)
		document.image1.src=staticImage1.src;
	if (i!=2)
		document.image2.src=staticImage2.src;
	if (i!=3)
		document.image3.src=staticImage3.src;
	if (i!=4)
		document.image4.src=staticImage4.src;
	if (i!=5)
		document.image5.src=staticImage5.src;
	if (i!=6)
		document.image6.src=staticImage6.src;
	if (i!=7)
		document.image7.src=staticImage7.src;
}


document.write("<STYLE>");
document.write("#tabcontentcontainer{");
document.write("width:840px;");
if(navigator.appName == "Microsoft Internet Explorer")
	document.write("height:18px;");
else
	document.write("height:20px;");
document.write("background-color:#e5e9f1;");
document.write("}");
document.write("</STYLE>");

<!--END OF IMAGE UTILITIES-->

function selected_menu(sub1_open,sub2_open,sub1_hl,sub2_hl) {
// Expand First Menu
expandcontent2(sub1_open, this, 1);
// Expand Second Menu
expandcontent(sub2_open, this);
// Highlight 1st sub menu background
document.getElementById(sub1_hl).style.backgroundColor ="#e5e9f1";
// Highlight 2nd sub menu background
document.getElementById(sub2_hl).style.backgroundColor ="#cbd3e3";
//var previoustab2=sub1_open
//var previoustab=sub2_open
}

function selected_menu_sub1(sub1_open,sub1_hl) {
// Expand First Menu
expandcontent_pre(sub1_open, this, 0);
// Expand Second Menu
// Highlight 1st sub menu background
document.getElementById(sub1_hl).style.backgroundColor ="#e5e9f1";
// Highlight 2nd sub menu background
//var previoustab2=sub1_open
//var previoustab=sub2_open
}