/* Prevent background image flickers in IE*/
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

/* Wooo nvr tot i would solve this */

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function nav(){
	navroot = $('nav');
	var defaultstate = 'ORANGETEE'; /*this value will change anyway*/
	var navtab = new Array('nav_home', 'nav_corporate', 'nav_vip' ,'nav_work', 'nav_corporate_chinese');
	
	/*check for default state*/
	for (n=0; n<navtab.length; n++) {
		if ($(navtab[n]).className == 'over') {
			defaultstate = navtab[n];
		}
	}
	
	for (i=0; i<navroot.childNodes.length; i++){
	node = navroot.childNodes[i];
	
	if (node.nodeName == 'LI') {
		node.onmouseover = function() {
			for (j=0; j<navtab.length; j++) {
				this.id == navtab[j] ? this.className = 'over' : $(navtab[j]).className = '';
			}
		}
		node.onmouseout = function() {
			this.className = '';
			$(defaultstate).className = 'over';
		}
	}
	}
}

function switchtab(id) {
	contenttab = new Array(3);
	for (j=0; j<contenttab.length; j++)
	contenttab[j] = new Array(2);
	
	contenttab[0][0] = "content_propsearch";
	contenttab[0][1] = "btn_propsearch";
	contenttab[1][0] = "content_propposts";
	contenttab[1][1] = "btn_propposts";
	contenttab[2][0] = "content_advertise";
	contenttab[2][1] = "btn_advertise";
	
	for (i=0; i<contenttab.length; i++) {
		if (contenttab[i][0] == id) {
			$(id).style.display = 'block';
			$(contenttab[i][1]).className = '';
		} else {
			$(contenttab[i][0]).style.display = 'none';
			$(contenttab[i][1]).className = 'inactive';
		}
	}
}

function switchtab360(id) {
	contenttab = new Array(3);
	for (j=0; j<contenttab.length; j++)
	contenttab[j] = new Array(2);
	
	contenttab[0][0] = "content_propsearch_360";
	contenttab[0][1] = "btn_propsearch_360";
	contenttab[1][0] = "content_propposts_360";
	contenttab[1][1] = "btn_propposts_360";
	contenttab[2][0] = "content_advertise_360";
	contenttab[2][1] = "btn_advertise_360";
	
	for (i=0; i<contenttab.length; i++) {
		if (contenttab[i][0] == id) {
			$(id).style.display = 'block';
			$(contenttab[i][1]).className = '';
		} else {
			$(contenttab[i][0]).style.display = 'none';
			$(contenttab[i][1]).className = 'inactive';
		}
	}
}

function switchtab_corpinfo(id) {
	contenttab = new Array(3);
	for (j=0; j<contenttab.length; j++)
	contenttab[j] = new Array(2);
	
	contenttab[0][0] = "content_corpinfo";
	contenttab[0][1] = "btn_corpinfo";
	contenttab[1][0] = "content_agentpropposts";
	contenttab[1][1] = "btn_agentpropposts";
	contenttab[2][0] = "content_otherresource";
	contenttab[2][1] = "btn_otherresource";
	
	for (i=0; i<contenttab.length; i++) {
		if (contenttab[i][0] == id) {
			$(id).style.display = 'block';
			$(contenttab[i][1]).className = '';
		} else {
			$(contenttab[i][0]).style.display = 'none';
			$(contenttab[i][1]).className = 'inactive';
		}
	}
}

function switchtab_login(id) {
	contenttab = new Array(3);
	for (j=0; j<contenttab.length; j++)
	contenttab[j] = new Array(2);
	
	contenttab[0][0] = "content_loginhere";
	contenttab[0][1] = "btn_loginhere";
	contenttab[1][0] = "content_infocentre";
	contenttab[1][1] = "btn_infocentre";
	contenttab[2][0] = "content_docudownloads";
	contenttab[2][1] = "btn_docudownloads";

	for (i=0; i<contenttab.length; i++) {
		if (contenttab[i][0] == id) {
			$(id).style.display = 'block';
			$(contenttab[i][1]).className = '';
		} else {
			$(contenttab[i][0]).style.display = 'none';
			$(contenttab[i][1]).className = 'inactive';
		}
	}
}

function switchtab_vip(id) {
	contenttab = new Array(3);
	for (j=0; j<contenttab.length; j++)
	contenttab[j] = new Array(2);
	
	contenttab[0][0] = "content_vip";
	contenttab[0][1] = "btn_vip";
	contenttab[1][0] = "content_valuation";
	contenttab[1][1] = "btn_valuation";
	contenttab[2][0] = "content_loanwizard";
	contenttab[2][1] = "btn_loanwizard";
	
	for (i=0; i<contenttab.length; i++) {
		if (contenttab[i][0] == id) {
			$(id).style.display = 'block';
			$(contenttab[i][1]).className = '';
		} else {
			$(contenttab[i][0]).style.display = 'none';
			$(contenttab[i][1]).className = 'inactive';
		}
	}
}

window.onload = nav;

function GotoLocation(ctln)
{
	if (ctln.value.length > 5 )
		openCenterWin(ctln.value,'External', 600, 800)
	else if (ctln.value.length > 0 )
		openCenterWin('Workahome/NRIC_Prompt.asp?ID='+ctln.value, 'New', 600, 800)
}

function openCenterWin(url,winName, theHeight, theWidth)
{
	var theTop=(screen.height/2)-(theHeight/2);
	var theLeft=(screen.width/2)-(theWidth/2);
	//If using the toolbar and status bar
	theTop = theTop - 50
	var features= 'height='+theHeight+',width='+theWidth+',top='+theTop+',left='+theLeft+",scrollbars=yes,location=no,status=yes,toolbar=yes,resizable=yes,menubar=yes";
	theWin=window.open(url, winName, features);	
}
