
//popup location define
var POP_LOCATION_LEFT 	= "PL01";
var POP_LOCATION_CENTER = "PL02";
var POP_LOCATION_RIGHT 	= "PL03";
    
function setCookie( name, value, expiredays ) {
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	//document.cookie = name + "=" + escape( value ) + "; path=/; domain=.cheil.com; expires=" + todayDate.toGMTString() + ";"
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}

function getCookie(name) {
	var cname = name + "=";
	var dc = document.cookie;
	if (dc.length > 0) {
		begin = dc.indexOf(cname);
		if (begin != -1) {
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
				return unescape(dc.substring(begin, end));
		}
	}
	return null;
}


function closeWin(cookiename) {
	setCookie( cookiename, "checked" , 1);
	self.close();
}

function openpopup(url, name, w, h, loc) {
  var winX = 0;
  var winY = 0;
  
  if(loc==POP_LOCATION_LEFT){
	  if (parseInt(navigator.appVersion) >= 4) {
		  winX = (screen.availWidth - w)*0;
	  }	  
  } else if (loc==POP_LOCATION_CENTER){
	  if (parseInt(navigator.appVersion) >= 4) {
	    winX = (screen.availWidth - w)*.5;
	  }
  } else if (loc==POP_LOCATION_RIGHT){
	  if (parseInt(navigator.appVersion) >= 4) {
		  winX = (screen.availWidth - w);
	  }
  }

  var features = 'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY +',scrollbars=y, resizable=yes';
  
  //open popup
  popupWin = window.open(url, name, features);
  
 }

function getCookieName(cValue){
	
	var now=new Date();
	var strYear = now.getFullYear().toString();
	var strMon = now.getMonth();
	var strDate = now.getDate();
	
	if (strMon<10) { strMon = "0"+ (now.getMonth()+1);}
	else { strMon = now.getMonth()+1;}
	if (strDate<10) { strDate = "0"+ (now.getDate());}
	else { strDate = now.getDate();}

	var today = strYear.substring(2,4)+""+strMon+strDate;
	var c_name = "pm_popup_"+cValue+today;
	//var c_name = "popup_"+today;
	return c_name;
	
	//alert(cValue);
	return cValue;
}


	function popupAutoResize(val,val2) {
		
		if(val==0&&val2==0){
		    var thisX = parseInt(document.body.scrollWidth);
		    var thisY = parseInt(document.body.scrollHeight);
		}else{
		    var thisX = parseInt(val);
		    var thisY = parseInt(val2);
		}
		    var maxThisX = screen.width - 50;
		    var maxThisY = screen.height - 50;
		    var marginY = 0;
	
			// ������ ���� ���� 
		    if (navigator.userAgent.indexOf("MSIE 6") > 0) marginY = 45;        // IE 6.x
		    else if(navigator.userAgent.indexOf("MSIE 7") > 0) marginY = 75;    // IE 7.x
		    else if(navigator.userAgent.indexOf("MSIE 8") > 0) marginY = 75;    // IE 7.x
		    else if(navigator.userAgent.indexOf("Firefox") > 0) marginY = 50;   // FF
		    else if(navigator.userAgent.indexOf("Opera") > 0) marginY = 30;     // Opera
		    else if(navigator.userAgent.indexOf("Netscape") > 0) marginY = -2;  // Netscape
	
		    if (thisX > maxThisX) {
		        window.document.body.scroll = "yes";
		        thisX = maxThisX;
		    }
		    if (thisY > maxThisY - marginY) {
		        window.document.body.scroll = "yes";
		        thisX += 19;
		        thisY = maxThisY - marginY;
		    }
		    window.resizeTo(thisX+25, thisY+marginY);	
	}
