var NS4;
var IE4;
if (document.all)
{
    IE4 = true;
    NS4 = false;
}
else
{
    IE4 = false;
    NS4 = true;
}
isWin = (navigator.appVersion.indexOf("Win") != -1)

var telRegEx = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}/i; //ÀÏ¹ÝÀüÈ­ Á¤±Ô½Ä
var hpRegEx = /^[0-9]{3}-[0-9]{3,4}-[0-9]{4}/i;	//ÇÚµåÆù

function onlyNumber() //¼ýÀÚ À¯È¿¼º °Ë»ç
{	
  if((event.keyCode<48)||(event.keyCode>57))
  event.returnValue=false ;
}

function js_RegnoValid(Regno) //ÁÖ¹Î¹øÈ£ À¯È¿¼º °Ë»ç
{
	a = new Array(13);

	for (var i=0; i < 13; i++) 
	{ a[i] = parseInt(Regno.charAt(i));}

   var j = a[0]*2 + a[1]*3 + a[2]*4 + a[3]*5 + a[4]*6 + a[5]*7 + a[6]*8 + a[7]*9 + a[8]*2 + a[9]*3 + a[10]*4 + a[11]*5;
   var j = j % 11;
   var k = 11 - j;

   if (k > 9) { k = k % 10 }
   if (k != a[12])
	   return false
   else 
	   return true;
}

String.prototype.trim = function(){return this.replace(" ","");}


//°ø¹éÁ¦°Å
/*function Trim(string) {
    for(;string.indexOf(" ")!= -1;){
        string=string.replace(" ","")
    }
    return string;
}*/

function strCheck(checkStr) { //Æ¯¼ö¹®ÀÚ Ã¼Å©
	var TEXT = "-_~!@#$%^&*()+|\=`,.><?/£££¦£ª£À¡×¡Ø¡Ù¡Ú¤±¡Û¡Ü¤»¡Ý¡Þ¡ß¡à¡á¡â¡ã¡ä¡å¡æ¡ç¡è¡é¡ê¡ë¢·¢¸¢¹¢Ã¢»¢¼¢½¢¾¢¿¢À¢Á¢Â¢Ã¢Ä¢Å¢Æ¢Ç¢È¢É¢Ë¢Ì¢Í¢Î¢Ï¢Ð¢Ñ";
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < TEXT.length;  j++) {
			if (ch == TEXT.charAt(j)) {
				return (false);
				break;
			}
		}
	}
	return (true);
}


/*function post(chk){ //¿ìÆí¹øÈ£Ã¢
	var url = "/mypage/findzip.asp?chk="+chk;
	window.open(url,"postsearch","width=403,height=250,scrollbars=yes");	
}*/

function findPost(obj){ //¿ìÆí¹øÈ£Ã¢
	 oWnd = centOpenWin('../services/p_post.php?obj='+obj,'FND_POST','scrollbars=no' ,390, 450);
     oWnd.focus();
}

function isEmail(s) {
	return s.search(/^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~\-]+)+\s*$/g)>=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function imgUpload(obj,sample,dir){ //ÀÌ¹ÌÁö ÆË¾÷ ¾÷·Îµå(Æû¿ÀºêÁ§Æ®, Ç¥½ÃÇÒ¿ÀºêÁ§Æ®ÀÌ¸§, ¾÷·ÎµåÆú´õÀÌ¸§)
  var theURL = '/olive_manager_booth/popup_upload.asp?obj='+obj+'&sample='+sample+'&dir='+dir;
  var winName = 'WIN_IMG';
  var features = 'width=430, height=280 ,toolbar=no,menubar=no,location=no,status=yes';
  popup_Window = window.open(theURL,winName,features);
  popup_Window.focus();
}

function imgUploadDel(obj,sample,dir){ //ÀÌ¹ÌÁö»èÁ¦(Æû¿ÀºêÁ§Æ®, Ç¥½ÃÇÒ¿ÀºêÁ§Æ®ÀÌ¸§, ¾÷·ÎµåÆú´õÀÌ¸§)
  var theURL = '/olive_manager_booth/popup_upload.asp?obj='+obj+'&sample='+sample+'&imgDel=Y&dir='+dir;
  var winName = 'WIN_IMG_DEL';
  var features = 'width=430, height=280 ,toolbar=no,menubar=no,location=no,status=yes';

	if(!eval(obj).value){
		alert('»èÁ¦ÇÒ ÀÌ¹ÌÁö°¡ ¾ø½À´Ï´Ù.');
		return;
}
  popup_Window = window.open(theURL,winName,features);
  popup_Window.focus();

}

function mailSend(no){ //ÇÁ·Î±×·¥ ¸ÞÀÏº¸³¿
  var theURL = '/popup/progview_send.asp?pgm_no='+no;
  var winName = 'WIN_MAIL';
  var features = 'width=810, height=670 ,scrollbars=yes, toolbar=no,menubar=no,location=no,status=yes';

  popup_Window = window.open(theURL,winName,features);
  popup_Window.focus();

}

function mailConSend(no){ //ÇÁ·Î±×·¥ ¸ÞÀÏº¸³¿
  var theURL = '/popup/contents_send.asp?cm_no='+no;
  var winName = 'WIN_MAIL';
  var features = 'width=810, height=670 ,scrollbars=yes, toolbar=no,menubar=no,location=no,status=yes';

  popup_Window = window.open(theURL,winName,features);
  popup_Window.focus();

}

function detailPrint(no){ //ÇÁ·Î±×·¥ ÇÁ¸°Æ®
  var theURL = '/popup/progview_print.asp?pgm_no='+no;
  var winName = 'WIN_MAIL';
  var features = 'width=810, height=670 ,scrollbars=yes, toolbar=no,menubar=no,location=no,status=yes';

  popup_Window = window.open(theURL,winName,features);
  popup_Window.focus();

}

function detailConPrint(no,cate,pg){ //ÇÁ·Î±×·¥ ÇÁ¸°Æ®
  var theURL = '/popup/contents_print.asp?cm_no='+no+'&cate='+cate+'&page='+pg;
  var winName = 'WIN_MAIL';
  var features = 'width=810, height=670 ,scrollbars=yes, toolbar=no,menubar=no,location=no,status=yes';

  popup_Window = window.open(theURL,winName,features);
  popup_Window.focus();

}

function bImgView(img){ //ÇÁ·Î±×·¥ ÇÁ¸°Æ®
  var theURL = '/popup/zoom.asp?img='+img;
  var winName = 'WIN_MAIL';
  var features = 'width=600, height=400 ,scrollbars=no, toolbar=no,menubar=no,location=no,status=no';

  popup_Window = window.open(theURL,winName,features);
  popup_Window.focus();

}

function zzimMsg(){ //ÇÁ·Î±×·¥ ÂòÇÏ±âÆË¾÷
  var theURL = '/popup/regist_mypage.asp';
  var winName = 'WIN_MAIL';
  var features = 'scrollbars=no, toolbar=no,menubar=no,location=no,status=no';

   popup_Window = centOpenWin(theURL,winName,features,275,180);
   popup_Window.focus();


}

function centOpenWin(url,name,features ,width, height){ //ÆË¾÷ ¼¾ÅÍ·Î ¶ç¿ì±â
	if (IE4 && width < window.screen.width && height < window.screen.height) 
    {
        var windowX = Math.ceil( (window.screen.width  - width) / 2 );
        var windowY = Math.ceil( (window.screen.height - height) / 2 );
        oWnd = window.open(url, name, "width="+width+",height="+height+","+features+",left="+windowX+",top="+windowY);
    }
    else 
    {
        oWnd = window.open(url, name, "width="+width+",height="+height+","+features);
    }
  return oWnd	
}
  

function ResizeParentFrame(name)	// ÀÚ½ÅÀÇ ³»¿ë¿¡ ¸Â°Ô ºÎ¸ðÀÇ iframe »çÀÌÁî Å©±â Á¶Àý
{
	if (parent.document.all(name)) {
		var frmSelf  = parent.document.all(name);
		var frmBody  = document.body;
		var frmBodyHeight = frmBody.scrollHeight;
		if (frmBodyHeight <= 0) 
		{
			location.reload();
		}else{ 
		   if(name=='ifrmComment') //´ñ±Û
		   {
			 frmSelf.style.height = frmBodyHeight+40;
		   }else{
			frmSelf.style.height = frmBodyHeight+20;
		   }
		   
		}
		
	}
}

function ResizeParentWidthFrame(name)	// ÀÚ½ÅÀÇ ³»¿ë¿¡ ¸Â°Ô ºÎ¸ðÀÇ iframe Width Å©±â Á¶Àý
{
	if (parent.document.all(name)) {
		var frmSelf  = parent.document.all(name);
		var frmBody  = document.body;
		var frmBodyWidth = frmBody.scrollWidth;
		
		
		if (frmBodyWidth <= 0)
			location.reload();
		else
			frmSelf.style.width = frmBodyWidth - 31;
	}
}


function zzimPgm(no,cd,dbjob) //ÇÁ·Î±×·¥ ÂòÇÏ±â
{
  if(dbjob=='d'){
	var msg = confirm('»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?');
	if(!msg)return;
  }
  document.frames['ifrmZzimPgm'].location.href = '/common/iframe/ifrm_zzim_program.asp?pgm_no='+no+'&pgm_cd='+cd+'&dbjob='+dbjob; 	
}

function rebroadcastPgm(no) //ÇÁ·Î±×·¥ Àç¹æ¿äÃ»
{
  document.frames['ifrmRebroadcastPgm'].location.href = '/common/iframe/ifrm_rebroadcast_program.asp?pgm_no='+no; 	
}

function loginMsg()
{
  alert('·Î±×ÀÎ ÇØÁÖ¼¼¿ä');
  return;
}


function repeat_check(str, num)
{ 
	var cnt = str.length; 
	var repeat = ""; 
	var R=1;
	 
	for(var i=0; i<cnt; i++) { 
	  tmp = str.substr(i, 1); 
	  key = tmp; 
	  if(key == repeat) { R++; } 
	  else { R=1; repeat = key; } 
	  if(R >= num) { return repeat; } 
	} 
	return ""; 
}

function sequence_check(str, num)
{
	var cnt = str.length; 
	var repeat = 0; 
	var R=1;
	 
	for(var i=0; i<cnt; i++) { 
	  asc = str.charCodeAt(i);
	  key = asc; 
	  if(key == repeat + 1) { R++; repeat = key; } 
	  else { R=1; repeat = key; }
	  if(R >= num) { return repeat; } 
	} 
	return 0;
}


function loginError(no) //·Î±×ÀÎ ¿¡·¯Ã¢
{
  oWnd = centOpenWin('/member/error.asp?errMsg='+no,'WIN_ERR','' ,300, 200);
  oWnd.focus();
}

function fndInfoErr() //¾ÆÀÌµð, ºñ¹Ð¹øÈ£Ã£±â ¿¡·¯
{
  oWnd = centOpenWin('/member/discord_message.asp','WIN_ERR','' ,400, 300);
  oWnd.focus();
}

 function loginImsi(url) //ÀÓ½Ãºñ¹Ð¹øÈ£·Î ·Î±×ÀÎÇÑÈ¸¿ø
{
   
   //common/inc/_tail.asp ¿¡ ÀÌ¾´ ÀÚ¹Ù½ºÅ©¸³Æ® È£Ãâ
   parent.loginWinImsi(url);
   //alert('wwwww');
   
  /*oWnd = centOpenWin('/member/temporary_pwLogin.asp','WIN_ERR','' ,300, 200);
  oWnd.focus();
  top.location.href=url;*/
}
    
function loginFood() //ÇªµåÈ¸¿ø
{

  top.location.href='/member/foodch_login.asp';
}
    

function loginSucess(url)
{
   
   //top.location.href= 'http://test.olivetv.co.kr?wwwww';
   top.location.href=url;
   //window.ocation.reload();
}

function MoveLogin(url){
	parent.location.href = "/member/login.asp?link_url="+escape(url);
}


 /*function KeyEventHandle()
 {
	if(
	(event.ctrlKey == true && ( event.keyCode == 78 || event.keyCode == 82 ) ) ||
	(event.keyCode >= 112 && event.keyCode <= 123 ))
	{
		event.keyCode                = 0;
		event.cancelBubble        = true;
		event.returnValue        = false;
	}
}
        document.onkeydown=KeyEventHandle;
        document.onkeyup=KeyEventHandle;
*/
/*
oncontextmenu='return false'
ondragstart = 'return false'
onselectstart = 'return false'
*/

function vwimgrzmv(obj,imgsrc) {
	var rz = 0;
	var scrl = 0;
	var rzwidth = obj.width + 5;
	var rzheight = obj.height + 25;
	var mvleft = (window.screen.width - obj.width) / 2;
	var mvtop = (window.screen.height - obj.height - 25) / 2;
	var imgwin = null;
	var ie = navigator.appName.indexOf('Microsoft Internet Explorer')>-1 ? true : false;

	if(obj.height>window.screen.height) {
		rz = 0;
		scrl = 1;
		rzwidth = obj.width + 23;
		rzheight = window.screen.height - 30;
		mvtop = 0;
	}

	if(obj.width>window.screen.width) {
		rz = 0;
		scrl = 1;
		rzwidth = window.screen.width;
		mvleft = 0;
	}

	if(!imgsrc) imgsrc = obj.src;

	imgwin = window.open('','_blank','toolbar=0,menubar=0,status=1,scrollbars=' + scrl + ',resizable=' + rz + ',width=0,height=0,left=' + ((window.screen.availWidth-245)/2) + ',top=' + ((window.screen.availHeight-105)/2));
	if(imgwin) {
		imgwin.blur();
		imgwin.moveTo(0,0);
		imgwin.resizeTo(0,0);

		imgwin.document.write(("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><" + "html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"ko\" xml:lang=\"utf-8\"><" + "head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><" + "title>object</" + "title><style type=\"text/css\">body { margin:0; }</style></" + "head>" +
			"<" + "body>" +
			"<img src=\"" + imgsrc.replace('+',' ') + "\" id=\"uploaded_image\" " +
			" onload=\"" +
				"var rz = 0;" +
				"var scrl = 0;" +
				"var rzwidth = this.width + 5;" +
				"var rzheight = this.height + 25 + " + (ie?55:30)  + ";" +
				"var mvleft = (window.screen.width - this.width) / 2;" +
				"var mvtop = (window.screen.height - this.height-25) / 2;" +
				"var imgwin = null;" +
				"if(this.height >= window.screen.height - 10) {" +
					"rzwidth = this.width + 23;" +
					"rzheight = window.screen.height - 30;" +
					"mvtop = 0;" +
				"} " +
				"if(this.width >= window.screen.width - 10) {" +
					"rz = 1;" +
					"scrl = 1;" +
					"rzwidth = window.screen.width;" +
					"mvleft = 0;" +
				"}" +
				"window.resizeTo(rzwidth, rzheight);" +
				"window.moveTo(mvleft, mvtop);" +
				"window.scrollbars = scrl;" +
				"window.resizable = rz;" +
				"\"" +
			" onerror=\"alert('ÀÌ¹ÌÁöÆÄÀÏÀÌ ¾ø°Å³ª ÆÄÀÏÀÌ¸§ÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.\\nÆÄÀÏÀÌ¸§¿¡ ÇÑ±ÛÀÌ Æ÷ÇÔµÇ¾î ÀÖÀ¸¸é ºä¾îÃ¢¿¡ ¿À·ù°¡ ¹ß»ýÇÒ¼öµµ ÀÖ½À´Ï´Ù.');self.close();\"" +
			" onclick=\"window.close();\"" +
			" style=\"cursor:hand;cursor:pointer;\" alt=\"Å¬¸¯ÇÏ½Ã¸é Ã¢ÀÌ ´ÝÈü´Ï´Ù\" />" +
			"<" + "script type=\"text/javascript\">" +
				"function init() {" +
					"var img = document.getElementById('uploaded_image');" +
					"if(img) {" +
						"if(img.width >= window.screen.width -10) {" +
							"img.width = window.screen.width - 10;" +
						"}" +
						"if(img.height >= window.screen.height-50) {" +
							"document.body.scroll='auto';" +
						"}" +
						"document.title = img.width + '*' + img.height;" +
					"}" +
				"}" +
				"window.onLoad = init();" +
			"</" + "script" + ">" +
			"</" + "body></" + "html>"));
		imgwin.status = "Resolution:" + window.screen.width + "x" + window.screen.height;
		imgwin.focus();
	}
}