// 플로팅 팝업에 보여줄 데이터 통신을 위한 변수
var float_req;
// AJAX로 특정 페이지의 내용을 가져와 플로팅 팝업으로 보여줌
function pop_float(url,width,height){
	var left , top , float_height , float_width , margin_top;

	if(document.body.offsetWidth){
		left = Math.ceil((document.body.offsetWidth - (width))/2) + 'px';
		top = (Math.ceil((window.screen.height - (height))/2) - 100) + 'px';
	}
	else{
		left = 600 + 'px';
		top = 500 + 'px';
	}

	if(top < 0) top = 0;
	if(left < 0) left = 0;

	if(document.documentElement){
		float_height = document.documentElement.scrollHeight + 'px';
		float_width = document.documentElement.scrollWidth + 'px';
	}
	else if(document.all.tags('html')[0]){
		float_height = document.all.tags('html')[0].scrollHeight + 'px';
		float_width = document.all.tags('html')[0].scrollWidth + 'px';
	}
	else{
		float_height = '150%'
		float_height = window.screen.width + 'px';
	}

	var i;
	if(document.body.getElementsByTagName('select').length){
		for(i = 0;i < document.body.getElementsByTagName('select').length;i++){
			document.body.getElementsByTagName('select')[i].style.visibility = 'hidden';
		}
	}

	if(document.getElementById('pop_float') == null){
		var pop_float = document.createElement('DIV');
		pop_float.id = 'pop_float';
		pop_float.style.position = 'absolute';
		pop_float.style.zIndex = 19999;
		pop_float.style.width = float_width;
		pop_float.style.height = float_height;
		pop_float.style.top = 0;
		pop_float.style.left = 0;
		pop_float.style.backgroundColor = 'black';
		pop_float.style.filter = 'Alpha(Opacity=60)';
		pop_float.style.opacity = '0.6';
		document.body.appendChild(pop_float);
	}

	if(document.getElementById('pop_content') == null){
		var pop_content = document.createElement('DIV');
		pop_content.id = 'pop_content';
		pop_content.style.position = 'absolute';
		pop_content.style.zIndex = 20000;
		pop_content.style.width = width + 'px';
		pop_content.style.height = height + 'px';
		pop_content.style.marginTop = top;
		pop_content.style.marginLeft = left;
		pop_content.style.top = 0;
		pop_content.style.left = 0;
		pop_content.style.backgroundColor = 'white';
		pop_content.innerHTML = '<div style="text-align:center;margin-top:' + (parseInt(height / 2) - 50) + 'px"><img src="/images/loader.gif"></div>';
		document.body.appendChild(pop_content);
	}
	else{
		document.getElementById('pop_content').style.width = width + 'px';
		document.getElementById('pop_content').style.height = height + 'px';
		document.getElementById('pop_content').style.marginTop = top;
		document.getElementById('pop_content').style.marginLeft = left;
		document.getElementById('pop_content').innerHTML = '<div style="text-align:center;margin-top:' + (parseInt(height / 2) - 50) + 'px"><img src="/images/loader.gif"></div>';
	}

	if(window.ActiveXObject){
		try{
			float_req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try{
				float_req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e1){
				float_req = null;
			}
		}
	} 
	else if(window.XMLHttpRequest) float_req = new XMLHttpRequest();
	else float_req = null;

	float_req.onreadystatechange = view_pop_float;
	float_req.open("GET", url, true);
	float_req.send(null);
}

function view_pop_float(){ 
	if(float_req.readyState == 4) {
		if(float_req.status == 200){           
			var xmlDoc = float_req.responseText;
			document.getElementById('pop_content').innerHTML = xmlDoc;
		} 
		else{
			alert("잠시후 다시 시도해 주세요.");
		}
	}
}
//-- AJAX로 특정 페이지의 내용을 가져와 플로팅 팝업으로 보여줌
// 플로팅 팝업 닫기
function close_float(){
	var i;
	if(document.body.getElementsByTagName('select').length){
		for(i = 0;i < document.body.getElementsByTagName('select').length;i++){
			document.body.getElementsByTagName('select')[i].style.visibility = 'visible';
		}
	}

	if(document.getElementById('pop_content')) document.body.removeChild(document.getElementById('pop_content'));
	if(document.getElementById('pop_float')) document.body.removeChild(document.getElementById('pop_float'));
}
