// JavaScript Document

startList = function() {		
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("breadcrumb");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {				
				node.onmouseover=function() {
					this.className+=" open";
				}
				node.onmouseout=function() {
					this.className="secNav";
				}
			}
		}
	}
}

window.onload=startList;

function $(id) {
	return document.getElementById(id);
}

function detectBrowser(){
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion<7) return true
	}
}

function openSubMenu(){
	if	(detectBrowser() == true){
		$("subMenu").style.display = "block";	
	}
}

function closeSubMenu(){
	if	(detectBrowser() == true){
		$("subMenu").style.display = "none";	
	}
}

var shifted=false;
var contW = 541;

function shiftTableLeft(tableID, tableWidth){	
	t_id = document.getElementById(tableID);
	t_w = tableWidth;
	
	if(shifted != true){
		t_id.style.marginLeft = -(t_w - contW)+"px";
	}
	
	shifted = true;
}

function shiftTableRight(tableID, tableWidth){
	t_id = document.getElementById(tableID);
	t_w = tableWidth;
	
	if(shifted == true){
		t_id.style.marginLeft = 0+"px";
	}
	
	shifted = false;
}

function popwindow(url, title, win_w, win_h){
	window.open(url, '', 'resizable=no,width='+win_w+',height='+win_h+',left=100,top=100');
}

function formAddRow(btnNum, container){
	var formContainer = $(container);
	var currRowBtnName = "btnAddRow"+btnNum;
	var currRowBtn = $(currRowBtnName);
	currRowBtn.style.display = "none";
	
	formContainerHeight = 215;
	
	formContainer.style.height = formContainerHeight + btnNum*26 + "px";
}

function setVipStatus(ComPoints){
	var status = String((ComPoints/20)+1);
	var vipStatus = $("vipStatus");
	
	if (isVIP !=1 ){
		if (ComPoints < 100){		
			vipStatus.className = "innerBox vipStatusBackground vipStatus"+status.split(".")[0];
		} else if (ComPoints >= 100) {
			vipStatus.className = "innerBox vipStatusBackground vipStatusCitizen";
		}
	} else {
		vipStatus.className = "innerBox vipStatusBackground vipStatusCitizen";
	}
}

function expandBanking(expandBox, btnExpand){
	$(expandBox).style.display = "block";
	$(btnExpand).style.display = "none";
}

function collapseBanking(expandBox, btnExpand){
	$(expandBox).style.display = "none";
	$(btnExpand).style.display = "inline";	
}

/*---- box expand/collapse GENERIC ----*/
function initRakeTable(tableHolder){
	tableHolder = $(tableHolder);
	
	if (tableHolder.offsetHeight < 480){
		$('mbRakRaceExpand').style.display = "none";
		$('mbRakRaceCollapse').style.display = "none";
	} else {
		tableHolder.style.height = 496 + "px";
	}
}

function expandBox(expandBox, btnExpand){
	$(expandBox).style.height = "auto";
	$(expandBox).style.overflow = "visible";
	$(btnExpand).style.display = "none";
}

function collapseBox(expandBox, btnExpand, startWidth){
	$(expandBox).style.height = startWidth+"px";
	$(expandBox).style.overflow = "hidden";
	$(btnExpand).style.display = "inline";	
}

/*---- DOWNLOAD SCRIPTS -----*/
function dwnload(lang)
{	
	if (down == 1){
		setTimeout("SetTimeouttoOpenDownloadWin(lang)", 0); //from hppopup.js
		//DownloadClientTemp();
	}
}

function getURLVar(urlVarName) {
	var urlHalves = String(document.location).split('?');
	var urlVarValue = '';
	if(urlHalves[1]){
		var urlVars = urlHalves[1].split('&');
		for(var i=0; i<=(urlVars.length); i++){
			if(urlVars[i]){
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0].toLowerCase() == urlVarName.toLowerCase()) {
					urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;
}

var down=getURLVar('d');

var titleTabs=new Array();
titleTabs[0] = "bankTitleTab1";
titleTabs[1] = "bankTitleTab2";
titleTabs[2] = "bankTitleTab3";
titleTabs[3] = "bankTitleTab4";

var contentTabs=new Array();
contentTabs[0] = "bankContentTab1";
contentTabs[1] = "bankContentTab2";
contentTabs[2] = "bankContentTab3";
contentTabs[3] = "bankContentTab4";

function selectTab(tab){

	for (i=0; i<titleTabs.length; i++){
		tabsInactive = $(titleTabs[i]);
		tabsInactive.className = "title title-tab title-tab-unactive";
		
		tabsContentInactive = $(contentTabs[i]);
		tabsContentInactive.style.display = "none";
	}
	
	tabActive = $(titleTabs[tab]);
	tabActive.className = "title title-tab";
	
	if (tab<2){
		tabActive2 = $(titleTabs[tab+2]);
		tabActive2.className = "title title-tab";
	} else {
		tabActive2 = $(titleTabs[tab-2]);
		tabActive2.className = "title title-tab";
	}
	
	tabContentActive = $(contentTabs[tab]);
	tabContentActive.style.display = "block";
	
	if (tab<2){
		tabContentActive2 = $(contentTabs[tab+2]);
		tabContentActive2.style.display = "block";
	} else {
		tabContentActive2 = $(contentTabs[tab-2]);
		tabContentActive2.style.display = "block";
	}
}
