var bPanelArr = [];
var numOfPanels = 3;
var activeMenu = null;

function togglePanel(i){
	i--;
	bPanelArr[i] = eval(!bPanelArr[i]);
	//writeCookies();
	setPanel(i);
}

/*
function writeCookies() {
	if (supportsCookies() == true) { 
		var cookieDate=new Date();
		cookieDate.setDate(cookieDate.getDate()+7);
		for( var i=0; i< numOfPanels; i++){
			setCookie('bPanel'+(i+1), bPanelArr[i], cookieDate, '/');
		}	
	}

}
*/
function setPanel( idx ) {
	idx++; 
	
	if(eval(bPanelArr[idx-1])){
		$("#cPanelDiv"+idx).fadeOut();
		$("#colT"+idx).hide();
		$("#expT"+idx).show();
	} else {
		$("#cPanelDiv"+idx).fadeIn();
		$("#colT"+idx).show();
		$("#expT"+idx).hide();		
	}
	matchHeight();
}
function initPanels(){	
	for( var i=0; i< numOfPanels; i++){
		bPanelArr[i] = false;
		if (supportsCookies() == true) { 
			var bValue = getCookie('bPanel'+(i+1));
			if( bValue != null  ){
				bPanelArr[i] =bValue;
			}
		}
		setPanel(i);
	}
}

function initiate() {
	initPanels();

	if( activeMenu != null && activeMenu != -1 ){
		enterMenu(activeMenu);
	}
	matchHeight();
	//set active SubMenu
	$("#NavContainer a").click(function () {	
      	$(this).toggleClass("current");
		activeSubmenu = $(this);
    });

}

function matchHeight() {

/*
	var h1 = parseInt($("#cPanel").height());
	var h2 = parseInt($("#contentPanel").height());

	if( h1 > h2 ) {
		$("#contentPanel").height(h1-64);
	} else {
		$("#cPanel").height(h2);
	}
*/
}

window.onload = initiate;

