
function HtmlChar(Url,Title,oheight,owidth){
	var htmlDiv = '';
	htmlDiv +='<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:8px solid #7E5A40;cursor:move;" onMousedown="StartDrag(this,event)" onMouseup="StopDrag(this)" onMousemove="Drag(this,event)">';
	htmlDiv +='<tr>';
	htmlDiv +='<td style="padding:0px; font-size:12px;" >';
	htmlDiv +='<table width="100%" border="0" cellspacing="0" cellpadding="0" >';
	htmlDiv +='<tr>';
	htmlDiv +='<td height="30" style="padding-left:5px;border-bottom:1px solid #B59B88;color:#7E5A40;font-size:17px;font-weight:bold;">'+Title+'</td>';
	htmlDiv +='<td width="10%" align="right" style="border-bottom:1px solid #B59B88;background:#fff;padding-right:5px;" ><img onclick="closeLayer();" style="cursor:pointer;" src="/images/x.jpg" alt="CLOSE" title="CLOSE"/></td>';
	htmlDiv +='</tr>';
	htmlDiv +='</table>';
	htmlDiv +='<table width="100%" border="0" cellspacing="0" cellpadding="0" >';
	htmlDiv +='<tr>';
	htmlDiv +='<td><iframe id="PopIframe1" src="'+Url+'" scrolling="no" style="height:'+oheight+'px;" frameborder="0" width="'+owidth+'px" ></iframe></td>';
	htmlDiv +='</tr>';
	htmlDiv +='</table>';
	htmlDiv +='</td>';
	htmlDiv +='</tr>';
	htmlDiv +='</table>';
	//alert(htmlDiv);
	return htmlDiv;
}

function openLayer(Url,Title,owidth,oheight,isbg){
	var arrayPageSize   = getPageSize();
	var arrayPageScroll = getPageScroll();

	if (!document.getElementById("popupAddr")){
		var popupDiv = document.createElement("div");
		popupDiv.setAttribute("id","popupAddr")
		popupDiv.style.position = "absolute";
		//popupDiv.setAttribute("style","float:left");
		popupDiv.style.border = "0px solid #000000"; 
		popupDiv.style.background = "#fff";
		popupDiv.style.zIndex = 99;
		var bodyBack = document.createElement("div");
		bodyBack.setAttribute("id","bodybg")
		bodyBack.style.position = "absolute";
		bodyBack.style.width = "100%";
		bodyBack.style.height = (arrayPageSize[1] + 1000 + 'px');
		bodyBack.style.zIndex = 98;
		bodyBack.style.top = 0;
		bodyBack.style.left = 0;
		if(isbg!="n"){
		bodyBack.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
		bodyBack.style.opacity = 0.5;
		bodyBack.style.background = "#000";
		}
		var InDiv = document.createElement("div");
		InDiv.setAttribute("id","Inndiv");
		document.body.appendChild(InDiv);
		var mybody = document.getElementById("Inndiv");
		insertAfter(popupDiv,mybody);
		insertAfter(bodyBack,mybody);
	}
	document.getElementById("bodybg").style.display = "";
	var popObj=document.getElementById("popupAddr")
	popObj.innerHTML = HtmlChar(Url,Title,oheight,owidth);
	popObj.style.display = "";
	popObj.style.width = owidth;
	popObj.style.height = oheight;
	var topc=arrayPageScroll[1] + (arrayPageSize[3] - 35 - oheight) / 2; 
	popObj.style.top = topc < 0 ? 0 : topc + 'px'; 
	popObj.style.left = (arrayPageSize[0] - 20 - owidth) / 2 + 'px';
}



function getConSize(conId){
	var conObj=document.getElementById(conId)
	conObj.style.position = "absolute";
	conObj.style.left=-1000+"px";
	conObj.style.display="";
	var arrayConSize=[conObj.offsetWidth,conObj.offsetHeight]
	conObj.style.display="none";
	return arrayConSize;
}


function insertAfter(newElement,targetElement){
	var parent = targetElement.parentNode;
	if(parent.lastChild == targetElement){
		parent.appendChild(newElement);
	}else{
		parent.insertBefore(newElement,targetElement.nextSibling);
	}
}

function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}

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){
		sScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth,windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	var pageWidth,pageHeight
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

function closeLayer(){
	document.getElementById("popupAddr").style.display = "none";
	document.getElementById("bodybg").style.display = "none";
	return false;
}


var move=false,oldcolor,_X,_Y;

function StartDrag(obj,oEvent){ 
	if(obj.setCapture){
		obj.setCapture();
	}else if(window.captureEvents){
		window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); 
	}
	oldcolor=obj.style.backgroundColor;
	obj.style.background="#fff";
	move=true;
	var parentwin=document.getElementById("popupAddr");
	
	oEvent=oEvent||window.event;
	_X=parentwin.offsetLeft-oEvent.clientX
	_Y=parentwin.offsetTop-oEvent.clientY

}


function Drag(obj,oEvent){
	if(move){
		var parentwin=document.getElementById("popupAddr");
		oEvent=oEvent||window.event;
		parentwin.style.left=oEvent.clientX+_X+"px";
		parentwin.style.top=oEvent.clientY+_Y+"px";
	}
}

function StopDrag(obj){
	obj.style.background=oldcolor;
	if(obj.releaseCapture){
		obj.releaseCapture();
	}else if (window.captureEvents) {
		window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); 
		document.onmouseup = null; 
		document.onmousemove = null; 
	} 
	move=false;
}

function HiddenInput()
{
 var objs = document.getElementsByTagName("select"); 
 for(i=0;i<objs.length;i++)
 {
  objs[i].style.display='none';
 }

}

function ShowInput()
{
 var objs = document.getElementsByTagName("select"); 
 for(i=0;i<objs.length;i++)
 {
  objs[i].style.display='';
 }

}
