var NS4;
var IE4;
if (document.all)
{
    IE4 = true;
    NS4 = false;
}
else
{
    IE4 = false;
    NS4 = true;
}
isWin = (navigator.appVersion.indexOf("Win") != -1)

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;
}


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 strCheck1(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(no){ //¿ìÆí¹øÈ£Ã¢
	 oWnd = centOpenWin('/member/address_pop.asp?no='+no,'FND_POST','scrollbars=yes' ,450, 300);
     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 ResizeFitParentFrame(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{
			frmSelf.style.height = frmBodyHeight;
		}
	}
}

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 vodrebroadcastPgm(no) //VOD ÇÁ·Î±×·¥ Àç¹æ¿äÃ»
{
  document.frames['ifrmRebroadcastPgm'].location.href = '/common/iframe/ifrm_vodrebroadcast_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 loginError_Try(no) //·Î±×ÀÎ ¿¡·¯Ã¢
{
	if (no == "1")
	{
		alert("¾ÆÀÌµð°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
	}
	else if (no == "2")
	{
		alert('ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.');
	}

}

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?linkUrl="+escape(url);
}



function vod_init(){

		window.open("mstation.asp","oPlayer","width=650, height=560") ;

}

function OnLogOut(str){
	top.location.href = "/member/logout.asp?use="+str;
}



 /*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 doPopupOpen(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

