<!--// 

if(typeof($)!='function'){
	function $(element){
		if(document.getElementById(element)){
			return document.getElementById(element);
		}
		else{
			return null;
		}
	}
}

document.ondblclick=function(eventTag){
    var event=eventTag||window.event;      
    var currentKey=event.charCode||event.keyCode;
	if(event.ctrlKey){	
		str="<HTML>"+document.getElementsByTagName('html').item(0).innerHTML+"</HTML>";
		str="<textarea style='width:100%;height:100%;font-family:Fixedsys;overflow-x:hidden;' readonly>"+str.replace("</textarea","</ textarea")+"</text"+"area>";
		str="<html><head><title>查看源代码</title></head><body style='margin:0;padding:0;overflow:hidden;'>"+str+"</body></html>";
		win=window.open('about:blank','resource','');
		win.document.write(str);
		win.focus();
	}
}


/* 图层相关函数 */

// 加载样式表
function load_layer_style(){
	var scripts=document.getElementsByTagName("script");
	var folder="";
	for(i=0;i<scripts.length;i++){
		script=scripts[i];
		if(script.src && script.src.search(/layer\.js/i)>=0){
			folder=script.src.substring(0,script.src.lastIndexOf("/")+1);
			break;		
		}
	}

	var obj=$("style_layer");
	if(obj==null){
		var obj=document.createElement("link");
		obj.id="style_layer";
		obj.href=folder+"layer.css";
		obj.rel="stylesheet";
		obj.type="text/css";
		document.getElementsByTagName("HEAD").item(0).appendChild(obj);
		//document.getElementsByTagName("HEAD").item(0).insertAdjacentElement("AfterBegin",obj);
	}
}

// 显示图层
function show_layer(str){
	load_layer_style();
	var obj=$("layer_base");
	if(obj==null){
		obj=document.createElement("div");
		obj=document.body.insertAdjacentElement("afterBegin",obj);
		obj.id="layer_base";
	}
	with(obj.style){
		clean="both";
		position="absolute";
		zIndex="1000";
		top="0";
		left="0";
		width="100%";
		height=document.body.scrollHeight<document.body.clientHeight?document.body.clientHeight:document.body.scrollHeight;
		visibility="visible";
		display="block";
	}

	var html="";
	html+="<iframe id='layer_base1' style='position:absolute;z-index:1000;left:0;top:0;width:100%;height:100%;scrolling:no;' src='about:blank' frameborder='0'></iframe>";
	html+="<div	   id='layer_base2' style='position:absolute;z-index:1001;left:0;top:0;width:100%;height:100%;overflow:hidden;'></div>";
	html+="<table  id='layer_container' cellspacing='0' cellpadding='0' border='0' style='position:absolute;top:"+document.body.scrollTop+";left:"+document.body.scrollLeft+";width:"+document.body.clientWidth+";height:"+document.body.clientHeight+";z-index:1002;background:transparent;' oncontextmenu='return false;' onselectstart='return false;'>";
	html+="	<tr>";
	html+="		<td align='"+(arguments.length>=2?arguments[1]:"left")+"' valign='"+(arguments.length>=3?arguments[2]:"top")+"'>";
	html+="			"+str;
	html+="		</td>";
	html+="	</tr>";
	html+="</table>";
	obj.innerHTML=html;

	var _change=function(){
		if($("layer_base")){
			with($("layer_base").style){				
				top="0";
				left="0";
				width="100%";
				height=document.body.scrollHeight<document.body.clientHeight?document.body.clientHeight:document.body.scrollHeight;
			}
		}
		if($("layer_container")){
			with($("layer_container").style){
				top=document.body.scrollTop;
				left=document.body.scrollLeft;
				width=document.body.clientWidth;
				height=document.body.clientHeight;
			}
		}
	}
	document.body.onscroll=_change;
	document.body.onresize=_change;
}

// 显示消息
function show_msg(){
	var type=arguments.length<=1?"tips":arguments[1];
	var obj=$("layer_"+type);
	if(obj==null){
		obj=document.createElement("div");
		obj=document.body.insertAdjacentElement("afterBegin",obj);
		obj.id="layer_"+type;
	}	
	with(obj.style){
		clean="both";
		zIndex="1000";
		textAlign="left";
		visibility="visible";
		filter="BlendTrans(duration=2)";
		display="block";
	}
	if(arguments.length<=2){
		obj.style.position="absolute";
		obj.style.left=document.body.scrollLeft+event.x+12;
		obj.style.top=document.body.scrollTop+event.y+12;
	}
	else{
		arr=arguments[2];
		if(typeof(arr)=="object"){			
			for(key in arr){
				eval("obj.style."+key+"='"+arr[key]+"';");
			}
		}
	}
	obj.innerHTML=arguments[0];
	if(arguments.length<4){		
		obj.filters[0].Apply();
		obj.style.visibility="hidden";
		setTimeout(function(){$("layer_"+type).filters[0].play();},5000);
	}
}

// 显示面板
function show_panel(str,uri){
	var html="<div id='layer_panel'><div class='header'></div><div class='middle'>"+str+"</div><div class='footer'></div><button id='layer_panel_btn' onclick='"+uri+";if(document.all.layer_base){document.all.layer_base.style.visibility=\"hidden\";};'></button></div>";
	show_layer(html,"center");
}

// 显示框架
function show_frame(uri,width,height){
	var w=width==null?800:parseInt(width);
	var h=height==null?600:parseInt(height);
	var html="<div id='layer_frame' style='width:"+(w+12)+" px;height:"+(h+12)+" px;'><iframe width='"+w+"' height='"+h+"' scrolling='0' frameborder='0' src='"+uri+"'></iframe><button id='layer_frame_btn' onclick='if(document.all.layer_base){document.body.removeChild($(\"layer_base\"));};'></button></div>";
	show_layer(html,"center");	
}

// 显示等待
function waiting(){
	var html="<div id='layer_waiting'></div>";
	show_layer(html,"right");
}

//-->
