function updateAclass(obj,tag,className){
	for(var i=0;i<obj.length;i++){
			if(obj[i].tagName.toLocaleLowerCase()==tag){
				obj[i].className=className;
			}
	}
}

window.onload=function (){
	updateAclass(document.getElementById("main_menu").children,"a","a_clr");
	for(var i=1;i<5;i++){
		updateAclass(document.getElementById("son_meun_"+i).children,"a","a_clr");
		document.getElementById("son_meun_"+i).style.display="none";
	}
	menuOut();
	
}

function showThisMenu(obj){
	var mainMenus=document.getElementById("main_menu").children;
	updateAclass(mainMenus,"a","a_clr");
	obj.className="over";
	sonMenusShow(getParam("p",obj.getAttribute("onClick")+""));
}	


function sonMenusShow(id){
	
	for(var i=1;i<5;i++){
		var sonObj=document.getElementById("son_meun_"+i);
		if(sonObj!=null){
			sonObj.style.display="none";
		}
	}
	var sonBlockObj=document.getElementById("son_meun_"+id);
	if(id!=null&&id!=""&&sonBlockObj!=null){
		sonBlockObj.style.display="block";
	}
}


function menuOut(){
	var mainMenus=document.getElementById("main_menu").children;
	var p=getParam("p");
	updateAclass(mainMenus,"a","a_clr");
	if(p==null||p==""){
		p=0;
	}
	mainMenus[parseInt(p)].className="over";
	sonMenusShow(p);	
}


function getParam(ags,urlstr){
	var thisUrl="";
	var ps=null;
	if(urlstr==null||urlstr=="")
		thisUrl=window.parent.location.href;
	else
		thisUrl=urlstr;
	var be=thisUrl.indexOf("?");
	var en=thisUrl.lastIndexOf("'");

	if(en<0){
		en=thisUrl.lastIndexOf("\"");
	}
	if(en<0){
		en=thisUrl.length;
	}
	if(be>0&&thisUrl.length>be){
	    ps=thisUrl.substring(be+1,en).split('&');
	}
	if(ps!=null&&ps.length>0){
		for(var i=0;i<ps.length;i++){
			var ab=ps[i].split("=");
			if(ab.length>1&&ab[0]==ags){
				return ab[1];
			}
		}
	}
	return null;
}


function setparentUrl(url){
	window.parent.location.href=url;
}

function dosubmit(theUrl) {
	document.forms[0].action=theUrl;
	document.forms[0].target="_parent";
	document.forms[0].submit();
}
