﻿

function MakeFlash(Url,Width,Height){  
document.writeln("<div id=\"time\"></div>"); 
document.writeln("<span id=\"tianqi\"><iframe src=\"http://m.weather.com.cn/m/pn5/weather.htm \" allowtransparency=\"true\" width=\"200\" height=\"20\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"></iframe> </span>"); 
  document.writeln("  <form id=fromSearch action=/nSearch.aspx method=post target=_blank runat=server><span id=\"search\"><img src=\"/images/search.jpg\" />站内搜索"); 
       document.writeln("   <input id=s_input name=Tags type=text style=\"border:1px solid #888; width:100px; padding-left:2px\" />"); 
      document.writeln("  <input id=rdoTitle type=radio checked=checked name=rdo class=danxuan value=Title style=\"margin-top:4px;\" /><label>标题</label>"); 
        document.writeln(" <input id=txtTags class=danxuan type=radio name=rdo value='Content' style=\"margin-top:4px;\" /><label>内容</label>"); 
       document.writeln("<input id=s_button  type=submit value='' style=\" background:url(images/searchbj.jpg); width:49px; height:18px; border:0px; line-height:18px; cursor:pointer; margin-left:20px\"  />"); 
  document.writeln("</span></form>"); 
document.writeln("</div><div class=\"flash2\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"" + Width + "\" height=\"160\">");   
document.writeln("<param name=\"movie\" value=\"" + Url + "\" />");   
document.writeln("<param name=\"quality\" value=\"high\" />");       
document.writeln("<param name=\"wmode\" value=\"transparent\" />");
document.writeln("<param name=\"menu\" value=\"false\">");
document.writeln("<embed src=\"" + Url + "\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + Width + "\"  height=\"160\" />");   
document.writeln("</object>");   
document.writeln("<script>window.setInterval(\"var mydate = new Date();time.innerHTML='今天是：'+mydate.toLocaleString() +' 星期'+ mydate.getDay().toString().replace('0','日').replace('1','一').replace('2','二').replace('3','三').replace('4','四').replace('5','五').replace('6','六');\",200);</script>");
} 

    function ResumeError() {
    return true;
}
window.onerror = ResumeError;



var temp, temp2, cookieArray, cookieArray2, cookieCount;

function initiate(){

  cookieCount=0;

  if(document.cookie){

    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();

    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }

  }

  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();

  temp=document.getElementById("containerul");

  for(var o=0;o<temp.getElementsByTagName("li").length;o++){

    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){

      temp2				= document.createElement("span");
      temp2.className			= "symbols";
      temp2.style.backgroundImage	= (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(/images/minus.png)":"url(/images/plus.png)"):"url(/images/plus.png)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        writeCookie();
      }

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)

      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";

      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }

      cookieCount++;

    }
    else{

      temp2				= document.createElement("span");
      temp2.className			= "symbols";
      temp2.style.backgroundImage	= "url(/images/point5.jpg)";

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);

    }

  }

}



function showhide(el){

  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";

  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(/images/minus.png)":"url(/images/plus.png)";

}



function writeCookie(){		// Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.

  cookieArray=new Array()

  for(var q=0;q<temp.getElementsByTagName("li").length;q++){

    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){

        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");

      }
    }

  }

  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();

}

