//////////////////////////////////////////////////////////////
//½ºÅ©·Ñ ¹Ú½º À§Ä¡ ¹× µû¶ó´Ù´Ï±â
var inter = null;
var tempo = 0;
var QuicknewPos = 0;

function sbp() {
    if(document.getElementById("scrollbox") != null)    {
        if(inter!=null)
            clearInterval(inter);

        var scrollTop = document.documentElement.scrollTop;
        
        if (scrollTop == 0)
            QuicknewPos = 400 + document.body.scrollTop;
        else
            QuicknewPos = scrollTop + 400;

        if((parseInt((document.getElementById("scrollbox").style.top).replace("px","")) - QuicknewPos)>0)
            tempo = -30;
        else
            tempo = 30;

        inter = setInterval("BeQuickTop()",2);
    }
}

function BeQuickTop(){
    var cpos = parseInt((document.getElementById("scrollbox").style.top).replace("px",""));
    document.getElementById("scrollbox").style.top = cpos + tempo + "px";
    document.getElementById("scrollbox").style.left = (document.body.clientWidth-1000)/2 + 1000 + 10
    
    if(tempo>0 &&tempo<20)
        tempo=20;
    else if(tempo<0 &&tempo>-20)
        tempo = -20;
    else
        tempo = tempo/2;

    if(( tempo>0 && cpos>QuicknewPos) || ( tempo<0 && cpos<QuicknewPos))    {
        document.getElementById("scrollbox").style.top = QuicknewPos + "px";
        document.getElementById("scrollbox").style.left = (document.body.clientWidth-1000)/2 + 1000 + 10
        clearInterval(inter);
    }
}

//////////////////////////////////////////////////////////////
//»óÇÏ ½ºÅ©·Ñ ¹öÆ°
function scrollit(pm) {
  if (document.body.scrollTop == 0 )
    snum = document.documentElement.scrollTop
  else
    snum = document.body.scrollTop
  k = 0
  for(i = snum; k < 5000 ; i=i+k*pm)
  { self.scroll(0,i); k++; }
}

//////////////////////////////////////////////////////////////
//»óÈ²¿¡ µû¶ó ½ºÅµ³»ºñ°ÔÀÌ¼Ç Ãß°¡ »ðÀÔÇÏ±â
function sknaviadd() {
    addHTML= ''
  if(document.getElementById('bonmun'))
    addHTML += '<a class="sknavi" href="#bonmun">º»¹® ¹Ù·Î°¡±â(Alt+3)</a>';
  if(document.getElementById('rightMenu'))
    addHTML += '<a class="sknavi" href="#rightMenu">ÇÏÀ§¸Þ´º ¹Ù·Î°¡±â(Alt+2)</a>';
  if(document.getElementById('sgnbbox'))
    addHTML += '<a class="sknavi" href="#sgnbbox">ÁÖ¸Þ´º ¹Ù·Î°¡±â(Alt+1)</a>';
  document.getElementById('sknavi_box').innerHTML = addHTML;
}

//////////////////////////////////////////////////////////////
//ÁÖ¿ä Å°º¸µå ´ÜÃàÅ°
function HotKey(){
  if(event.keyCode == 80) { // 'p'Å° »óÀ§·Î
    for(i=4; i>=0; i--) {
      if(document.getElementById("Depth"+i))
      {  location.href=eval("Depth"+i+".href"); break;  }
    }
    if(!document.getElementById("Depth0")) { alert("ÇöÀçÆäÀÌÁö´Â Ã¹ ÆäÀÌÁöÀÔ´Ï´Ù.") }
  }
  else if(event.keyCode == 72) { // 'h'Å° È¨À¸·Î
    location.href="/"
  }
  else if(event.keyCode == 49) { // accesskey '1'Å° ÁÖ¸Þ´º·Î
    if(document.getElementById("sgnbbox"))
    { sgnbbox.title="ÁÖ¸Þ´º ½ÃÀÛ"; sgnbbox.tabindex=0; sgnbbox.focus(); }
    else if(document.getElementById("center_con"))
    { center_con.title="ÁÖ¸Þ´º ½ÃÀÛ"; center_con.tabindex=0; center_con.focus();  }
    else   
      alert("ÀÌµ¿ÇÒ ÁÖ¸Þ´º°¡ ¾ø½À´Ï´Ù.")
  }
  else if(event.keyCode == 50) { // accesskey '2'Å° ÇÏÀ§¸Þ´º·Î
    if(document.getElementById("rightMenu"))
    { rightMenu.title="ÇÏÀ§¸Þ´º ½ÃÀÛ"; rightMenu.tabindex=0; rightMenu.focus();  }
    else
      alert("ÇöÀçÆäÀÌÁö´Â ÇÏÀ§¸Þ´º°¡ ¾ø½À´Ï´Ù.")
  }
  else if(event.keyCode == 51) { // accesskey '3'Å° º»¹®À¸·Î
    if(document.getElementById("bonmun"))
    { bonmun.title="º»¹® ½ÃÀÛ"; bonmun.tabindex=0; bonmun.focus();  }
    else
      alert("ÀÌµ¿ÇÒ º»¹®ÀÌ ¾ø½À´Ï´Ù.")
  }
}
document.onkeydown = HotKey

/////////////////////////////////////////////////////////////
//¸Þ´º ·Ñ¿À¹ö ÀÌ¹ÌÁö ½ºÅ©¸³Æ®
function FnInpuRollOver() 
{
  this.Start = function() 
  {
    this.MenuBox = document.getElementById(this.DivName).getElementsByTagName("ul")[0].getElementsByTagName("li");
    this.MenuLength = this.MenuBox.length;
    for ( var i=0; i<this.MenuLength; i++ ) 
    {
      this.MenuLink = this.MenuBox.item(i).getElementsByTagName("a")[0];
      this.MenuLink.i = i;
      this.MenuLink.fnName = this.fnName;
      this.MenuLink.onmouseover = this.MenuLink.onfocus = function() 
      { eval( this.fnName + ".fnMouseOver("+this.i+")") }
      this.MenuLink.onmouseout = this.MenuLink.onblur = function() 
      { eval( this.fnName + ".fnMouseOver()") }
    }
  }
  this.fnMouseOver = function(val) 
  {
    for ( var i=0; i<this.MenuLength; i++ ) 
    {
      this.MenuImg=this.MenuBox.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0];
      if ( i == val ) 
        this.MenuImg.src = this.MenuImg.src.replace("_off.gif","_on.gif");
      else 
        this.MenuImg.src = this.MenuImg.src.replace("_on.gif","_off.gif");
    }
  }
}




//////////////////////////////////////////////////////////////////////////////////////////////////////////
//VODPlayer Call Function
function vodpop(mode) {
	//window.open('http://asx.kbs.co.kr/player.html?kind=300_2week&url=2TV$20040322$live_day20040322-3_m&no_login=1','window','width=345,height=494,left=50,top=50,toolbar=0,scrollbar=0,menubar=0'); 
	if(mode == '1') window.open('player.html?kind=300_2week&url=2TV$20040322$live_day20040322-3_m&no_login=1','window','width=345,height=494,left=50,top=50,toolbar=0,scrollbar=0,menubar=0');
	else if(mode == '2') window.showModalDialog('player.html?kind=300_2week&url=2TV$20040322$live_day20040322-3_m&no_login=1','window','dialogHeight:518px; dialogWidth:349px; scroll:0; status:0; help:0; edge:sunken;');
	else if(mode == '3') window.open('player2.html?kind=live&url=2TV$20040322$live_day20040322-3_m&no_login=1','window','width=345,height=494,left=50,top=50,toolbar=0,scrollbar=0,menubar=0');
}

// old Version
//function VODPlayer(file,type) {
//	gurl = 'http://asx.kbs.co.kr/check_login.php?'+file+'&type='+type;
//	vodplayer = window.open(gurl, 'vodplayer', 'width=350 , height=200 , resizable=no , status=0 , scrollbars=0 , menubar=no, toolbar=no, fullscreen=no, channelmode=no,location=no,directories=no,alwaysRadised=0');
//}
//
//function VODAblePlayer(file,type) {
//	gurl = '/live/check_able.php?'+file+'&type='+type;
//	vodplayer = window.open(gurl, 'vodplayer', 'width=355 , height=523 , resizable=no , status=0 , scrollbars=0 , menubar=no, toolbar=no, fullscreen=no, channelmode=no,location=no,directories=no,alwaysRadised=0');
//}
//
//function CMSVod(url,type) { 
//
//	var returnUrl  = "http://asx.kbs.co.kr/check_login.php?";
//
//	if (url.indexOf("javascript:VODPlayer") > -1){
//		startIndex = url.indexOf("title");
//		lastIndex = url.lastIndexOf(",");
//
//		var str = url.substring(startIndex, lastIndex-1);
//		returnUrl = returnUrl + str ;
//	} else {
//
//		arrParam = url.split("?")[1].split("&");
//
//		for (i=0; i<arrParam.length;i++){
//			temp = arrParam[i].split("=");
//
//			p_title = temp[0];
//			p_value = temp[1];
//			
//			if (p_title == 'title'){
//							returnUrl = returnUrl+ p_title+"="+p_value+"&";
//			}
//			if (p_title == 'url'){
//							returnUrl = returnUrl+ p_title+"="+p_value+"&";
//			}
//		}
//	}
//
//	churl = returnUrl+'&type='+type+'&starttime=&endtime='; 
//	vodplayer = window.open(churl, 'vodplayer', 'width=350 , height=200 , resizable=no , status=0 , scrollbars=0 , menubar=no, toolbar=no, fullscreen=no, channelmode=no,location=no,directories=no,alwaysRadised=0');
//}


// new Version(2011)
function VODPlayer(query,type) { 
	document.domain = "kbs.co.kr";
	try{
		URLString = document.location.href;
		tURLString = URLString.split("/"); 

		ctURLString = tURLString[2].split(".");
		cString= ctURLString[1]+"."+ctURLString[2]+"."+ctURLString[3];
	}catch(e){
		cString = "";
	}

	if(cString != "kbs.co.kr"){
	}else{
		gurl = 'http://asx.kbs.co.kr/checkAsx.php?'+query+'&type='+type+'&svType=able';
		vodplayer = window.open(gurl, 'vodplayer', 'width=350 , height=400 , resizable=no , status=0 , scrollbars=0 , menubar=no, toolbar=no, statusbar=no, fullscreen=no, channelmode=no,location=no,directories=no,alwaysRadised=0,top=10,left=390');
		vodplayer.focus();
	}
}


function CMSVod(url,type) { 

	var returnUrl  = "http://asx.kbs.co.kr/checkAsx.php?";

	if (url.indexOf("javascript:VODPlayer") > -1){
		startIndex = url.indexOf("title");
		lastIndex = url.lastIndexOf(",");

		var str = url.substring(startIndex, lastIndex-1);
		returnUrl = returnUrl + str ;
	} else {

		arrParam = url.split("?")[1].split("&");

		for (i=0; i<arrParam.length;i++){
			temp = arrParam[i].split("=");

			p_title = temp[0];
			p_value = temp[1];
			
			if (p_title == 'title'){
							returnUrl = returnUrl+ p_title+"="+p_value+"&";
			}
			if (p_title == 'url'){
							returnUrl = returnUrl+ p_title+"="+p_value+"&";
			}
		}
	}

	churl = returnUrl+'&type='+type+'&starttime=&endtime=&svType=able';
	vodplayer = window.open(churl, 'vodplayer', 'width=350 , height=200 , resizable=no , status=0 , scrollbars=0 , menubar=no, toolbar=no, fullscreen=no, channelmode=no,location=no,directories=no,alwaysRadised=0');
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// Æ¯Á¤Å° ´­·¯¼­ Æ¯Á¤ÆäÀÌÁö·Î ÀÌµ¿ÇÏ°ÔÇÏ´Â ½ºÅ©¸³Æ® 
var key = new Array();   // Å°°ª°ú ÀÌµ¿ÇÒ °÷ÀÇ ÁÖ¼Ò¸¦ ÀÔ·Â ÇÏ¼¼¿ä
key['!'] = "http://able.kbs.co.kr/index.html";		// È¨À¸·Î
key['@'] = "http://able.kbs.co.kr/help/index.html";		// µµ¿ò¸»

function getKey(keyStroke) {
	isNetscape=(document.layers);
	eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
	which = String.fromCharCode(eventChooser).toLowerCase();
	for (var i in key) if (which == i) window.location = key[i];
}
document.onkeypress = getKey;
///////////////////////////////////////////////////////////////////////////////////////////////////////////

// ´º½º vod¸µÅ© ¼û±â±â
function hidestatus(obj){
	var statusmsg="";
	window.status=statusmsg;

	on_mouse(obj)

	return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

function on_user(flag) {
	document.all[flag].style.fontSize = "20px";
}

function out_user(flag) {
	document.all[flag].style.fontSize = usersFontSize+"px";
}
