/* Template JavaScript */
/* Version: 2.0 || Date: 2005-12-1 || Author: Cyrano */
/* //W3C//DTD XHTML 1.0 Transitional//EN */

/* Flash Interface */
	function SetXmlPath(FlashId,Path)
	{
		document.all[FlashId].SetVariable("XmlPath",Path);
	}
	function SetFlashWidth(FlashId)
	{
		if(screen.availWidth<1000)
		FlashWidth = 400;
		else
		FlashWidth = 500;
		document.all[FlashId].SetVariable("StageWidth", FlashWidth);
	}
	
/* Show & Hide */
	function SwitchTable(ControlId,num)
	{
		for (var i=1;i<num+1;i++)
		{document.all["tbl"+i].style.display = "none";}
		document.all["tbl"+ControlId].style.display="";
	}
	function Switch(ControlId)
	{
		if (document.all[ControlId].style.display == "none")
		document.all[ControlId].style.display="";
		else
		document.all[ControlId].style.display="none";
	}
	function SwitchPic(pic, picsrc1, picsrc2)
	{
      if (pic.src.indexOf(picsrc1) !=-1 )
           pic.src = pic.src.replace(picsrc1,picsrc2);
      else 
           pic.src = pic.src.replace(picsrc2,picsrc1);
	}
/* Frame Application */
	function SwitchFrameRows(FrameId)
	{
		if(parent.document.all[FrameId].rows!='*,20')
		parent.document.all[FrameId].rows='*,20';
		else
		parent.document.all[FrameId].rows='*,30%';
	}
	
	function SwitchFrameCols(FrameId)
	{
		if(parent.document.all[FrameId].cols!='*,250')
		parent.document.all[FrameId].cols='*,250';
		else
		parent.document.all[FrameId].cols='*,0';
	}
	
	function GotoFrame(PageName1,PageName2)
	{	
		top.frames["Main"].location.href=PageName1;
		top.frames["Left"].location.href=PageName2;
	}
	function resizeIframe()
	{
		if(window.name != "")
		{
		i = parent.document.all[window.name];
		iHeight = document.body.scrollHeight;
			i.style.height = iHeight + "px";
	}
	}
	
/* OnMouseOver-Out */
	function OnMouseOverPicSrc(pic)
	{
		var picPath = pic.src.substring(0,pic.src.lastIndexOf("."));
		var picExt = pic.src.substring(pic.src.lastIndexOf("."));
		pic.src = picPath + "Over" + picExt;
	}
	
	function OnMouseOutPicSrc(pic)
	{
		var picPath = pic.src.substring(0,pic.src.lastIndexOf("Over"));
		var picExt = pic.src.substring(pic.src.lastIndexOf("."));
		pic.src = picPath + picExt;
	}
	
	function OnMouseOverClass(obj)
	{
		var classNameOver=obj.className+'Over';
		obj.className=classNameOver;
	}
	
	function OnMouseOutClass(obj)
	{
		var classNameOrgin=obj.className.substring(0,obj.className.lastIndexOf("Over"));
		obj.className=classNameOrgin;
	}
	
	function OnClickPicSrc(pic,num)
	{ //alert(pic.id);
      var picPath = pic.src.substring(0,pic.src.lastIndexOf("."));
	  var picExt = pic.src.substring(pic.src.lastIndexOf("."));
	  if (picPath.substring(picPath.length-4)!='Over')
	  {
		  for(var i=1; i < num+1;i++)
        {
			top.TopBar.document.getElementById("img"+i).src =picPath.substring(0,picPath.lastIndexOf("_"))+"_"+i+picExt;
 			//top.TopBar.document.getElemAttribute("onMouseOver","OnMoentById("img"+i).setuseOverPicSrc(this)");
			//top.TopBar.document.getElementById("img"+i).setAttribute("onMouseOut","OnMouseOutPicSrc(this)");
		}
		pic.src = picPath + "Over" + picExt;
		//pic.removeAttribute("onMouseOver");
		//pic.removeAttribute("onMouseOut");
		}
	}
	
/* Window Resize */
	
	function WindowMax()
	{
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth,screen.availHeight);
	}
	function WindowMin()
	{
		screenleft = (screen.availWidth - 800)/2;
		screentop = (screen.availHeight - 570)/2;
		window.moveTo(screenleft,screentop);
		window.resizeTo(800,570);
	}
	
/* WebPart Loading Message */
	function LoadMsgSWF(swfSrc)
    {
		document.write("<center><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='80' height='50'>");
		document.write("<param name='movie' value='" + swfSrc + "' />");
        document.write("<param name='quality' value='high' />");
        document.write("<param name='wmode' value='transparent' />");
        document.write("</object></center>");     
    }
	
	function LoadMsgGIF(gifSrc)
    {
		document.write("<center><img src='"+gifSrc+"' border='0' /> ");
		document.write("数据正在载入中...</center>");
    }

/* Web2.0 Div Auto Height */

function CheckAutoHeight()
{
    var length = Frame.childNodes.length;
    for(var i=1;i<length-1;i++)
    {
        var cLength = Frame.childNodes[i].childNodes.length;
        var maxHeight = 0;
        for(var j=0;j<cLength;j++)
        {
            var rcts = Frame.childNodes[i].childNodes[j].getClientRects();
            var height = rcts[0].bottom-rcts[0].top;
            if(height>maxHeight)
                maxHeight = height;
        }
        for(var j=0;j<cLength;j++)
            Frame.childNodes[i].childNodes[j].style.height=maxHeight+"px"
    }
}

function SetAutoHeight()
{
    if(document.readyState=="complete")
        CheckAutoHeight();
    else
        setTimeout("SetAutoHeight();",100);
}
