function msn() {
	CheckCookie();
	SetCookieArticle();
	CheckMessenger();
}

function getDzCookies(name) {
	var cookies = document.cookie;
	var value  = "";
	if(cookies.indexOf(name) != -1) {
		var start = cookies.indexOf(name) + name.length + 1;
		var end   = cookies.indexOf(";",start);

		if(end == -1) {
			end = cookies.length;
		}

		value = cookies.substring(start,end);
		value = unescape(value);
	}

	return value;
}

var obj;
var AppID = "99995653";

function CheckMessenger()
{
	eval ('try {obj = new ActiveXObject("MSNMessenger.P4QuickLaunch"); } catch (e) {obj = null;}');
	var strErrorPage = "http://www.mydaily.co.kr/";
	
	if ( window.navigator.appName != "Microsoft Internet Explorer" ) 
	{
		ShowWindow(strErrorPage, 410, 130);
	}	
	else if (obj == null)
	{
		ShowWindow(strErrorPage, 410, 130);
	
	}
	obj.LaunchApp(AppID, '');

}

function IgnoreEvents(e)
{
  return false
}

var winModalWindow;
//Display error message if the MSN Messenger client 6.2 is not installed or the browser is not Internet Explorer
function ShowWindow(strError, width, height) {
	if (window.showModalDialog) {

		window.showModalDialog(strError,null, "dialogWidth="+width+"px;dialogHeight="+height+"px;help=no;dialogLeft=160");
	}
	else {
		var ah = screen.availHeight;

		var y = (ah - height) / 2;

		window.top.captureEvents (Event.CLICK|Event.FOCUS)
		window.top.onfocus=HandleFocus
		winModalWindow = window.open (strError,"ModalChild", "dependent=yes,width="+width+",height="+height+",top="+y+",left=160,screenX=160,screenY="+y)
		winModalWindow.focus()
	}
}

function SetCookieArticle(){
	
	var sValue = location.href;
	var sExpires = new Date();
	sExpires.setDate(sExpires.getDate()+1);
	sExpires.setHours(0,0,0,0);

	document.cookie = "msn=" + escape(sValue)+";expires="+(sExpires.toGMTString()) +
		";path=/"+((location.host.toLowerCase().indexOf("mydaily.co.kr")>=0)?";domain=mydaily.co.kr":"");
}

function CheckCookie() {   
	var cookieName = "checkCookie";
	document.cookie = cookieName + "=1;path=/"+((location.host.toLowerCase().indexOf("mydaily.co.kr")>=0)?";domain=mydaily.co.kr":"");
	var value = getDzCookies(cookieName);

	if (value == null || value == "") {
		//if (isVista())
		//	alert ("¸Þ½ÅÀúº¸³»±â ±â´ÉÀº À¥ ºê¶ó¿ìÀú¿¡¼­ 'ÄíÅ°Çã¿ë' ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");
		alert ("ÄíÅ°¼³Á¤ÀÌ ¾ÈµÇ¾î ÀÖ´Â °æ¿ì ´Ù¸¥±â»ç°¡ Àü¼ÛµÉ ¼ö ÀÖ½À´Ï´Ù. \n\nÀÎÅÍ³Ý¿É¼Ç¿¡¼­ ÄíÅ°Çã¿ëÀ» È®ÀÎÇØ ÁÖ¼¼¿ä.");
	}
	
	document.cookie = cookieName + "=;path=/;expires=Fri, 31 Dec 1900 23:59:59 GMT"+((location.host.toLowerCase().indexOf("mydaily.co.kr")>=0)?";domain=mydaily.co.kr":"");
}

function HandleFocus()
{
  if (winModalWindow)
  {
    if (!winModalWindow.closed)
    {
      winModalWindow.focus()
    }
    else
    {
      window.top.releaseEvents (Event.CLICK|Event.FOCUS)
    }
  }
  return false
}

