var pTar;
var settop=0;
var setheight=0;
var i=0;
function dyniframesize(iframename) {
  var region="Y";//同域名;
  var h;
  var height;
  pTar = iframename;
  try{
	 
     h = pTar.mheight;	 
  }catch(e){ }
  
 try{
	  	 height = pTar.Document.body.scrollHeight+1; //height=900;
          pTar.height = height+"px";	
  }
  catch(e){
	   pTar.height=h+"px";  
       region=="N"
  }

   var bb = document.getElementById("body");
   if(region=="Y"){  
		  try{	      
				   if(i==0)
				   {
						var strsetheight=bb.style.height;						//??μ?bodyμ??-ê?éè?????è;
						var strsettop=document.getElementById("bottom").style.top; //??μ?bottomμ??-ê?éè??top;
						if(strsetheight.indexOf("px")>0){					
							setheight =parseInt(strsetheight.substring(0,strsetheight.length-2));
						}
						if(strsettop.indexOf("px")>0){					
							settop =parseInt(strsettop.substring(0,strsettop.length-2));
						}
						i++;
					} 	
					  var bodyheight=0;
					  if(height+60<setheight) {
						  bodyheight=setheight-60;
					  }
						  else{
							  bodyheight=height+60;
						  }		
							
							bb.style.height=bodyheight+"px";	
	
			 }catch(e){
			   //alert(e);
			 }
/*
		   var bbt = document.getElementById("bottom");
		   
		   var bh = bbt.style.height;  
		   if(bh.indexOf("px")>0)
		   {
				bh = bh.substring(0,bh.length-2);
		   }
		   
		   var bt=0;
		   try{
			   bt = parseInt(bh);
		   }catch(e){} 
		   var dt= document.body.scrollHeight;
			bbt.style.top=(dt-bt+20)+"px";
			*/
   }

}
function expand(){
		   var height = pTar.Document.body.scrollHeight+1;
		   pTar.height = height+"px";
		   var bb = document.getElementById("body");
			
		   if(bb){
					 try{
						 var bodyheight=0;
						  if(height+100<setheight) {
							  bodyheight=setheight-100;
						  }
						  else{
							  bodyheight=height+100;
						  }		
						bb.style.height=bodyheight+"px";
					 }catch(e){
					   alert(e);
					 }
					 
		         }
				 
		var bt=bb.style.top;
		if(bt.indexOf("px")>0)
  		{
	   	 bt = bt.substring(0,bt.length-2)-0;
  		}
		
		var bbt = document.getElementById("bottom");  	
		var top=0;
		if((height+bt)<settop){
			top=settop;
		}
		else{
			top=height+bt+150;
		}
		bbt.style.top=top+"px";		
		document.body.scrollHeight=top;
		//parent.document.all(self.name).height = height+bt+150;
}
function Showdevise(oDiv)
{
	window.Layer1.style.display='none';
	window.Layer2.style.display='none';	
	window.Layer3.style.display='none';	

	oDiv.style.display='';	
}
function hidedevise(oDiv)
{
	oDiv.style.display='none';	
}

var onclick=0;
var ochild="";
function expandtree(o)
{
	
 var parent = o.parentElement;
 var child = parent.childNodes;
 
 if(onclick==0){
	 onclick=1;
 }	
 else{
	if(ochild!="")ochild.style.display='none';
 }
 
 
 if(child.length==2){
	ochild= child[1];
   var xx = child[1];

   if(xx.style.display=="none"){
	   
      xx.style.display="block";
   }else
   {
      xx.style.display="none";
   }
   
 }
}
function changetable(o,index1)
{
 var parent = o.parentElement;
 var child = parent.childNodes;
 var name = o.className;
 var index = name.indexOf("_");
 if(index>0){
    name = name.substring(0,index);
 }
 try{
	 for(var i=0;i<child.length;i++)
	 {
	 
	   var node = child[i];
	   if(node.nodeType==1){
	   node.className=name+"_f";
	   }
	 }
     o.className=name+"_b";
 }catch(e){alert(e)};
  //更改更多
  try{
	  var top=o.parentElement.parentElement.parentElement.parentElement; 
	  var ch = top.childNodes[2];
	  var ch1 = ch.childNodes[0].childNodes[1].childNodes;
	  for(var i=0;i<ch1.length;i++){
	     var node = ch1[i];
	     if(i==index1)node.style.display='block';
	     else node.style.display='none';
	  }
  }catch(e){alert(e)};
}
var innerHtml="<div id='editModule' style='position:absolute;dispaly:none;z_index:20;top:200px;'>";
innerHtml+="<iframe allowtransparency='true' width='100%' height='100%' frameborder='0' name='editframe' id='editframe' scrolling=no ></iframe> ";
innerHtml+="</div>";

function editmodule(productid,moduleid,navigateid)
{
var oo = parent.editModule;
if(oo){
  oo.style.display="block";
  var url="/design/editmodule.do?productid="+productid+"&moduleid="+moduleid+"&navigateid="+navigateid;
  parent.editmoduleframe.location=url;
  return true;
}
return false;
}

function delmodule(productid,moduleid,navigateid)
{
var ok= confirm("确实需要删除该功能模块吗?");
if(ok==true){
   xmlHttp=GetXmlHttpObject(delreturn);
   xmlHttp.open("POST", "/design/delmodule.do" , true);
   xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
   var para="productid="+productid+"&moduleid="+moduleid+"&navigateid="+navigateid;
   xmlHttp.send(para);

}

return false;
}

function delreturn()
{
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
         var text = xmlHttp.responseText;
         if(text=="success")
         {
            alert("删除成功");
            window.location = window.location.href;
         }else
         {
            alert("删除失败!");
         }
     }
}

//调整底部和小框架的位置
function afterLoad()
{
 var top = document.getElementById("top");
 if(top!=null)
 {
    top.style.top="0px";
 }

 var bottom = document.getElementById("bottom");
 if(bottom!=null)
 {
  var height = bottom.style.height;
  if(height.indexOf("px")>0)
  {
    height = height.substring(0,height.length-2);
  }
  var h=0;
  try{
    h = parseInt(height);
  }catch(e){}
   
 // bottom.style.top = (document.body.scrollHeight-h)+"px";
 if (self.location != top.location)
  {
     parent.document.all(self.name).height = document.body.scrollHeight;
     
  }
 }
 
}

function locationurl(defaulturl)
{
  var url = window.location.href;
  var index = url.indexOf("defaulturl="); 
  if(index>0){
   // var index2 = url.indexOf("&",index+1);
   // if(index2<0)index2 =url.length;
	var index2=url.length;
    var de = url.substring(index+11,index2);
    if(de!="")defaulturl = de;
  }
if(defaulturl!="")
{
  var oo = document.getElementById("main");
  if(oo){
    main.location = defaulturl;
  }
}
}