function toLogin(){
	new Ajax.Request('/sub/login.jsp',{method: 'post',parameters: 'username='+$F('username')+'&password='+$F('password')+'&timestemp='+(new Date()).getTime(), onComplete: function(originalRequest){eval(originalRequest.responseText);}});
}
function toLogout(){
	new Ajax.Request('/sub/logout.jsp',{method: 'post', onComplete: function(originalRequest){eval(originalRequest.responseText);}});
}

function jumPageForSub(str,val){
	$(str).value=val;
	$('npage').value="1";
	$("listForm").submit();
}

function jumPage(num){
	$('npage').value=num;
	$("listForm").submit();
}

function checkSeachBox(flag){
	if(flag=="+"){
		if($F("searchKeys")=="请输入检索词"){
			$("searchKeys").value="";
		}
	}
	else if(flag=="-"){
		if($F("searchKeys")==""){
			$("searchKeys").value="请输入检索词";
		}
	}
}
function searchSubmit(){
	if($F("searchKeys")=="请输入检索词" || $F("sreachKeys")==""){
		alert("请输入检索词");
		$("searchKeys").focus();
		return false;
	}
	else return true;
}

function getPointer(tag){
	var nX=0,nY=0;
	if(!$(tag))return {left:0,top:0};
	else {
		var elt = $(tag);
		while(elt!=null && elt!=document.body){
			nX += elt.offsetLeft;
			nY += elt.offsetTop;
			elt = elt.offsetParent;
		}
		return {left:nX,top:nY};
	}
}

var a1,a2,sNum=0,eLeft=0;
var items = new Array();
items[0] = ['1','电子信息'];
items[1] = ['2','汽　车'];
items[2] = ['3','钢　铁'];
items[3] = ['4','石　化'];
items[4] = ['5','食　品'];
items[5] = ['6','纺　织'];
items[6] = ['53','生物医药'];
items[7] = ['54','节能环保'];
items[8] = ['55','先进制造'];
items[9] = ['56','新 材 料'];
function changeMain(num){
	$('inforsub_3').update('<center>loading......</center>');
	$('inforsub_5').update('<center>loading......</center>');
	$('inforsub_8').update('<center>loading......</center>');
	$('inforsub_4').update('<center>loading......</center>');
	$('inforsub_7').update('<center>loading......</center>');
	$('inforsub_6').update('<center>loading......</center>');
	$('inforsub_9').update('<center>loading......</center>');
	$('inforsub_10').update('<center>loading......</center>');
	var path0 = "type=icid&linkcss=c666&width=356&rows=7&pics=/images/index06.gif&line=true&showclass=true&classid="+num;
	if(num==0)path0 = "type=inforid&linkcss=c666&width=356&rows=7&pics=/images/index06.gif&line=true&showclass=true&classid="+num;
	new Ajax.Updater('inforsub_3', '/sub/indexList.jsp?'+path0+'&inforid=3&lenstr=18', {method:'post',evalScripts:true});
	new Ajax.Updater('inforsub_5', '/sub/indexList.jsp?'+path0+'&inforid=5&lenstr=18', {method:'post',evalScripts:true});
	new Ajax.Updater('inforsub_8', '/sub/indexList.jsp?'+path0+'&inforid=8&lenstr=16', {method:'post',evalScripts:true});
	new Ajax.Updater('inforsub_4', '/sub/indexList.jsp?'+path0+'&inforid=4&lenstr=16', {method:'post',evalScripts:true});
	new Ajax.Updater('inforsub_7', '/sub/indexList.jsp?'+path0+'&inforid=7&lenstr=16', {method:'post',evalScripts:true});
	new Ajax.Updater('inforsub_6', '/sub/indexList.jsp?'+path0+'&inforid=6&lenstr=16', {method:'post',evalScripts:true});
	new Ajax.Updater('inforsub_9', '/sub/indexCorpList.jsp?'+path0+'&inforid=9&lenstr=18', {method:'post',evalScripts:true});
	new Ajax.Updater('inforsub_10', '/sub/indexProductList.jsp?'+path0+'&inforid=10&lenstr=18', {method:'post',evalScripts:true});
}
function createMenu(){
	if(!$("m1") || $("m1")==null){
		var m1 = document.createElement("div");
		m1.id="m1";

		var m1_title = document.createElement("div");
		m1_title.id="m1_title";

		var m1_content = document.createElement("div");
		m1_content.id="m1_content";

		document.body.appendChild(m1);
		$("m1").appendChild(m1_title);
		$("m1").appendChild(m1_content);
		$("m1").setStyle({left:'0px'});

	}
}

function menu1_submenu(elt){
	var min_left = getPointer("main_menu_body").left;
	var max_left = min_left+$("main_menu_body").getWidth();

	var nX = (elt.getWidth()/2);
	nX += getPointer(elt).left;

	$("m1").style.display="block";
	//showObj();

	var m1Width = $("m1").getWidth();
	nX = nX-(m1Width/2);

	if(nX<min_left)nX=min_left;
	else if((nX+m1Width)>max_left)nX=max_left-m1Width;

	$("m1").setStyle({left:nX+'px',display:'block'});
	//eLeft = nX;
	//setMenuLeft();
}

function setOpacity(obj,opc){
	if(opc==null || opc=='')opc="0";
	if($(obj))
	with($(obj).style){
		display='block';
		filter='alpha(opacity='+opc+')';
		MozOpacity=''+opc/100+'';
		Opacity=''+opc/100+'';
	}
}

function showObj(){
	sNum = sNum+20;
	if (sNum > 80){clearInterval(a1);}
  	else {
  		if(sNum>80)sNum = 80;
		setOpacity("m1",sNum)
		a1 = setInterval("showObj()",1);
	}

}
function hideObj(){
	if($("m1")){
		with($("m1").style){
			display='none';
			//filter='alpha(opacity=0)';
			//MozOpacity='0';
			//Opacity='0';
		}
		sNum=0;
	}
}

function setMenuLeft(){
	var nleft = parseInt($("m1").style.left);

	if(nleft>eLeft){
		nleft = nleft -10;
		nleft = (nleft-eLeft)>10?nleft:eLeft;
	  	$("m1").style.left = nleft+"px";
		a2 = setInterval("setMenuLeft()",500);
	}
	else if(nleft<eLeft){
		nleft = nleft + 10;
		nleft = (eLeft-nleft)<10?eLeft:nleft;
	  	$("m1").style.left = nleft+"px";
		a2 = setInterval("setMenuLeft()",500);
	}
	else {
		clearInterval(a2);
	}
}


$(document).observe('mouseover',function(event){
	var elt = Event.element(event);
	if(elt.className == 'menu'){
		menu1_submenu(elt);
		$("m1_title").update(elt.innerHTML+":");
		var temp = '';
		for(var i=0;i<items.length;i++){
			if(i>0)temp += ' | ';
			if(elt.getAttribute("root")=="cyl")
				temp += '<span class="menu1sub" onclick=window.location.href="/'+elt.getAttribute("root")+'/index.jsp?classid='+items[i][0]+'";>'+items[i][1]+'</span>';
			else
				temp += '<span class="menu1sub" onclick=window.location.href="/'+elt.getAttribute("root")+'/index.html?lisType=infor&inforid='+elt.getAttribute("inforid")+'&classid='+items[i][0]+'";>'+items[i][1]+'</span>';
		}

		$("m1_content").update(temp);
	}

	while(elt && elt.id && elt!=document.body){
		if(elt.className == 'menu' || elt.className == 'menu1sub')break;
		else if(elt.id=="m1" || elt.id=="main_menu_body_content")break;
		else elt = elt.offsetParent;
	}
	if(elt.className != 'menu' && elt.className != 'menu1sub' && (elt.id!="m1" && elt.id!="main_menu_body_content")){
		hideObj();
	}
});
