// JavaScript Document
function wind(width,height){
	this.pz=document.createElement("div");
	this.wid=document.createElement("div");
	this.Shadow=document.createElement("div");
	this.head=document.createElement("div");
	this.Title=document.createElement("div");
	this.CtrButton=document.createElement("div");
	this.ld=document.createElement("div");
	this.ifram=document.createElement("div");
	this.showcontent=document.createElement("div");
	this.content=document.createElement("div");
	this.butt1=document.createElement("div");
	this.butt2=document.createElement("div");
	this.butt3=document.createElement("div");
	this.sL;
	this.sT;
	this.oW;
	this.oH;
	this.width=width;
	this.height=height;
	this.cstype;
	this.type="close";
	this.model;
	this.tempStr="";
	this.tempPic=null;
	this.mousex;
	this.mousey;
}
wind.prototype.createwind=function(type,model,obj){
	window._widObj=obj;
	this.cstype=type;
	this.type=type;
	this.model=model;
	this.pz.setAttribute("className","pz");
	this.wid.setAttribute("className","wid");
	this.Shadow.setAttribute("className","Shadow");
	this.Shadow.setAttribute("class","Shadow");
	this.head.setAttribute("className","winhead");
	this.pz.setAttribute("class","pz");
	this.wid.setAttribute("class","wid");
	this.head.setAttribute("class","winhead");
	//this.head.onmousedown=this.down;
	//this.head.ondrag=this.drag;
	this.content.setAttribute("className","content");
	this.Title.setAttribute("className","Title");
	this.CtrButton.setAttribute("className","CtrButton");
	this.ld.setAttribute("className","ld");
	this.showcontent.setAttribute("className","showcontent");
	this.ifram.setAttribute("className","ifram");
	
	this.content.setAttribute("class","content");
	this.Title.setAttribute("class","Title");
	this.CtrButton.setAttribute("class","CtrButton");
	this.ld.setAttribute("class","ld");
	this.showcontent.setAttribute("class","showcontent");
	this.ifram.setAttribute("class","ifram");
	this.ifram.innerHTML="<iframe style='width:100%;height:100%'></iframe>";
	this.ifram.style.left=0;
	this.ifram.style.top=0;
	this.butt1.setAttribute("className","butt1");
	this.butt2.setAttribute("className","butt2");
	this.butt3.setAttribute("className","butt4");
	this.butt1.setAttribute("class","butt1");
	this.butt2.setAttribute("class","butt2");
	this.butt3.setAttribute("class","butt4");
	this.butt3.onclick=this.close;
	this.CtrButton.appendChild(this.butt1);
	this.CtrButton.appendChild(this.butt2);
	this.CtrButton.appendChild(this.butt3);
	this.wid.appendChild(this.head);
	this.wid.appendChild(this.ifram);
	this.wid.appendChild(this.content);
	this.head.appendChild(this.Title);
	this.head.appendChild(this.CtrButton);
	this.content.appendChild(this.ld);
	this.content.appendChild(this.showcontent);
	document.body.appendChild(this.pz);
	document.body.appendChild(this.wid);
	document.body.appendChild(this.Shadow);
}
		
wind.prototype.getsceen=function(){
	this.sL=document.documentElement.scrollLeft;
	this.sT=document.documentElement.scrollTop;
	this.oW=document.documentElement.clientWidth-2;
	this.oH=document.documentElement.clientHeight-2;
}	
wind.prototype.show=function(){
	//document.documentElement.style.overflowY="hidden";
	this.wid.style.display="block";
	this.Shadow.style.display="block";
	this.content.style.display="block";
	this.pz.style.display="block";
	if(this.type=="min" || this.type=="close"){
		this.type=this.cstype;
	}
	this.getsceen();
	if(this.type=="max"){
		this.Shadow.style.display="none";
		this.wid.style.width=this.oW+"px";
		this.wid.style.height=this.oH+"px";
		this.butt2.setAttribute("className","butt3");
		this.butt2.setAttribute("class","butt3");
		this.butt2.onclick=this.hywid;
	}else if(this.type=="hy"){
		if(this.width>this.oW){
			this.wid.style.width=this.oW+"px";
		}else{
			this.wid.style.width=this.width+"px";
		}
		if(this.height>this.oH){
			this.wid.style.height=this.oH+"px";
		}else{
			this.wid.style.height=this.height+"px";
		}
		this.Shadow.style.width=this.wid.style.width;
		this.Shadow.style.height=this.wid.style.height;
		this.butt2.setAttribute("className","butt2");
		this.butt2.setAttribute("class","butt2");
		this.butt2.onclick=this.maxwid;
	}
	this.butt1.setAttribute("className","butt1");
	this.butt1.setAttribute("class","butt1");
	this.butt1.onclick=this.minwid;
	this.content.style.width=this.wid.offsetWidth-12+"px";
	this.content.style.height=this.wid.offsetHeight-this.head.offsetHeight-12+"px";
	this.content.style.top=this.head.offsetHeight+5+"px";
	this.content.style.left=5+"px";
	this.showcontent.style.height=this.content.style.height;
	this.showcontent.style.width=this.content.style.width;
	this.pz.style.width=this.oW+"px";
	this.pz.style.height=this.oH+"px";
	this.setwz();
	
}
wind.prototype.setmin=function(){
	this.content.style.display="none";
	this.wid.style.width=this.Title.offsetWidth+this.CtrButton.offsetWidth;
	this.wid.style.height=this.head.offsetHeight;
	this.Shadow.style.width=this.wid.style.width;
	this.Shadow.style.height=this.wid.style.height;
	this.butt1.setAttribute("className","butt3");
	this.butt1.setAttribute("class","butt3");
	this.butt1.onclick=this.hywid;
	this.butt2.setAttribute("className","butt2");
	this.butt2.setAttribute("class","butt2");
	this.butt2.onclick=this.maxwid;
	this.pz.style.display="none";
	this.pz.style.width="1px";
	this.pz.style.height="1px";
	document.documentElement.style.overflowY="auto";
}
wind.prototype.setwz=function(){
	this.pz.style.left=this.sL;
	this.pz.style.top=this.sT+"px";
	if(this.type=="min"){ 
	this.wid.style.left=this.sL+"px"
	this.wid.style.top=this.sT+this.oH-26+"px"
	}else{
	this.wid.style.left=this.sL+(this.oW-parseInt(this.wid.style.width))/2+"px";
	this.wid.style.top=this.sT+(this.oH-parseInt(this.wid.style.height))/2+"px";
	}
	this.Shadow.style.left=parseInt(this.wid.style.left)+5+"px";
	this.Shadow.style.top=parseInt(this.wid.style.top)+5+"px";
	if(parseInt(this.Shadow.style.left)+parseInt(this.Shadow.offsetWidth)-this.sL>this.oW || parseInt(this.Shadow.style.top)+parseInt(this.Shadow.offsetHeight)-this.sT>this.oH) this.Shadow.style.display="none";
	this.ld.style.top=(this.content.offsetHeight-parseInt(this.ld.offsetHeight))/2+"px";
}
wind.prototype._load=function(tit,url){
	this.showcontent.innerHTML="";
	this.Title.innerHTML=tit;
	this.pz.style.display="block";
	this.wid.style.display="block";
	this.Shadow.style.display="block";
	this.content.style.display="block";
	this.ld.style.display="block";
	this.showcontent.style.display="none";
	this.show();
	switch(this.model){
		case "image":
		this.showcontent.style.textAlign="center";
		this.loadpic(url);
		break;
		case "page":
		this.showcontent.style.textAlign="left";
		this.loadpage(url);
		break;
		case "content":
		this.showcontent.style.textAlign="left";
		this.showcontent.innerHTML=url;
		this.ld.style.display="none";
		this.showcontent.style.display="block";
		break;
		default:
		alert("Error!");
	}
	//alert(document.body.innerHTML);
}
wind.prototype.loadpic=function(pic){
	var ld=this.ld;
	var showcontent=this.showcontent;
	var tempimg=new Image();
	tempimg.onload=function (){
		if(this.complete||this.readyState=="complete"){
		//getpage("BrowseDegree.asp?type=product&id="+id);
		ld.style.display="none";
		showcontent.appendChild(tempimg);
		showcontent.style.display="block";
		}
	}
	tempimg.src=pic;
}
wind.prototype.loadpage=function(url){
	var ld=this.ld;
	var showcontent=this.showcontent;
	var oXHR = zXmlHttp.createRequest();
	oXHR.open("get", url, true);
	oXHR.onreadystatechange = function () {   
		if (oXHR.readyState == 4) {
			if (oXHR.status == 200) {
				ld.style.display="none";
				showcontent.innerHTML=oXHR.responseText;
				showcontent.style.display="block";
			}else{
				alert("¼ÓÔØÐÅÏ¢³ö´í£¡");
				_widObj.close();
			}
		}
	};    
	oXHR.send(null);    
}
wind.prototype.hywid=function(){
	_widObj.type="hy";
	_widObj.show();
}
wind.prototype.maxwid=function(){
	_widObj.type="max";
	_widObj.show();
}
wind.prototype.minwid=function(){
	_widObj.type="min";
	_widObj.setmin();
	_widObj.hd();
}
wind.prototype.close=function(){
	_widObj.type="close";
	_widObj.pz.style.display="none";
	_widObj.wid.style.display="none";
	_widObj.Shadow.style.display="none";
	//document.documentElement.style.overflowY="auto";
}
wind.prototype.hd=function(){
	this.getsceen();
	_widObj.setwz();
	//this.wid.style.left=this.sL;
	//this.wid.style.top=this.sT+this.oH-this.wid.offsetHeight-20;
}
wind.prototype.drag=function(){
	//alert(_widObj.mousex)
	_widObj.wid.style.left=parseInt(_widObj.wid.style.left)+(event.x-_widObj.mousex);
}
wind.prototype.down=function(){
	_widObj.mousex=event.x;
	_widObj.mousey=event.y;
}
window.onscroll=function(){
	if(isObj(window._widObj)){
		if(_widObj.wid.style.display=="block"){
			_widObj.hd();
		}
	}
}
window.onresize=function(){
	if(isObj(window._widObj)){
		if(_widObj.wid.style.display=="block"){
			if(_widObj.type!="min"){
				_widObj.show();
			}else{
				_widObj.hd();
			}
		}
	}
}
function isObj(str)
 {
  if(str==null||typeof(str)=='undefined')   return false;
  return true;
 }