/* zieo@zieo.com */
function zHttprequest(URL) {
	var xmlhttp = null;
	if(window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	} else {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open('GET', URL,false);
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState==4 && xmlhttp.status == 200 && xmlhttp.statusText=='OK') {
			responseText = xmlhttp.responseText;
		}
	}
	xmlhttp.send('');
	return responseText = xmlhttp.responseText;
}

function zAjax(theID,theURL) {
	var temp = zHttprequest(theURL);
	document.getElementById(theID).innerHTML = temp;
}

function zhDIV(theDIV,theCode,theLIMIT) {
	var rolloverCode = "r";
	for(i=1;i<theLIMIT+1;i++) {
		if(i==theCode) rolloverCode = "r"; else rolloverCode = "";
		document.getElementById(theDIV+"0"+i).src = "/web/"+theDIV+"0"+i+rolloverCode+".jpg";
	}
}

// Hide And Show Toggle
var cc=0
function hideShow(id) {
    if (cc==0) {
        cc=1
        document.getElementById(id).style.display="none";
    } else {
        cc=0
        document.getElementById(id).style.display="block";
    }
}

// Show And Hide Toggle
var cc=0
function showHide(id) {
    if (cc==0) {
        cc=1
        document.getElementById(id).style.display="block";
    } else {
        cc=0
        document.getElementById(id).style.display="none";
    }
}

// Local Navigation Toggle
function lnbToggle(id) {
	for(num=1; num<=3; num++) document.getElementById('D3MG'+num).style.display='none'; //D4MG1~D4MG3 까지 숨긴 다음
	document.getElementById(id).style.display='block'; //해당 ID만 보임
}

// IS
function chkIsKind(key, value) {
    showHide('selectOrder');
    xGetElementById('search_target'+key).checked = true;
    xInnerHtml('search_target_label', value);
}

var favoriteurl="http://www.bscbs.co.kr";
var favoritetitle="부산CBS";

function addFavorites() {
  if(document.all) window.external.AddFavorite(favoriteurl,favoritetitle);
}

function liveradio(zID) {
	window.open('/liveradio?zid='+zID, 'wLiveRadioBSCBS', 'width=400,height=190');
}

(function($){
	$(document).ready(function () {
		
		// gnb show & hide
		$('#gnb ul li').hover(function () {
				$(this).children('ul:not(":animated")').slideDown('fast');
			}, function () {	
				$('ul', this).fadeOut('fast');
		}).children('a').focus(function(){
			$(this).parent('li').parent('ul').children('li').children('.sub').addClass('closed');
			$(this).removeClass('closed').addClass('opened');
			$(this).parent('li').children('ul').slideDown('fast');
			if($(this).attr('class').match('opened')) $(this).parent('li').parent('ul').children('li').children('.closed').parent('li').children('ul').fadeOut('fast');
		});
		$('*:not("#gnb a")').focus(function(){
			$('#gnb ul li ul').fadeOut('fast');
		});
		
		jQuery('.select_language_button button').click(function () {
				jQuery(this).css({'border-bottom':'1px'});
				jQuery('.language_line ul').slideToggle('fast');
		});
		
		/* .zAjax 로 된 것은 모두 데이터 불러오기 */	/* 모든 zAjax 적용하기 */
		$('.zAjax').each(function(index){
			var zURL = $(this).attr('url');
			$(this).load(zURL);
		});
		
		/* 촤측 상단 편성표 보기 */
		$('#btn_stt').click(function() {
			if($('#div_stt').is(':visible')) {
				$('#div_stt').slideUp();
			} else {
				$('#div_stt').slideDown();				
			}
		});
		$('#div_stt .menu li').bind('mouseenter',function() {
			$(this).parent().children('li').removeClass();
			$(this).addClass('selected');
			$('#div_stt .body').load($(this).attr('url'));
		});
	});
})(jQuery);

