document.write("<table width=100% height=76 border=0 cellspacing=0 cellpadding=0 class=my_serv_txt><tr><td style=\"padding-left:17px;\"><a href=\"javascript:getArticleURL()\">Url º¹»çÇÏ±â</a></td></tr><tr><td style=\"padding-left:17px;\"><a href='javascript:showNewsScrab();'>½ºÅ©·¦ÇÏ±â</a></td></tr><tr><td style='padding-left:17px;'><a href='javascript:showScrab();'>ºí·Î±×´ã±â</a></td></tr><tr><td style='padding-left:10px;'><a href=\"javascript:TryItNow()\" onmouseover=\"Msn_mopen(1);\" onmouseout=\"Msn_mclosetime();\"><img src=http://image.chosun.com/cs/200801/images/m_service.gif></a></td></tr></table>");

document.write("\
<div id=\"msn_event\" onmouseover=\"Msn_mcancelclosetime()\" onmouseout=\"Msn_mclosetime();\" align=right> \
<table width=97 border=0 cellspacing=0 cellpadding=0> \
  <tr> \
    <td><img src=http://image.chosun.com/cs/200801/images/m_service_box01.gif></td> \
  </tr> \
  <tr> \
    <td background=http://image.chosun.com/cs/200801/images/m_service_box03.gif align=center><a href=\"javascript:TryItNow()\"><img src=http://image.chosun.com/cs/200801/images/m_service01.gif border=0 style='cursor:pointer'></a><br><a  target=_blank onClick=\"MsnAction()\"><img src=http://image.chosun.com/cs/200801/images/m_service02.gif border=0 vspace=2 style='cursor:pointer'></a><br><a href=\"http://newsplus.chosun.com/promotion/2007/msn/guide/index.html\" target=_blank><img src=http://image.chosun.com/cs/200801/images/m_service03.gif border=0></a></td> \
  </tr> \
  <tr> \
    <td><img src=http://image.chosun.com/cs/200801/images/m_service_box02.gif></td> \
  </tr> \
</table> \
</div> \
");

function checkLogin() {
	if(!getDzCookies('SMSESSION') || getDzCookies('SMSESSION') == "LOGGEDOFF" || !getDzCookies('SM_USER') || !getDzCookies('dz_info')) {
		return false;
	} else {
		return true;
	}
}

function getArticleURL () {
	var cFile = location.href;

	var IE=(document.all)?true:false;
	if (IE) {
		alert ("                             ±â»çÀÇ URLÀÌ º¹»çµÇ¾ú½À´Ï´Ù.\nÀÌÁ¦, ±â»ç¸¦ º¸³»´Â ºÐÀÇ ¸Þ½ÅÀú³ª ÀÌ¸ÞÀÏ¿¡ ctrl+V ·Î ºÙ¿©³Ö±â ÇÏ¼¼¿ä.\n\n");
		window.clipboardData.setData("Text", cFile);
	}
	else {
		prompt("ÀÌ ±â»çÀÇ ÁÖ¼ÒÀÔ´Ï´Ù. Ctrl+C¸¦ ´­·¯ Å¬¸³º¸µå·Î º¹»çÇÏ¼¼¿ä", cFile);
	}
}

function showScrab() {
	var win;
	var width = 423;
	var height = 462;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

	if (typeof(scrabYN) != "undefined" && scrabYN == "N") {
		alert('ºí·Î±×´ã±â ±â´ÉÀÌ Á¦°øµÇÁö ¾Ê´Â ±â»çÀÔ´Ï´Ù.');
		return;
	}
	if (checkLogin() == false) {
		alert('ºí·Î±×´ã±â ±â´ÉÀº ·Î±×ÀÎ ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
		location.href = "http://membership.chosun.com/login/protect_sso/sso_user_info.jsp?returl=" + escape(location.href);
		return;
	}

	win = window.open("/svc/news/scrap_blog.html", "_blank", "left=" + left + ", top=" + top + ", width=" + width + ", height=" + height + ", status=0, menubar=0, location=0, scrollbars=0");

	//while (win.document.readyState != 'complete')
	//	window.setTimeout(function() { ; }, 30);
	//var title = win.document.getElementById("title");
	//title.innerText = getTitle();
}

function showNewsScrab() {
	var win;
	//var width = 385; var height = 295;
	var width = 357; var height = 227;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

	//if (typeof(scrabYN) != "undefined" && scrabYN == "N") {
	//	alert('±â»ç½ºÅ©·¦ ±â´ÉÀÌ Á¦°øµÇÁö ¾Ê´Â ±â»çÀÔ´Ï´Ù.');
	//	return;
	//}
	if (checkLogin() == false) {
		alert('±â»ç½ºÅ©·¦ ±â´ÉÀº ·Î±×ÀÎ ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
		location.href = "http://membership.chosun.com/login/protect_sso/sso_user_info.jsp?returl=" + escape(location.href);
		return;
	}

	var url = location.href;
	var sec = url.substring(7, url.indexOf(".chosun.com"));

	window.open("http://newsplus.chosun.com/ranking/scrap/folder.php?act=1&url="+url+"&sec="+sec+"&usr_id="+getDzCookies('SM_USER'), "_blank", "left=" + left + ", top=" + top + ", width=" + width + ", height=" + height + ", status=0, menubar=0, location=0, scrollbars=1");
}

function getTitle() {
	var title = '';
	var spans = document.body.all.tags("SPAN");

	for (var i = 0; i < spans.length; i++)
	{
		if (spans[i].className == 'artTitle')
		{
			title = spans[i].innerText;
			break;
		}
	}

	return title;
}

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 winobj;
var winModalWindow;
var AppID = "99995409";

function TryItNow() {   
	//checkCookie
	CheckCookie();

	// Test #1: Launch with no email variable value causing the user to have to select another user to interact with.
	CheckMessenger();

	//setCookie
	SetCookieArticle();

	LaunchApp(AppID, "");

	(new Image).src = "http://218.145.28.148/php/In_Newht.php?sitecode=1&catcode=sec_00006&artcode=sec_sec_00006&ref=www.chosun.com&cur=www.chosun.com";
}

function LaunchApp(AppID, emailID) {   
	if (winobj != null) {   
		winobj.LaunchApp(AppID, emailID);
	}
}

function CheckMessenger() {   
	eval ('try {winobj = new ActiveXObject("MSNMessenger.P4QuickLaunch"); } catch (e) {winobj = null;}');
	var strErrorPage = "http://news.chosun.com/svc/content_view/notice.html"


	/*if ([Browser is not IE]) {
		ShowWindow(strErrorPage, 410, 130);
	}
	else if (obj == null) {
		ShowWindow(strErrorPage, 410, 225);
	}

	ShowWindow(strErrorPage, 410, 225);
	*/
}

function CheckCookie() {   
	var cookieName = "checkCookie";
	document.cookie = cookieName + "=1;path=/"+((location.host.toLowerCase().indexOf("chosun.com")>=0)?";domain=chosun.com":"");
	var value = getDzCookie(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("chosun.com")>=0)?";domain=chosun.com":"");
}

function IgnoreEvents(e) {
	return false;
}

//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 HandleFocus() {
	if (winModalWindow) {
		if (!winModalWindow.closed) {
			winModalWindow.focus()
		}
		else {
			window.top.releaseEvents (Event.CLICK|Event.FOCUS)
		}
	}
	return false
}

function SetCookieArticle(){

	var sValue = location.href;
	var sExpires = new Date();
	sExpires.setDate(sExpires.getDate()+1);
	sExpires.setHours(0,0,0,0);

	document.cookie="conturl="+escape(sValue)+";expires="+(sExpires.toGMTString())+";path=/"+((location.host.toLowerCase().indexOf("chosun.com")>=0)?";domain=chosun.com":"");
}

//ºñ½ºÅ¸ Ã¼Å© ÀÚ¹Ù½ºÅ©¸³Æ® ºñ½ºÅ¸ÀÎ°æ¿ì true ¸®ÅÏ 
function isVista() { 
	var re = new RegExp("Windows NT ([0-9]).([0-9])" ,"g"); 
	var m = re.exec(navigator.userAgent); 
	return (m[1] >= 6); 
} 

function MsnAction() {   
	(new Image).src = "http://218.145.28.148/php/In_Newht.php?sitecode=1&catcode=sec_00008&artcode=sec_sec_00008&ref=www.chosun.com&cur=www.chosun.com";

	window.open ("http://signup.alerts.live.com/alerts/login.do?PINID=41789040&returnURL=http://www.chosun.com", "_blank");
}

//¸Þ½ÅÀúº¸³»±â ¹öÆ° ·Ñ¿À¹ö, ·Ñ¾Æ¿ô

var Msn_TimeOut         = 300;
var Msn_currentLayer    = null;
var Msn_currentitem     = null;

var Msn_currentLayerNum = 0;
var Msn_noClose         = 0;
var Msn_closeTimer      = null;

// Open Hidden Layer
function Msn_mopen(n)
{
    var l  = document.getElementById("msn_event");
    var mm = document.getElementById("contentButtonArea");
    
    if(l)
    {
        Msn_mcancelclosetime();
        l.style.visibility='visible';

        if(Msn_currentLayer && (Msn_currentLayerNum != n))
            Msn_currentLayer.style.visibility='hidden';

        Msn_currentLayer = l;
        Msn_currentitem = mm;
        Msn_currentLayerNum = n;            
    }
    else if(Msn_currentLayer)
    {
        Msn_currentLayer.style.visibility='hidden';
        Msn_currentLayerNum = 0;
        Msn_currentitem = null;
        Msn_currentLayer = null;
    }
}

// Turn On Close Timer
function Msn_mclosetime()
{
    Msn_closeTimer = window.setTimeout(Msn_mclose, Msn_TimeOut);
}

// Cancel Close Timer
function Msn_mcancelclosetime()
{
    if(Msn_closeTimer)
    {
        window.clearTimeout(Msn_closeTimer);
        Msn_closeTimer = null;
    }
}

// Close Showed Layer
function Msn_mclose()
{
    if(Msn_currentLayer && Msn_noClose!=1)
    {
        Msn_currentLayer.style.visibility='hidden';
        Msn_currentLayerNum = 0;
        Msn_currentLayer = null;
        Msn_currentitem = null;
    }
    else
    {
        Msn_noClose = 0;
    }

    Msn_currentLayer = null;
    Msn_currentitem = null;
}

// Close Layer Then Click-out
document.onclick = Msn_mclose; 


