function activeMenu(acm) {
	if (acm == "")
	{
		acm = document.getElementById("idactive").value;			
	}
	else
	{
		document.getElementById("idactive").value = acm;
	}
	var mn = Array("main", "about", "product", "news", "library", "media" ,"emp", "contact");
	var len = mn.length;
	for(i = 0; i < len; i++) {
		if(acm == mn[i])
			document.getElementById(acm).className = 'active';
		else
			document.getElementById(mn[i]).className = 'normal';
	}
}

function normalMenu(acm) {
	document.getElementById(document.getElementById("idactive").value).className = 'normal';
	document.getElementById(acm).className = 'over';
}

function overMenu(acm) {
	document.getElementById(acm).className = 'normal';
}

function normalsubMenu(acm) {
	document.getElementById(acm).className = 'over_sub';
}

function oversubMenu(acm) {
	document.getElementById(acm).className = 'normal_sub';
}

function normalsubMenu_1(acm) {
	document.getElementById(acm).className = 'over_sub_1';
}

function oversubMenu_1(acm) {
	document.getElementById(acm).className = 'normal_sub_1';
}


function goMod(acm, url, elm) {
	activeMenu(acm);
	goPage(url, elm);
}
function getMod(url) {
	s = url;
	var ss = s.split("#");
	return ss[1];
}
function setMod(url) {
	var sss = getMod(url);
	switch(sss[0]) {
		case "main":
			activeMenu("main");
			break;
		case "about":
			activeMenu("about");
			break;
		case "product":
			activeMenu("product");
			break;
		case "news":
			activeMenu("news");
			break;
		case "library":
			activeMenu("library");
			break;
		case "media":
			activeMenu("media");
			break;
		case "emp":
			activeMenu("emp");
			break;
		case "contact":
			activeMenu("contact");
			break;
	}
}

function langGo(lng) {
	window.location.href= "http://"+window.location.hostname+"/pnl/"+lng+"/main/f/home/index.html";
}

function decodeUrl(url) {
	var sss = getMod(url);
	page = "/pnl/" + document.getElementById("langcurrid").value + "/" + sss + "/index.html";
	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) {
	if(url.indexOf("#") <= 0 )
		window.location.href = url;
	else
		window.location.href = decodeUrl(url);
}
function goMenu(url, idelm) {
	if(url.indexOf("#") <= 0 )
		window.location.href = url;
	else
		window.location.href = decodeUrl(url);
}
function goText(url, idelm) {
	if(url.indexOf("#") <= 0 )
		window.location.href = url;
	else
		window.location.href = decodeUrl(url);
}
function goLoad(url) {
	goPage(url, "fulltext", 0);
}


//Slide
var sqolauqua = 0;
var mmenu_tren = 0;
var mmenu_trai = 0;
var loop, next, prev, t;

function autoSlide()
{
	if (next >0)
	{
		blkmember.next();
		next--;
		prev=next;
	}
	else
		if (prev < loop)
		{
			blkmember.prev();
			prev++;
		}
		else
			next=loop;
	t = setTimeout('autoSlide()', 2000);
}

function initEvent() {	
	if(document.getElementById('tiles') && document.getElementById('numpicloop')) {
		blkmember.init(document.getElementById('numpicloop').value, document.getElementById('tiles'));
		loop = document.getElementById('numpicloop').value;
		next = loop;
		//Kiem tra slide
		if (t)	clearTimeout(t);
		autoSlide();
		sqolauqua = 0;
	} else {
		if(sqolauqua < 10000) {
			setTimeout('initEvent()', 1000);
			sqolauqua += 1000;
		} else
			sqolauqua = 0;
	}
}



function goList(url) {
	JAJAX.load(url, "list_other");
}


function submitPost(frs) {
	if(frs.elements["fullname"].value == "") {
		alert(frs.elements["m_fullname"].value + '!');
		frs.elements["fullname"].focus();
		return false;
	} else
	if(frs.elements["email"].value == "") {
		alert(frs.elements["m_email"].value + '!');
		frs.elements["email"].focus();
		return false;
	} else
	if(!JSTR.isemail(frs.elements["email"].value)) {
		alert( frs.elements["m_erroremail"].value + '!');
		frs.elements["email"].focus();
		return false;
	} else
	if ((frs.elements["phone"].value!= "") && (!JSTR.isphone(frs.elements["phone"].value))) {
		alert(frs.elements["m_errorphone"].value + '!');
		frs.elements["phone"].focus();
		return false;
	} else
	if (frs.elements["question"].value == "") {
		alert(frs.elements["m_question"].value + '!');
		frs.elements["question"].focus();
		return false;
	} else
	{
		frs.action = 'http://ymyceramic.com.vn/ajax.php?o=modules&n=support&f=support_post&action=submit';
		AIM.submit(frs, {'onComplete': JCB.complete});
		return true;
	}
}

//Map
JMAP = {
	counter: 0,
	init:function() {
		if(document.getElementById('map_canvas')) {
			initialize();
		} else {
			if(this.counter < 4000) {
				setTimeout('JMAP.init()', 1000);
				this.counter += 1000;
			} else
				this.counter = 0;
		}
	}
}

//slide tin
var time4=0;
function initGallery() {	
	if(document.getElementById('gallery')) {
		time4=0;
		slideShow();
		if (g) clearTimeout(y);
	} else {
		if(time4 < 10000) {
			g=setTimeout('initGallery()', 1000);
			time4 += 1000;
		}else
			time4 = 0;
	}
}




