// JavaScript Document
function change(obj)
{
for(var i=1;i<20;i++)
{
if(document.getElementById("menu"+i+"_"+1+"_td")==null)
continue;
for(var j=1;;j++)
{
if(document.getElementById("menu"+i+"_"+j+"_td")==null)
break;
document.getElementById("menu"+i+"_"+j+"_td").style.background="url(images/menu_3.gif)";
document.getElementById("menu"+i+"_"+j+"_td_span").style.color="#000000";
}
}
document.getElementById(obj).style.background="url(images/menu_2.gif)";
document.getElementById(obj+"_span").style.color="#ffc04e";
  document.cookie="curentpage="+obj;
}
function clearcookie()
{
  parent.document.cookie="curentpage=nopage";
}
function refreshpagesy()
{
if(screen.width==1024)
{
    window.document.body.style.width = 1004;
}
else if(screen.width==1280)
{
     window.document.body.style.width = 1255;
}
else if(screen.width >= 1440) 
{
    window.document.body.style.width = 1420;
}
else 
{
    window.document.body.style.width = 780;
}
}
function refreshpage()
{
if(screen.width==1024)
{
    window.document.body.style.width = 1004;
}
else if(screen.width==1280)
{
     window.document.body.style.width = 1255;
}
else if(screen.width >= 1440) 
{
    window.document.body.style.width = 1420;
}
else 
{
    window.document.body.style.width = 780;
}
refreshmenupage();
}
String.prototype.Trim=function()
{
	return this.replace(/^\s+/g,"").replace(/^s+$/g,"");
}
function GetCookie(key)
{
		var cookie=document.cookie;
		var cookieArray=cookie.split(';');
		var getvalue="";
		for(var i=0;i<cookieArray.length;i++)
		{
			if(cookieArray[i].substr(0,key.length)==key)
			{
				getvalue=cookieArray[i].Trim().substr(key.length+1);
				break;
			}
		}
	return getvalue;
}

function reinitIframe(){

var iframe = document.getElementById("iframe");

try{

var bHeight = iframe.contentWindow.document.body.scrollHeight;

var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;

var height = Math.max(bHeight, dHeight);

iframe.height =  height;

}catch (ex){}
}

window.setInterval("reinitIframe()", 5500);
function lefttree(menu)
{
for(var i=1;i<20;i++)
{
if(document.getElementById("menu"+i+"_"+1)==null)
continue;
if("menu"+i!=menu)
{
for(var j=1;;j++)
{
if(document.getElementById("menu"+i+"_"+j)==null)
break;
document.getElementById("menu"+i+"_"+j).style.display="none"
}
}
}
for(var s=1;s<30;s++)
{
if(document.getElementById("menu"+s)==null)
continue;
document.getElementById("menu"+s).style.color="#000000";
}
for(var k=1;k<30;k++)
{
if(document.getElementById(menu+"_"+k)==null)
continue;
if(document.getElementById(menu+"_"+k).style.display=="block")
{document.getElementById(menu+"_"+k).style.display="none";}
else
{document.getElementById(menu+"_"+k).style.display="block";
 document.getElementById(menu).style.color="#ffc04e";
}
}
}
function refreshmenupage()
{
var keyvalue=GetCookie("curentpage");


    if(keyvalue!=null&&keyvalue!=""&&keyvalue.substring(0,4)=="menu")
    {
		
     if(document.getElementById(keyvalue)!=null)
     {
		   // change('menu1_1_td');sendXml(this,'消息警报 ','http://172.21.196.201:8010/zy/xxjb/index.html')
         src=document.getElementById(keyvalue).attributes["onclick"].value.split(',')[2].Trim();
		 src=src.substr(1,src.length-3);
	      
		 
		if(src.substring(0,4)=="http")
		 {
			lefttree(keyvalue.split('_')[0]);
			 change(keyvalue)
			if(parent.document.getElementById("content")==null) return;
			parent.document.getElementById("content").src=src;
		
			}
      }
    }
    else
 	 parent.document.all.content.src="http://www.xmeteo.xm.fj.cn/mh/yw/YuBaoChanPin/DuanShiYuBao/duanshiyubaoIndex.html";
}










function sendXml(obj,para1,para2)
{

try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
    if(4==xmlhttp.readyState){
        if (200==xmlhttp.status)
        {
  
            if(xmlhttp.responseText=="true")
            {
			
				if(para1=="台风信息 ")
					//parent.window.location.href=para2;
					 window.open(para2);
				else
					parent.document.all.content.src=para2;
					 document.cookie="curentpage="+obj.id;
	        }
            else
            {
              alert("页面不能访问，原因可能是1、您尚未被授权使用该页面；2、您尚未登陆。若无法解决问题，请与管理员联系！");
            //  parent.document.all.content.src="login.aspx";
			   document.cookie="curentpage=nologin";

            }
        }
        else
        {
        alert("站点选择不正确，请和管理员联系或者您的浏览器不支持此功能，请重新确认！");
        parent.document.all.content.src="/login.aspx";
        }
    }
}
xmlhttp.open("post","/checkright.aspx?menu="+encodeURI(para1),false);
//xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.setRequestHeader("Content-Type","text/html; encoding=gb2312");
xmlhttp.send();

}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}