// ============================ Cookie 관련 함수 =============================0
    function delCookie(name,value,expires,path,domain,secure) {
      document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
    }
    
    function setCookie (name,value,expires,path,domain,secure) {
      document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
    }
    
    function getCookieVal (offset) {
      var endstr = document.cookie.indexOf (";", offset);
      if (endstr == -1)
        endstr = document.cookie.length;
      return unescape(document.cookie.substring(offset, endstr));
    }
    
    function getCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
            var j = i + alen;
            if (document.cookie.substring(i, j) == arg)
                return getCookieVal (j);
            i = document.cookie.indexOf(" ", i) + 1;
            if (i == 0) break;
        }
        return null;
    }
    
    function getCookieA(uName,uName2){		//쿠키열 중에 uName2의 값을 구한다 
    	var string = getCookie(uName);
    	if(string==null) string="";    	
    	
    	var flag = string.indexOf(uName2+'=');
    	if (flag != -1){ 
    		flag += uName2.length + 1
    		end = string.indexOf('&', flag) 
    
    		if (end == -1) end = string.length
    		return unescape(string.substring(flag, end))
    	}else{
    		return ""
    	}
    }    
// ============================ Cookie 관련 함수 =============================0

	// 공용  팝업 
	 function popupWindow(Url, windowName, width, height){
	   //var win = window.open(Url,windowName,"toolbar=no,location=no,directory=no,status=no,menubar=no,scrollbars="+ scroll +",resizable=no,top=200,left=300,width="+ Width +",height="+ Height);
	   //var win = window.open(Url, windowName, "toolbar=no, location=no");
	   var win = window.open(Url, windowName, "status=no,toolbar=no,resizable=yes,scrollbars=yes,menubar=no, width="+width+", height="+height+", left=0, top=0"); 
	   win.focus();
	 }
	 
	 // ============================ Validation 체크 관련 함수  =============================0
	  var NUM = "0123456789";	
	  var SALPHA = "abcdefghijklmnopqrstuvwxyz_";
	  var ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"+SALPHA;
	  var EMAIL = "-_.@"+NUM+ALPHA;
	
	//숫자와 영문조합 확인
	function CheckType(s,spc) {
		var i;
		for(i=0; i<s.length; i++) {
			if (spc.indexOf( s.substring(i, i+1)) < 0) {
				return false;
			}
		}
			
		return true;
	}
	  
	//Email 유효성 검사 (중국어 사이트)
	function CheckEmail (langtype, email, essential, resultobj) {
	   var strAlert = "";
	   
	   if (langtype == "ck")
	   		strAlert = "请输入有效的电邮";
	   else if(langtype =="cb")
	   		strAlert = "請輸入有效的電郵";
	   		
	   resultobj.innerHTML = "";
	   if(essential){
		   	if ( email == "") {
				resultobj.innerHTML = strAlert;	        
				return false;
			}
		}
		if(email!=""){		
			if (!CheckType(email, EMAIL)) {
				resultobj.innerHTML = strAlert;	        
				return false;
			}
					
			var a = email.indexOf('@');
			if ( a <=0 || a == email.length -1 ) {
				resultobj.innerHTML = strAlert;	        
				return false;
			}	
		}	
		return true;
	}
	
	//Email 유효성 검사(중국 포탈)
	function CheckEmail(email, essential) {
	   var strAlert = "";
	   if(essential){
		   	if ( email == "") {
		   		alert("E-mail 주소를 입력하세요.");
				return false;
			}
		}
		if(email!=""){		
			if (!CheckType(email, EMAIL)) {
				alert("E-mail 주소에 부적적한 문자가 있습니다 .");
				return false;
			}
					
			var a = email.indexOf('@');
			if ( a <=0 || a == email.length -1 ) {
				alert("jci@joongang.co.kr와 같이 입력하세요.");
				return false;
			}	
		}	
		return true;
	}
	
   // ============================ Validation 체크 관련 함수  =============================0
   
   // 구글 애드 센스 
   function google_ad_request_done(google_ads) {
	
/*
* This function is required and is used to display
* the ads that are returned from the JavaScript
* request. You should modify the document.write
* commands so that the HTML they write out fits
* with your desired ad layout.
*/
var s = '';
var i;

/*
* Verify that there are actually ads to display.
*/
if (google_ads.length == 0) {
return;
}

/*
* If an image ad is returned, display that ad.
* Otherwise, build a string containing all of the ads and
* then use a document.write() command to print that string.
*/


if (google_ads[0].type == "image") {


   s += '<a href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 

'<a href="' + google_ads[0].url +
'" target="_blank" title="go to ' + google_ads[0].visible_url +
'"><img border="0" src="' + google_ads[0].image_url +
'"width="' + google_ads[0].image_width +
'"height="' + google_ads[0].image_height + '"></a>';


} else {


if (google_ads.length == 1) {
/*
* Partners should adjust text sizes
* so ads occupy the majority of ad space.
*/
/*
s += '<a href=\"' + google_info.feedback_url + '\" style="color:000000" target="_blank">Ads by Google</a><br>' + 

'<a href="' + google_ads[0].url + '" ' +
'onmouseout="window.status=\'\'" ' +
'onmouseover="window.status=\'go to ' +
google_ads[0].visible_url + '\'" ' +
'style="text-decoration:none" target="_blank">' +
'<span style="text-decoration:underline;font-size:20pt">' +
'<b>' + google_ads[0].line1 + '</b><br></span>' + 
'<span style="color:#000000;font-size:16pt">' +
google_ads[0].line2 + '&nbsp;' +
google_ads[0].line3 + '<br></span>' +
'<span style="color:#008000;font-size:14pt">' +
google_ads[0].visible_url + '</span></a><br>';
*/
s +="<div class=\"goo05\">"+
"<a class=\"goo02\" href=\""+google_ads[0].url+"\" target='_blank'>"+google_ads[0].line1 +"</a>"+
"<p class=\"goo03\">"+google_ads[0].line2 +"<BR>"+google_ads[0].line3 +"</p>"+
"<a class=\"goo04\">"+google_ads[0].visible_url+"</a>"+
"</div>"


} else if (google_ads.length > 1) {

   //s += '<a href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>'
   s += '<a href=\"' + google_info.feedback_url + '\" style="color:000000" target="_blank"><p class="goo01">Ads by Google</p></a>' 

  /*
  * For text ads, append each ad to the string.
  */

for(i = 0; i < google_ads.length; ++i) {
/*
s += '<br><a href="' + google_ads[i].url + '" ' + 
'onmouseout="window.status=\'\'" ' +
'onmouseover="window.status=\'go to ' +
google_ads[i].visible_url + '\'" ' +
'style="text-decoration:none">' +
'<span style="text-decoration:underline">' +
'<b>' + google_ads[i].line1 + '</b><br></span>' + 
'<span style="color:#000000">' +
google_ads[i].line2 + '<br>' +
google_ads[i].line3 + '<br></span>' +
'<span style="color:#008000">' +
google_ads[i].visible_url + '</span></a><br>';

*/
s+="<div class=\"goo05\">"+
"<a class=\"goo02\" href=\""+google_ads[i].url+"\" target='_blank'>"+google_ads[i].line1 +"</a>"+
"<p class=\"goo03\">"+google_ads[i].line2 +"<BR>"+google_ads[i].line3 +"</p>"+
"<a class=\"goo04\">"+google_ads[i].visible_url+"</a>"+
"</div>"
}       
}
    }
    document.write(s);
    return;
  }
  
function loadAdSense(objID){
	var obj = document.getElementById(objID);
	var adSense = "<script type='text/javascript'>google_ad_client = 'pub-3917197669619358';" +
	"google_ad_output = 'js';"+
	"google_max_num_ads = '3';"+
	"google_image_size = '228x226';"+
	"google_feedback = 'on';</script>"+
	"<script type=\"text/javascript\" src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\"></script>";
	obj.innerHTML = adSense;  	
}
  
  
  
  
  
function gbAddFavorite(){	
	window.external.AddFavorite("http://chinese.joins.com/gb","韩国最大的传媒机构《中央日报》中文网")
}
function big5AddFavorite(){	
	window.external.AddFavorite("http://chinese.joins.com/big5","韓國最大的傳媒機構《中央日報》中文網")
}


//admin에 있던 것 옮겨옴.
/*
함수 yAjax()
	- ajax 사용
	- 입력 패러미터
		sMmethod	: 전송 방식 (GET , POST)
		sUrl    	: Request URL					 
		sAsync  	: 동기(false)/비동기(true) 설정 => 비동기일 경우 콜백 이벤트 이용 가능
		sContent	: POST 방식일 경우 전송할 Data
		sRequest	: Response Type 
		sFunction   : 콜백 함수 명
	- 사용예		
	    yAjax.open('GET','test.aspx',true,null,XML,'callback')				
*/

var yAjax = {

	getXmlHttp : function(){
		var xmlHttp = false;
	
		if (window.ActiveXObject){
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			if (xmlHttp ==  null){
				xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");            
			}
		}else if (window.XMLHttpRequest){
			xmlHttp = new XMLHttpRequest();
		}			
		return xmlHttp;		
	}
	,
	open : function( sMmethod, sUrl, sAsync, sContent, sRequest, sFunction){
		var xmlHttp = this.getXmlHttp();
		if( !xmlHttp ){
			alert("XMLHTTP Object 생성 에러입니다.");
			return;
		}
		
		xmlHttp.open(sMmethod, sUrl, sAsync);
		
		if( sMmethod=="POST" ){
			xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		}

		xmlHttp.onreadystatechange = function() {
	    	
		    if(xmlHttp.readyState == 4){ //COMPLETE(4)
		        	
					if( xmlHttp.status == 200 ){
		
						if( sRequest=="XML" ){
							eval(sFunction+'(xmlHttp.responseXML);');
						}else{
							eval(sFunction+'(xmlHttp.responseText);');
						}
					}else{
						alert("오류:"+xmlHttp.status);
					}       
				}
		}

		xmlHttp.send(sContent);		
	}
	,
	encode : function(paramValue){
		return encodeURIComponent(paramValue);
	}	
};

var g_SetAjaxResult_Element;

function SetAjaxResultToElement(url, element) {
	g_SetAjaxResult_Element = element;
	yAjax.open("GET", url, false, null, "TEXT", "SetAjaxResultCallback");
}

function SetAjaxResultCallback(resHtml) {
	g_SetAjaxResult_Element.innerHTML = resHtml;	
}