function ii_re_tbs()
{
var w2=get_w2()+"%";
var tbs=document.getElementsByTagName("TABLE")
for (var i=0 ;i<tbs.length ;i++)
{
var tb=tbs[i]
if (tb.id=="tb_box")
{
ii_re_tb(tb);
}
}
}
function ii_re_tb(tb)
{
var w2=get_w2();
var w=tb.getAttribute("w");
if(w!=2 &&w!=3 &&w!=4)w=1;
var width=w2*w;
if(width>95)width=96;
tb.style.width=width+"%";
var bl=w2*0.01;
var h2=document.body.offsetWidth*bl *0.5;
var h=tb.getAttribute("h");
if(h!=2 &&h!=3 &&h!=4)h=1;
var height=h2*h;
height=height-11;
tb.style.height=height+'px';
}
function set_width(obj)
{
var tb=tf._gPar("obj.id=='tb_box'",obj);
var w=tb.getAttribute("w");
if(w!=2 &&w!=3 &&w!=4)w=1;
w++;
if(w>4)w=1;
tb.w=w;
ii_re_tb(tb)
var url="../asp/set_index_index.asp?exe=save_a&w="+w+"&id="+tb.box_id;
gid('frame_blank').src=url;
}
function set_height(obj)
{
var tb=tf._gPar("obj.id=='tb_box'",obj);
var h=tb.getAttribute("h");
if(h!=2 &&h!=3 &&h!=4)h=1;
h++;
if(h>4)h=1;
tb.h=h;
ii_re_tb(tb)
var url="../asp/set_index_index.asp?exe=save_a&h="+h+"&id="+tb.box_id;
gid('frame_blank').src=url;
}
function get_w2()
{
var w=document.body.offsetWidth;
var w2= "24";
if (w<770){w2="96"}
else if(w<1170){w2= "48"}
else if(w<1570){w2= "32"}
return w2
}
function del_index_index(obj)
{
var tb=tf._gPar("obj.id=='tb_box'",obj);
if(tb)tb.removeNode(true);
var url="../asp/set_index_index.asp?exe=del&id="+tb.box_id;
gid('frame_blank').src=url;
}
function re_a(obj)
{
var div=tf._gPar("obj.id=='tb_box'",obj);
var ifs=div.getElementsByTagName("IFRAME")[0];
var url=(ifs.src.indexOf("#")>-1)?(ifs.src.split('#')[0]):(ifs.src);
ifs.src=url;
}
function sh_over_div(s_h)
{
var divs=_gName("over_div");
for(var i=0;i<divs.length;i++)
{
if(divs[i].style.display!=s_h)
{
var p=tf._gPar("obj.id=='tb_box'",divs[i]);
var oTop=get_top(divs[i].parentNode);
var oLeft=get_left(divs[i].parentNode);
divs[i].style.display=s_h;
divs[i].style.top=oTop;
divs[i].style.left=oLeft;
divs[i].style.height=divs[i].parentNode.offsetHeight;
}
}
}
function set_tuo_div(downObj)
{
var tuo_div=index_index_tuo_div;
var title=downObj.getElementsByTagName("B")[0].innerText;
tuo_div.style.width=downObj.offsetWidth;
tuo_div.style.height=downObj.offsetHeight;
tuo_div.innerHTML="<b>"+title+"</b>";
tuo_div.style.top=get_top(downObj);
tuo_div.style.left=get_left(downObj);
}
var index_index_isDown=false;
var index_index_moveObj=null;
var index_index_downObj=null;
function index_indexTuo_down()
{
index_index_downObj=event.srcElement;
if(!index_index_downObj)return;
if(index_index_downObj.id!="title_td")
{
index_index_downObj=index_index_downObj.parentNode;
while(index_index_downObj.id!="title_td")
{
index_index_downObj=index_index_downObj.parentNode;
if(!index_index_downObj)return;
}	
}
sh_over_div("block");
set_tuo_div(index_index_downObj);
index_index_isDown=true;
}
var index_index_isMove=false;
function index_indexTuo_move()
{
if(index_index_isDown)
{	
var obj=event.srcElement;
index_index_tuo_div.style.display="block";	
obj=tf._gPar("obj.id=='tb_box'",obj);
index_index_downObj=tf._gPar("obj.id=='tb_box'",index_index_downObj);
if(obj&&obj.id&&obj.id=="tb_box"&&obj!=index_index_downObj)
{
if(!index_index_moveObj||index_index_moveObj.id!="tb_box")
{
index_index_moveObj=obj;
}
hid_dashed_div(obj,"block");
}
index_index_tuo_div.style.top=event.y+10;
index_index_tuo_div.style.left=event.x+10;
index_index_isMove=true;
}
}
function index_indexTuo_up()
{	
if(index_index_isMove)
{
var obj=event.srcElement;
obj=tf._gPar("obj.id=='tb_box'",obj);
if(index_index_downObj!=obj&&obj.id=="tb_box")
{
obj.insertAdjacentElement("beforeBegin",index_index_downObj);
hid_dashed_div(obj,"none")
}
}
if(index_index_isDown||index_index_isMove)
{
sh_over_div("none");
index_index_isMove=false;
index_index_isDown=false;
index_index_moveObj=null;
index_index_downObj=null;
index_index_tuo_div.style.display="none";
}
}
function hid_dashed_div(obj,s_h)
{
obj.rows[0].cells[0].getElementsByTagName("DIV")[0].style.display=s_h;
}
function save_index_index()
{
var o=_gName("tb_box");
var bj=",";
for(var i=0;i<o.length;i++)
{
bj+=o[i].box_id+",";
}
var url="../"+asp_php+"/index_index."+asp_php+"?exe=save_bj&bj="+bj;
tf.gid("frame_blank",window).src=url;
}
function reback_default_bj()
{
var url="../"+asp_php+"/index_index."+asp_php+"?exe=reback_default_bj";
tf.gid("frame_blank",window).src=url;
}
function get_index_index_content()
{
tf.gid("frame_blank",window).src="../"+asp_php+"/index_index."+asp_php;
}
function set_index_index_content(s)
{
s=s.replace(/&#39;/g,"'");
if(s=="")return;
var htm="",arr=s.split("|/tr|"),arr1;
for(var i=0;i<arr.length-1;i++)
{
arr1=arr[i].split("|/td|");
var width=arr1[3];
var height=arr1[4];
htm+="<table name='tb_box' box_id='"+arr1[0]+"' w='"+width+"' h='"+height+"' onMouseOut=hid_dashed_div(this,'none') id='tb_box' cellpadding='0' cellspacing='0'>";
htm+="<tr><td width='12'>";
htm+="<div class='dashed_div'></div></td>";
htm+="<td><table width='100%' height=100%  border='0' cellpadding='0' cellspacing='0' class='border_01'>";
htm+="<tr id=box_tr0>";
htm+="<td style='cursor:move' height='25' onMouseDown='index_indexTuo_down()' id='title_td' width='99%'>&nbsp;";
htm+="<img src='../img/list3.gif'><b>"+arr1[1]+"</b></td>";
htm+="<td><button id=but_lr onclick='set_width(this)' title='调整宽度'></button></td>";
htm+="<td><button id=but_tb onclick=set_height(this) title='调整高度'></button></td>";
htm+="<td width='12'><img title='刷新' src='../img/but_refresh.gif' height=12 onclick=re_a(this) style='CURSOR:hand;margin-right:10px;'></td>";
htm+="<td width='12'>";
htm+="<IMG style='CURSOR:hand' alt='关闭' onclick='del_index_index(this)' src='../img/close.gif' width=12>";
htm+="</td></tr><tr><td class=bg_alpha colspan='5' id='c' valign='top'>";
htm+="<div id=over_div name=over_div></div>";
if(arr1[2].length>4)
{
htm+="<iframe frameborder='0' scrolling=auto allowtransparency=true height=100% width='100%'  src="+arr1[2]+"></iframe>";
}else
{
htm+=tf.ytd_htmlDeCode(arr1[5]);
}
htm+="</td></tr></table></td></tr></table>";
}
var o=tf.gid("index_index_content_div",window);
if(o)o.innerHTML=htm;
ii_re_tbs();
}