var maxWebsite = {};

maxWebsite.languages = {
	"zh-cn": "zh-cn"
};

//----------------------------------------------------------
// Show/Hide element
//----------------------------------------------------------
function $toggle(id, bShow) {

	var obj = document.getElementById(id);
	if(!obj) return;

	if(bShow != undefined){
		if(bShow){
			bStyle = 'block';
		}else{
			bStyle = 'none';
		}
	}else{
//		alert(obj.style.display);
		if(obj.style.display != 'none'){
			bStyle = 'none';
		}else{
			bStyle = 'block';
		}
	}

	obj.style.display = bStyle;

}

function $toggleAll(id_prefix, begin, end){
	var show = 'block';
	var i;
	for(i=begin; i<=end; i++){
		var obj = document.getElementById(id_prefix + i);
		if(!obj) continue;
		if(obj.style.display != 'none'){
			show = 'none';
			break;
		}
	}
	for(i=begin; i<=end; i++){
		var obj = document.getElementById(id_prefix + i);
		if(!obj) continue;
		obj.style.display = show;
	}
}


//------------------------------------------------------------------
// Initialize the page
//------------------------------------------------------------------
maxWebsite.init = function(){
	maxWebsite.checkCurrentPage();
}


//------------------------------------------------------------------
// Check Current Page and highlight it
//------------------------------------------------------------------
maxWebsite.checkCurrentPage = function(){

	var currentPage = document.location.pathname.toString();
	currentPage = currentPage.substr(currentPage.lastIndexOf("/")+1, currentPage.length);
	if(currentPage.length < 1) return;

	var objMenu = document.getElementById("navMenu");
	if(!objMenu) return;

	var objs = objMenu.getElementsByTagName("A");
	for(var i=0; i<objs.length; i++){
		var page = objs[i].href;
		page = page.substr(page.lastIndexOf("/")+1, page.length);
		if(page == currentPage) objs[i].className = "buttons-active";
	}

}

function get_cb(req) {
	return function() {
		if (req.readyState == 4){
			maxWebsite.updateCounterBinder(req);
			req = null;
		}
	};
}

window.onload = maxWebsite.init;