/********************************************
 * »çÀÌÆ®¿¡¼­ °øÅëÀ¸·Î »ç¿ëÇÏ´Â ÇÔ¼ö¸ðÀ½
 * 
 ********************************************/
/**
 * ·Î±×ÀÎ¿©ºÎ
 */
function isLogin(userId){
	return userId == "" || userId == "guest" ? false : true;
}

/**
 * ÆäÀÌÁö ÀÌµ¿.
 * ÆË¾÷¿¡¼­ È£ÃâÇÑ °æ¿ì opener ÀÌµ¿ÇÔ
 * @param url
 * @param isPopup
 * @return
 */
function goUrlGate(url, isPopup) {
	if(typeof(isPopup)=='undefined'){
		document.location.href= url;
	}else{
		if(isPopup){
			opener.document.location.href = url;
		}else{
			document.location.href = url;
		}
	}
}
var twitterUrl = '';
var gTwLongUrl = '';
/**
 * Æ®À§ÅÍ·Î º¸³»±â
 * @return
 */
function sendPageToTwitter(twurl, e) {
	var ex = null;
	try {
		ex = e || window.event;
		ex.returnValue = false;
	}catch(excp){
	}
	
	var pageUrl = escape(document.location);
	twitterUrl = twurl;
	gTwLongUrl = pageUrl;
	
	var callUrl = "http://durl.me/api/Create.do?type=json&callback=callShortDUrl&longurl="+pageUrl;
	//alert(callUrl);
	/*
    $.getJSON(
    	callUrl, 
        function(data){
            if ( data.status == "ok" ) {
            	shortUrl = data.shortUrl;
                alert(result);
            }
        }
    );
	*/
	/* http://durl.me/api/Create.do?type=json&callback=test&longurl=http://www.postcorea.net/
	 * test({"key":"36br6","shortUrl":"http://durl.me/36br6","status":"ok","longUrl":"http://www.postcorea.net/"})
	 */
	var head = document.getElementsByTagName("head").item(0);
	var script = document.createElement ("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", callUrl);
	head.appendChild(script);
	
}
/**
 * dulr.me shorturl callback ÇÔ¼ö
 * @param data JSON => {key:'',shortUrl:'',status:'',longUrl:''}
 * @return
 */
function callShortDUrl(data){
	//alert(data.shortUrl);
	if(data.status=="ok"){
		openWin(twitterUrl+data.shortUrl,'','800','600','yes');
	}else{
		alert("´ÜÃàurlÁ¤º¸¸¦ ¹Þ¾Æ¿Ã ¼ö ¾ø½À´Ï´Ù.");
		openWin(twitterUrl+gTwLongUrl,'','800','600','yes');
	}
}
/**
 * ÆäÀÌÁö ½ºÅ©·¦ÇÏ±â. °ü½ÉÄÁÅÙÃ÷
 * @param userId
 * @return
 */
function scrapPage(url, userId) {
	var menuPath = getLinemapPath();
	//var pageUrl = escape(document.location);

	//alert(menuPath);
	if(!isLogin(userId)){
		alert("·Î±×ÀÎÀ» ÇÏ¼Å¾ßÇÕ´Ï´Ù.");
		goLogin();
	}else{
		var sf = document.funcForm;
		sf.target="_self";
		sf.MENU_PATH.value = menuPath;
		sf.action = url;
		sf.submit();
	}
}
