function activeMenu(acm) {
	/*var mn = Array("hmenu", "amenu", "pmenu", "rmenu", "nmenu", "jmenu", "cmenu");
	var len = mn.length;
	for(i = 0; i < len; i++) {
		if(acm == mn[i])
			document.getElementById(acm + "li").className = 'selectedli';
		else
			document.getElementById(mn[i] + "li").className = '';
	}*/
}
function goMod(acm, url, elm) {
	activeMenu(acm);
	goPage(url, elm);
}
function getMod(url) {
	s = url;
	var ss = s.split("#");
	return ss[1].split("/");
}
function setMod(url) {
	var sss = getMod(url);
	switch(sss[0]) {
		case "main":
			activeMenu("hmenu");
			break;
		case "about":
			activeMenu("amenu");
			break;
		case "product":
			activeMenu("pmenu");
			break;
		case "article":
			activeMenu("rmenu");
			break;
		case "news":
			activeMenu("nmenu");
			break;
		case "contact":
			activeMenu("cmenu");
			break;
	}
}
function decodeUrl(url) {
	var sss = getMod(url);
	page = "ajax.php";
	if (sss.length>1) {
		def = "?o=modules&n=" + sss[0];
		for (i=1; i<sss.length; i+=2)
			if (i==1)
				page += def + '&'+sss[i]+'='+sss[i+1];
			else 
				page += '&'+sss[i]+'='+sss[i+1];
	}
	return page;
}
function getPar(ar) {
	rt = "";
	if(ar.length > 3) {
		for (i=3; i<ar.length; i+=2)
			rt += '&'+ar[i]+'='+ar[i+1];
	}
	return rt;
}
function setUrl(url) {
	if (document.getElementById("ifr").contentDocument)
		ioj = document.getElementById("ifr").contentDocument;
	else
		ioj = document.frames['ifr'];
	ioj.location = "main.html?" + (url.split("#"))[1]; 
}
function goPage(url, idelm, sts) {
	window.location.href = url;
	if(typeof(sts) == 'undefined')
		sts = 0;
	if(sts == 0)
		setUrl(url);
	page = decodeUrl(url);
	var sss = getMod(url);
	JAJAX.load("ajax.php?f=left&pp=" + sss[0] + getPar(sss), "lblock");
	JAJAX.load("ajax.php?f=right&pp=" + sss[0] + getPar(sss), "rblock");
	JAJAX.load(page, idelm);
	//cssdropdown.weblink();
	cover.event();
	//JMP.init();
	//JLB.init();
}
function goMenu(url, idelm) {
	window.location.href = url;
	setUrl(url);
	page = decodeUrl(url);
	var sss = getMod(url);
	JAJAX.load("ajax.php?d=blocks&f=menu&n=" + sss[0] + getPar(sss), "mnblock");
	if(document.getElementById("leftbox"))
		JAJAX.load("ajax.php?d=blocks&f=box&pos=1&n=" + sss[0] + getPar(sss), "leftbox");
	if(document.getElementById("rightbox"))
		JAJAX.load("ajax.php?d=blocks&f=box&pos=2&n=" + sss[0] + getPar(sss), "rightbox");
	JAJAX.load(page, idelm);
}
function goText(url, idelm) {
	window.location.href = url;
	setUrl(url);
	page = decodeUrl(url);
	JAJAX.load(page, idelm);
	var sss = getMod(url);
	if(document.getElementById("leftbox"))
		JAJAX.load("ajax.php?d=blocks&f=box&pos=1&n=" + sss[0] + getPar(sss), "leftbox");
	if(document.getElementById("rightbox"))
		JAJAX.load("ajax.php?d=blocks&f=box&pos=2&n=" + sss[0] + getPar(sss), "rightbox");
}
function goLoad(url) {
	goPage(url, "fulltext", 0);
	setTimeout('setMod("' + url + '")', 1000);
}
function reLoad(sts) {
	linktop = window.location.href;
	if(linktop.indexOf("#") <= 0) 
		linktop = "#main/f/home";
	if(typeof(sts) == 'undefined')
		sts = 0;
	goPage(linktop, "fulltext", sts);
	setTimeout('setMod("' + linktop + '")', 1000);
}
JMP = {
	counter: 0,
	init:function() {
		if(document.getElementById('loadmap')) {
			var so = new SWFObject("images/mapa.swf", "Logo", "410", "744", "9", "");
			so.addParam("quality", "hight");
			so.addParam("wmode", "transparent");
			so.addParam("menu", "false");
			so.addParam("scale", "noscale");
			so.addVariable("strTieude", "Chieu hom nay sao nhi?");
			so.addVariable("strNoidung", "Chieu hom nay se di nhau lien tuc toi nua dem cho tam hon sang khoai!");
			so.addVariable("strToado", "300:544");
			so.write("loadmap");
			this.counter = 0;
		} else {
			if(this.counter < 10000) {
				setTimeout('JMP.init()', 1000);
				this.counter += 1000;
			} else
				this.counter = 0;
		}
	}
}
JPT = {
	counter: 0,
	init:function() {
		if(document.getElementById('photos')) {
			jQuery(document).ready(function(){
				jQuery('#photos').galleryView({
					panel_width: 800,
					panel_height: 300,
					frame_width: 100,
					frame_height: 100,
					type: 'sequence',
					timeout: 2000,
					autostop: 0,
					autostopCount: 0
				});
			});
			this.counter = 0;
		} else {
			if(this.counter < 4000) {
				setTimeout('JPT.init()', 1000);
				this.counter += 1000;
			} else
				this.counter = 0;
		}
	}
}
JLB = {
	counter: 0,
	init:function() {
		if(document.getElementById('example0')) {
			$(document).ready(function(){
				$(".example0").colorbox({iframe:true, innerWidth:600, innerHeight:765});
				
				$("#click").click(function(){ 
					$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
					return false;
				});
			});
			this.counter = 0;
		} else {
			if(this.counter < 4000) {
				setTimeout('JLB.init()', 1000);
				this.counter += 1000;
			} else
				this.counter = 0;
		}
	}
}
