function getXMLHttpRequest() {
 if (window.ActiveXObject) {
  try {
   return new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e) {
   try {
    return new ActiveXObject("Microsoft.XMLHTTP");
   } catch(e1) { return null; }
  }
 } else if (window.XMLHttpRequest) {
  return new XMLHttpRequest();
 } else {
  return null;
 }
}

var req;
var pop_width;
var pop_height;
var add_height;
function pop_float(url,width,height,add_h){
	pop_width = width;
	pop_height = height;

	if(add_h){
		add_height = add_h;
	}
	else{
		add_height = 0;	
	}

	if(url = '/pop_login.asp'){
		if(document.curr_page_form){
			url = url + '?return_page=' + document.curr_page_form.curr_page.value;
		}
		else{
			url = url + '?return_page=/';
		}
		
	}
    req = getXMLHttpRequest();
	req.onreadystatechange = view_popup;
    req.open("GET", url, true);
    req.send(null);
	view_popup();
}

function view_popup(){ 
	if(req.readyState == 4) {
		if(req.status == 200){           
            var xmlDoc = req.responseText;

			var left;
			var top;

			if(document.documentElement){
				float_height = (document.documentElement.scrollHeight + add_height) + 'px';
			}
			else if(document.all.tags('html')[0]){
				float_height = (document.all.tags('html')[0].scrollHeight + add_height) + 'px';
			}
			else{
				float_height = '150%'
			}

			if(document.body.offsetWidth){
				left = Math.ceil((document.body.offsetWidth - pop_width)/2);
				top = Math.ceil((document.body.offsetHeight - pop_height)/2);
			}
			else{
				left = Math.ceil((window.screen.width - pop_width)/2);
				top = Math.ceil((window.screen.height - pop_height)/2);
			}			

			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';
				}
			}

			document.getElementById('pop_float').style.height = float_height;
			document.getElementById('pop_float').style.display = 'block';

			document.getElementById('pop_content').style.posTop = top;
			document.getElementById('pop_content').style.posLeft = left;
			document.getElementById('pop_content').style.width = pop_width;
			document.getElementById('pop_content').style.height = pop_height;

			document.getElementById('pop_content').innerHTML = xmlDoc;
			document.getElementById('pop_content').style.display = 'block';
        } 
		else{
            alert("¼­¹ö »óÅÂ°¡ ºÒ¾ÈÁ¤ ÇÕ´Ï´Ù.");
        }
	}
}

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';
		}
	}

	document.getElementById('pop_content').innerHTML = '';
	document.getElementById('pop_content').style.display = 'none';
	document.getElementById('pop_float').style.display = 'none';
}

function login_chk() {
	if (document.loginfrm.mem_id.value == "") {
		alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
		document.loginfrm.mem_id.focus();
		return;
	}		
	else if (document.loginfrm.mem_pwd.value == "") {
		alert('ÆÐ½º¿öµå¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
		document.loginfrm.mem_pwd.focus();
		return;
	}
	else {
		document.loginfrm.submit();
	}		
}

function click_count(section , url , type , btn_url){
	var tmp_img = new Image(0,0);

	tmp_img.src = 'http://www.ygfamily.com/include/click_count.asp?section=' + section + '&target_url=' + btn_url;
	document.body.appendChild(tmp_img);

	if(type == 1){
		window.open(url);
	}
	else if(type == 2){
		location.href = url;
	}
	else{
		return;
	}
}