﻿
/* 输出编辑内嵌框架 */
function WriteFuncList() {
    document.writeln("<div id='floatdiv' class='floatdiv' style='display:none;width:700px;height:400px; position:absolute;z-index:100;'>");
    document.writeln("<table class='Dydrag' style='height:100%;' ><tr><td></td><td style='float:left;cursor:move;' onmousedown=\"moveIfmDiv(event,'floatdiv');\"><span id='floatdivname' style='float:left;cursor:move;' >管理项目</span>");
    document.writeln("<span onclick=closeIfrDiv('floatdiv') class='ResFresh'><img src=\"/images/close.gif\" /></span>");
    document.writeln("<div id='divFS' onclick=\"FullScreen('floatdiv',this)\" class='ResFresh'>全屏</div>");
    document.writeln("<span onclick='history.go(1)' class='ResFresh'><img src=\"/images/go.gif\" /></span>");
    document.writeln("<span onclick='history.go(-1)' class='ResFresh'><img src=\"/images/back.gif\" /></span>");
    document.writeln("</td><td></td></tr><tr><td></td><td style='height:100%;'>");
    document.writeln("<iframe name=\"Managermain\" id=\"Managermain\"  frameborder=\"0\"  style=\"width: 100%;height:100%\" scrolling=\"auto\"></iframe>");
    document.writeln("</td><td></td></tr><tr><td></td><td></td><td><div style=\"position:absolute;height:15px;width:6px;cursor:nw-resize;z-index:200;\" onmouseover=\"OnMouseOver(this,'floatdiv')\"></div></td></tr></table></div>");
}
//页面显示全屏
function FullScreen(_sID, obj) {
    var oObj = $(_sID); //显示层
    var arrySize = getPageSize(); //全屏的高度和宽度
    if (obj.innerHTML == "全屏") {
        oObj.style.height = document.body.clientHeight;  //arrySize[1];
        oObj.style.width = document.body.clientWidth;  //arrySize[0];
        oObj.style.left = 0;
        if (document.documentElement.clientHeight != 0) {
            temp = document.documentElement.scrollTop;
        }
        else {
            temp = document.body.scrollTop;
        }
        oObj.style.top = temp; //窗体的顶部位置
        obj.innerHTML = '退出全屏';
        document.body.style.overflow = "visible";
    }
    else {
        if (document.documentElement.clientHeight != 0) {
            temp = document.documentElement.scrollTop + (document.documentElement.clientHeight - 400) / 2;
        }
        else {
            temp = document.body.scrollTop + (document.body.clientHeight - 400) / 2;
        }
        if (temp < 10) // 高度超出窗体时
        {
            temp = 50;
        }
        oObj.style.width = '700';
        oObj.style.height = '400';
        oObj.style.left = arrySize[0] / 2 - 400;
        oObj.style.top = temp; //窗体的顶部位置
        obj.innerHTML = '全屏';
        document.body.style.overflow = "auto";
    }
}
function SetTipInfo(TipMess)
{
    document.writeln("<div id='TipID' class='floatdiv' style='display:none;width:100%;position:absolute;z-index:100;'>");
    document.writeln("<p>"+ TipMess +"<br />");
    document.writeln("<img src=\"images/loading/loading.gif\" style=\"width: 16px; height: 16px\" /> ");
    document.writeln("<img src=\"images/loading/loading_wide.gif\" style=\"width: 220px; height: 19px\" /></p>");   
    document.writeln("</div>");
   
    var arrySize = getPageSize();
	var oObj = $('TipID');
	//创建一个DIV,改名为 overlay 这个是透明的层	
	var oDiv =document.createElement("div");
	oDiv.id = "overlay";
	document.body.appendChild(oDiv);
	var overlay = $("overlay");
	overlay.style.height = arrySize[1];
	overlay.style.width = arrySize[0];
	oObj.style.left = arrySize[0] / 2 - 200;

	var mytemp; //层显示的位置根据情况改变
	if(document.documentElement.clientHeight != 0)
	{
	   temp = document.documentElement.scrollTop+(document.documentElement.clientHeight)/2;
	}
	else{
	   temp = document.body.scrollTop+(document.body.clientHeight)/2;
	}
   
	if(temp <10)
	{
	    temp = 50;
	}
	oObj.style.top = temp;
	
	oObj.style.display = "block";
	overlay.style.display = "block";
	overlay.style.zindex = oObj.style.zindex - 1;

}
function CloseTip(_sID)
{
    var oObj = $(_sID);
	var overlay = $("overlay");	
	if(overlay != null)
	{
		overlay.outerHTML = "";
	}
	oObj.style.display = "none";
}
function AutoHeight(obj,objid)
{ 
    var h = document.frames(objid).document.body.scrollHeight+20;
    if(h > 400)
    {
        obj.height = h;
    }
    else
    {
        obj.height = 500;
    }
}
/* 关闭层 */
function closeIfrDiv(_sID)
{
	var oObj = $(_sID);
	var overlay = $("overlay");	
	if(overlay != null)
	{
		overlay.outerHTML = "";
	}
	oObj.style.display = "none";
	var ifr = $("Managermain");
	ifr.src='';
	
}
/* 显示层 */
function CheckIframeUrl(_sID,Iurl,Iname,W,H)
{
	var arrySize = getPageSize();
	var oObj = $(_sID);
	//创建一个DIV,改名为 overlay 这个是透明的层	
	var oDiv =document.createElement("div");
	var ifr = $("Managermain");
	$('floatdivname').innerHTML = Iname;
	ifr.src = Iurl;
	oDiv.id = "overlay";
	document.body.appendChild(oDiv);
	var overlay = $("overlay");
	overlay.style.height = arrySize[1];
	overlay.style.width = arrySize[0];
    oObj.style.width = W;
    oObj.style.height = H;
	oObj.style.left = arrySize[0] / 2 - W/2 ;

	var mytemp; //层显示的位置根据情况改变
	if(document.documentElement.clientHeight != 0)
	{
	   temp = document.documentElement.scrollTop+(document.documentElement.clientHeight-H)/2;
	}
	else{
	   temp = document.body.scrollTop+(document.body.clientHeight-H)/2;
	}
   
	if(temp < 0)
	{
	    temp = 50;
	}
	oObj.style.top = temp;
	
	oObj.style.display = "block";
	overlay.style.display = "block";
	overlay.style.zindex = oObj.style.zindex - 1;
	return false;
}
function SetIframeSite(_sID,W,H)
{
    var arrySize = getPageSize();
	var oObj = $(_sID);
    oObj.style.width = W;
    oObj.style.height = H;
	oObj.style.left = arrySize[0] / 2 - W/2 ;
	var mytemp; //层显示的位置根据情况改变
	if(document.documentElement.clientHeight != 0)
	{
	   temp = document.documentElement.scrollTop+(document.documentElement.clientHeight-H)/2;
	}
	else{
	   temp = document.body.scrollTop+(document.body.clientHeight-H)/2;
	}
   
	if(temp < 0)
	{
	    temp = 50;
	}
	oObj.style.top = temp;	
	return false;
}
//取得页面大小
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
/* 移动层 */
function moveIfmDiv(event, _sId)
{
	var oObj = $(_sId);	
	oObj.onmousemove = mousemove;
	oObj.onmouseup = mouseup;
	oObj.setCapture ? oObj.setCapture() : function(){};
	oEvent = window.event ? window.event : event;
	var dragData = {x : oEvent.clientX, y : oEvent.clientY};
	var backData = {x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)};
   
	function mousemove()
	{
		var oEvent = window.event ? window.event : event;
		var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
		var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
		oObj.style.left = iLeft;
		oObj.style.top = iTop;
		dragData = {x: oEvent.clientX, y: oEvent.clientY};  
	}
   
	function mouseup()
	{
		var oEvent = window.event ? window.event : event;
		oObj.onmousemove = null;
		oObj.onmouseup = null;
		if(oEvent.clientX < 1 || oEvent.clientY < 1)
		{
			oObj.style.left = backData.y;
			oObj.style.top = backData.x;
		}
	    oObj.releaseCapture ? oObj.releaseCapture() : function(){};
	}
}

function ContentSize(size) 
{ 
    var obj=$("content");     
    obj.style.fontSize=size+"px"; 
} 
 function sub(btnid)
{
    if(event.keyCode == 13)
    {
       $(btnid).click();
    }
}
