function getCookie( name ){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length ){
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

function doOpenPopup(popKey, left, top, width, height ){
    var strProp = "left="+left+",top="+top+",width="+width+",height="+height+"";
    strProp += ",toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0";
    
    if (getCookie("popup" + popKey)  != "done" ){
        window.open("/htdocs/popups/pop_"+popKey+".html","popup"+ popKey, strProp);
    }
	return;
}

function openPopup(popKey, left, top, width, height ){

	document.domain = "golfdigest.co.kr";

    var strProp = "left="+left+",top="+top+",width="+width+",height="+height+"";
    strProp += ",toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0";
    
    if (getCookie("popup" + popKey)  != "done" ){
        window.open("/popups.asp?name=PopUp&action=write&id="+popKey,"popup"+ popKey, strProp);
    }
	return;
}

function setCookie( popKey, value, expiredays ){
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = "popup" + popKey + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function doClosePopup(popupKey){
    if (document.all['popup'].type == "checkbox"){
        if ( document.all['popup'].checked ){
            setCookie( popupKey , "done" , 1);
        }
    }else {
        if ( document.all['popup'].value = "CHK" ){
            setCookie( popupKey , "done" , 1);
        }
    }
	self.close(); 
}




function movePopupPage(link){

	document.domain = "golfdigest.co.kr";

	opener.document.location.href = link;
	self.close();
}




function newPopupPage(link){
	window.open(link);
	self.close();
}
