//ºê¶ó¿ìÁ® Ã¼Å©
appname = navigator.appName;
useragent = navigator.userAgent;
if(appname == "Microsoft Internet Explorer") appname = "IE";
IE55 = (useragent.indexOf('MSIE 5.5')>0);  //5.5 ¹öÀü
IE6 = (useragent.indexOf('MSIE 6')>0);     //6.0 ¹öÀü
IE7 = (useragent.indexOf('MSIE 7')>0);     //7.0 ¹öÀü

//·Î°í ÇÃ·¡½Ã Å¬¸¯
function flash_logo(){
	location.href = '/';
}

// Ä«Å×°í¸® on/off
function category_open(){
	document.getElementById('f_category').style.width = '905px';
	document.getElementById('f_category').style.height = '441px';

	var obj = document.getElementById('tvObjectIframe');
	var obj1 = document.getElementById('spanactivex1');
	var obj2 = document.getElementById('viewTvObjectIframe');
	var obj3 = document.getElementById('tvIncHighFrame');
	if(obj) obj.contentWindow.document.getElementById('tvObjectTable').style.display = 'none';
	if(obj2) obj2.contentWindow.document.getElementById('SeeLive').style.marginTop = '-300px';
	if(obj1){
		document.getElementById('spanactivex1').style.position = 'absolute';
		document.getElementById('spanactivex1').style.top = '-1000px';
	}
	if(obj3){
		obj3.contentWindow.document.getElementById('tvIncHigh').style.position = 'absolute';
		obj3.contentWindow.document.getElementById('tvIncHigh').style.top = '-1000px';
	}
}
function category_close(){
	document.getElementById('f_category').style.width = '188px';
	document.getElementById('f_category').style.height = '28px';

	var obj = document.getElementById('tvObjectIframe');
	var obj1 = document.getElementById('spanactivex1');
	var obj2 = document.getElementById('viewTvObjectIframe');
	var obj3 = document.getElementById('tvIncHighFrame');
	if(obj) obj.contentWindow.document.getElementById('tvObjectTable').style.display = '';
	if(obj2) obj2.contentWindow.document.getElementById('SeeLive').style.marginTop = '0px';
	if(obj1){
		document.getElementById('spanactivex1').style.position = 'static';
		document.getElementById('spanactivex1').style.top = '0';
	}
	if(obj3){
		obj3.contentWindow.document.getElementById('tvIncHigh').style.position = 'static';
		obj3.contentWindow.document.getElementById('tvIncHigh').style.top = '0px';
	}
}

// ¼­ºê Ä«Å×°í¸®
function category01_resize(f_width,f_height){
	document.getElementById('l_category').style.width = f_width+'px';
	document.getElementById('l_category').style.height = f_height-10+'px';
	if(document.getElementById('categoryheight').style.height<1){
		document.getElementById('categoryheight').style.height = f_height+'px';
	}
}

/*ÆäÀÌÁö ºñÈ°¼ºÈ­*/
function dimLayerView(dim) {
	var obj2 = document.getElementById('viewTvObjectIframe');
	if(obj2) obj2.contentWindow.document.getElementById('SeeLive').style.marginTop = '-300px';

	var oBody = ( document.compatMode && document.compatMode!="BackCompat" ) ? document.documentElement : document.body  ;
	var cheight= ( oBody.scrollHeight > oBody.clientHeight ? oBody.scrollHeight : oBody.clientHeight  ) + 'px';
	if(!dim){document.getElementById('dim_layer').style.display = "block";
	document.getElementById('dim_layer').style.height = cheight;
	chgSelect();
	}
}
function dimLayerClose(div) {
	var obj2 = document.getElementById('viewTvObjectIframe');
	if(obj2) obj2.contentWindow.document.getElementById('SeeLive').style.marginTop = '0px';

	if(div) disnone(div);
	document.getElementById('dim_layer').style.display = "none";
	//document.getElementById("default").style.overflowY="auto";
	//document.getElementById("layd").style.paddingRight="0px";
	chgSelectDefaut();
}
//CENTER POSITION check
var ObjTemp = {};
function view_layer(the_id, the_width, the_height, dim)
{
	var lfrm = document.getElementById(the_id);
	if(!dim) {
		dimLayerView(null);
		lfrm.width = the_width + "px";
		lfrm.height = the_height + "px";
		var aa=document.getElementsByTagName("html");
		//document.getElementsByTagName("html").style.overflowY="hidden";
		//document.getElementById("default").style.overflowY="hidden";
		//document.getElementById("layd").style.paddingRight="16px";
		//aa.style.overflow="hidden";
		getviewpoint();
		disblock(the_id);

		/*lfrm.style.left = ObjTemp.scroll_left + ((ObjTemp.docwidth-lfrm.offsetWidth) / 2) + "px";*/
		lfrm.style.top = ObjTemp.scroll_top + ((ObjTemp.docheight-lfrm.offsetHeight) / 2) + "px";
		lfrm.width = the_width + "px";
		lfrm.height = the_height + "px";
	}

}
window.onresize = function()
{
var lay_bigview = document.getElementById('lay_bigview');

	getviewpoint();
	if(lay_bigview){lay_bigview.style.top = ObjTemp.scroll_top + ((ObjTemp.docheight-lay_bigview.offsetHeight) / 2) + "px";}
}
function getviewpoint()
{
	var ie=document.all && !window.opera;
	//var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000; //Preliminary doc width in non IE browsers
	ObjTemp.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body; //create reference to common "body" across doctypes
	ObjTemp.scroll_top=(ie)? ObjTemp.standardbody.scrollTop : window.pageYOffset;
   // ObjTemp.scroll_left=(ie)? ObjTemp.standardbody.scrollLeft : window.pageXOffset;
   // ObjTemp.docwidth=(ie)? ObjTemp.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16);
	ObjTemp.docheight=(ie)? ObjTemp.standardbody.clientHeight: window.innerHeight;
}

//ie6 select box
function chgSelect() {
var selectObj = document.getElementsByTagName("select");
	 if(IE6) {
		if(selectObj) {
			for (var i=0; i<selectObj.length; i++) {
				if(selectObj[i].className != 'view') selectObj[i].style.visibility ="hidden";
			}
		}
	 }
}
function chgSelectDefaut() {
var selectObj = document.getElementsByTagName("select");
	if(IE6) {
		if(selectObj) {
			for (var i=0; i<selectObj.length; i++) {
				selectObj[i].style.visibility ="visible";
			}
		}
	}
}

// ÅÇÅä±Û
function tabtoggle(obj,tab,tnum){
	if(tab=='random'){
		var rnum = Math.floor(Math.random() * tnum) + 1;
		tab = rnum;
	}
	var tab_list = document.getElementById(obj).getElementsByTagName('li');
	var split = obj.split('_');
	for(i=1;i<=tab_list.length;i++){
		var imgEl=tab_list[i-1].getElementsByTagName("img").item(0);
		imgEl.src = (tab==i)? imgEl.src.replace("off.gif", "on.gif"):imgEl.src.replace("on.gif", "off.gif");
		document.getElementById('tab_con'+split[2]+'_'+i).style.display = (tab==i)? 'block' : 'none';
		//(tab==i)?tab_list[i-1].className='on':tab_list[i-1].className='';
	}
}
function tabtoggletxt(obj,tab,tnum){
	var tab_list = document.getElementById(obj).getElementsByTagName('li');
	var split = obj.split('_');
	for(i=1;i<=tab_list.length;i++){
		var imgEl=tab_list[i-1].getElementsByTagName("img").item(0);
		imgEl.src = (tab==i)? imgEl.src.replace("off.gif", "on.gif"):imgEl.src.replace("on.gif", "off.gif");
		(tab==i)?tab_list[i-1].className='on':tab_list[i-1].className='';
		document.getElementById('tab_con'+split[2]+'_'+i).style.display = (tab==i)? 'block' : 'none';
	}
}

// ´ëºÐ·ù ±âÈ¹Àü ÅÇÅä±Û
function tabplan(obj,total,tab){
	var tab_list = document.getElementById(obj).getElementsByTagName('li');
	for(i=1;i<=tab_list.length;i++){
		var imgEl=tab_list[i-1].getElementsByTagName("img").item(0);
		imgEl.src = (tab==i)? imgEl.src.replace("off.gif", "on.gif"):imgEl.src.replace("on.gif", "off.gif");
		(tab==i)?tab_list[i-1].className='on':tab_list[i-1].className='';
	}
	if(tab==1){
		for(a=1;a<=total;a++){
			document.getElementById('tab_plan_'+a).className = 'planbnr';
			tabtoggleplan('tab_plan_'+a,1,'close');
		}
	} else {
		for(b=1;b<=total;b++){
			document.getElementById('tab_plan_'+b).className = 'planbnr_on';
			tabtoggleplan('tab_plan_'+b,1);
		}
	}
}
function tabplan2(obj,total,tab){
	var tab_list = document.getElementById(obj).getElementsByTagName('li');
	for(i=1;i<=tab_list.length;i++){
		var imgEl=tab_list[i-1].getElementsByTagName("img").item(0);
		imgEl.src = (tab==i)? imgEl.src.replace("off.gif", "on.gif"):imgEl.src.replace("on.gif", "off.gif");
		(tab==i)?tab_list[i-1].className='on':tab_list[i-1].className='';
	}
	if(tab==1){
		for(a=3;a<=total+2;a++){
			document.getElementById('tab_plan_'+a).className = 'planbnr';
			tabtoggleplan('tab_plan_'+a,1,'close');
		}
	} else {
		for(b=3;b<=total+2;b++){
			document.getElementById('tab_plan_'+b).className = 'planbnr_on';
			tabtoggleplan('tab_plan_'+b,1);
		}
	}
}
function tabtoggleplan(obj,tab,close){
	if(document.getElementById(obj).className == 'planbnr_on' || close=='close') {
		var tab_list = document.getElementById(obj).getElementsByTagName('li');
		var split = obj.split('_');
		for(i=1;i<=tab_list.length;i++){
			var liClass = tab_list[i-1].className;
			if(tab==i){
				if(i==5){
					tab_list[i-1].className = 'last on';
				} else {
					tab_list[i-1].className = 'on';
				}
			} else {
				if(i==5){
					tab_list[i-1].className = 'last';
				} else {
					tab_list[i-1].className = '';
				}
			}
			if(close=='close'){
				document.getElementById('tab_pon'+split[2]+'_'+i).style.display = 'none';
			} else {
				document.getElementById('tab_pon'+split[2]+'_'+i).style.display = (tab==i)? 'block' : 'none';
			}
		}
	}
}

// ÇÃ·¡½¬
function swfprint(objid,furl,fwidth,fheight,transoption,flashvars) {
	var ieTxt = '<object id="'+ objid +'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" width="'+ fwidth +'" height="' + fheight +'" align="middle">';
	ieTxt += '<param name="allowScriptAccess" value="always"/>';
	ieTxt += '<param name="movie" value="'+ furl +'"/>';
	ieTxt += '<param name="quality" value="high"/>';
	ieTxt += '<param name="bgcolor" value="#ffffff"/> ';
	ieTxt += '<param name="menu" value="false"/> ';
	if (flashvars) ieTxt += '<param name="flashVars" value="'+ flashvars +'">';
	if (transoption == "t") {
		ieTxt += '<param name="wmode" value="transparent"/>';
	} else if	(transoption == "o") {
		ieTxt += '<param name="wmode" value="opaque"/>';
	}
	ieTxt += '</object>';

	var ffTxt = '<object id="'+ objid +'" type="application/x-shockwave-flash" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'"  menu="false" ';
	if (flashvars) ffTxt += ' flashVars="'+ flashvars +'" ';
	if (transoption == "t")	{
		ffTxt += ' wmode="transparent"';
	} else if	(transoption == "o")	{
		ffTxt += ' wmode="opaque"';
	}
	ffTxt +='allowScriptAccess="always"';
	ffTxt += '></object>';

	if(appname=="IE") document.write(ieTxt);
	else  document.write(ffTxt);
}

// png
function setpng24(obj) {
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter =	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+obj.src+"',sizingMethod='image');"
//	obj.src='';
	return '';
}

//display block/none
function disblock(obj){
	var div = document.getElementById(obj);
	if(obj=='selectlist') {
		var obj1 = document.getElementById('spanactivex1');
		var obj2 = document.getElementById('viewTvObjectIframe');
		var obj3 = document.getElementById('tvIncHighFrame');
		if(obj1){
			document.getElementById('spanactivex1').style.position = 'absolute';
			document.getElementById('spanactivex1').style.top = '-1000px';
		}
		if(obj2) obj2.contentWindow.document.getElementById('SeeLive').style.marginTop = '-300px';
		if(obj3){
			obj3.contentWindow.document.getElementById('tvIncHigh').style.position = 'absolute';
			obj3.contentWindow.document.getElementById('tvIncHigh').style.top = '-1000px';
		}
	}
	div.style.display = 'block';
}
function disnone(obj){
	var div = document.getElementById(obj);
	if(obj=='selectlist') {
		var obj1 = document.getElementById('spanactivex1');
		var obj2 = document.getElementById('viewTvObjectIframe');
		var obj3 = document.getElementById('tvIncHighFrame');
		if(obj1){
			document.getElementById('spanactivex1').style.position = 'static';
			document.getElementById('spanactivex1').style.top = '0';
		}
		if(obj2) obj2.contentWindow.document.getElementById('SeeLive').style.marginTop = '0px';
		if(obj3){
			obj3.contentWindow.document.getElementById('tvIncHigh').style.position = 'static';
			obj3.contentWindow.document.getElementById('tvIncHigh').style.top = '0px';
		}
	}
	div.style.display = 'none';
}

/*¸¸µçÀÌ : mins01,mins,°ø´ë¿©ÀÚ´Â ¿¹»Ú´Ù ·Ñ¸µ*/
var js_rolling = function(this_s){
	// ½Ã°£´ÜÀ§´Â ms·Î 1000ÀÌ 1ÃÊ
	if(this_s.nodeType==1){
		this.this_s = this_s;
	}else{
		this.this_s = document.getElementById(this_s);
	}
	this.is_rolling = false;
	this.direction = 1; //1:top, 2:right, 3:bottom, 4:left (½Ã°è¹æÇâ) // 1¹ø°ú 4¹ø¸¸ µÊ
	this.children =	null;
	this.move_gap = 1;	//¿òÁ÷ÀÌ´Â ÇÈ¼¿´ÜÀ§
	this.time_dealy = 100; //¿òÁ÷ÀÌ´Â Å¸ÀÓµô·¹ÀÌ
	this.time_dealy_pause = 1000;//ÇÏ³ªÀÇ ´ë»óÀÌ »õ·Î ½ÃÀÛÇÒ ¶§ ¸ØÃß´Â ½Ã°£, 0 ÀÌ¸é Àû¿ë ¾ÈÇÔ
	this.time_timer=null;
	this.time_timer_pause=null;
	this.mouseover=false;
	this.init();
	this.set_direction(this.direction);
}
js_rolling.prototype.init = function(){
	this.this_s.style.position='';
	this.this_s.style.overflow='hidden';
	var children = this.this_s.childNodes;
	for(var i=(children.length-1);0<=i;i--){
		if(children[i].nodeType==1){
			children[i].style.position='';
		}else{
			this.this_s.removeChild(children[i]);
		}
	}
	var this_s=this;
	this.this_s.onmouseover=function(){
		this_s.mouseover=true;
		if(!this_s.time_timer_pause){
			this_s.pause();
		}
	}
	this.this_s.onmouseout=function(){
		this_s.mouseover=false;
		if(!this_s.time_timer_pause){
			this_s.resume();
		}
	}
}
js_rolling.prototype.set_direction = function(direction, check){
	this.direction=direction;
	if((this.direction==2 ||this.direction==4) && check!=1){
		this.this_s.style.whiteSpace='nowrap';
	}else{
		this.this_s.style.whiteSpace='normal';
	}
	var children = this.this_s.childNodes;
	for(var i=(children.length-1);0<=i;i--){
			if(this.direction==1){
				children[i].style.display='block';
			}else if(this.direction==2){
				children[i].style.textlign='right';
				children[i].style.display='inline';
			}else if(this.direction==3){
				children[i].style.display='block';
			}else if(this.direction==4){
				children[i].style.display='inline';
			}
	}
	this.init_element_children();
}
js_rolling.prototype.init_element_children = function(){
	var children = this.this_s.childNodes;
	this.children = children;
	for(var i=(children.length-1);0<=i;i--){
			if(this.direction==1){
				children[i].style.top='0px';
			}else if(this.direction==2){
				children[i].style.left='-'+this.this_s.firstChild.offsetWidth+'px';
			}else if(this.direction==3){
				children[i].style.top='-'+this.this_s.firstChild.offsetHeight+'px';
			}else if(this.direction==4){
				children[i].style.left='0px';
			}
	}
}
js_rolling.prototype.act_move_up = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.top=(parseInt(child.style.top)-this.move_gap)+'px';
	}
	if((this.children[0].offsetHeight+parseInt(this.children[0].style.top))<=0){
		this.this_s.appendChild(this.children[0]);
		this.init_element_children();
		this.pause_act();
	}
}
js_rolling.prototype.move_up = function(){
	if(this.direction!=1&&this.direction!=3){return false;}
	this.this_s.appendChild(this.children[0]);
	this.init_element_children();
	this.pause_act();
}
js_rolling.prototype.act_move_down = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.top=(parseInt(child.style.top)+this.move_gap)+'px';
	}
	if(parseInt(this.children[0].style.top)>=0){
		this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
		this.init_element_children();
		this.pause_act();
	}
}
js_rolling.prototype.move_down = function(){
	if(this.direction!=1&&this.direction!=3){return false;}
	this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
	this.init_element_children();
	this.pause_act();
}
js_rolling.prototype.act_move_left = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.left=(parseInt(child.style.left)-this.move_gap)+'px';
	}
	if((this.children[0].offsetWidth+parseInt(this.children[0].style.left))<=0){
		this.this_s.appendChild(this.this_s.firstChild);
		this.init_element_children();
		this.pause_act();
	}
}
js_rolling.prototype.move_left = function(){
	if(this.direction!=2&&this.direction!=4){return false;}
	this.this_s.appendChild(this.this_s.firstChild);
	this.init_element_children();
	this.pause_act();
}
js_rolling.prototype.act_move_right = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.left=(parseInt(child.style.left)+this.move_gap)+'px';
	}

	if(parseInt(this.this_s.lastChild.style.left)>=0){
		this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
		this.init_element_children();
		this.pause_act();
	}
}
js_rolling.prototype.move_right = function(){
	if(this.direction!=2&&this.direction!=4){return false;}
	this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
	this.init_element_children();
	this.pause_act();
}
js_rolling.prototype.start = function(){ //·Ñ¸µ ½ÃÀÛ
	var this_s = this;
	this.stop();
	this.is_rolling = true;
	var act = function(){
		if(this_s.is_rolling){
			if(this_s.direction==1){this_s.act_move_up();}
			else if(this_s.direction==2){this_s.act_move_right();}
			else if(this_s.direction==3){this_s.act_move_down();}
			else if(this_s.direction==4){this_s.act_move_left();}
		}
	}
	this.time_timer = setInterval(act,this.time_dealy);
}
js_rolling.prototype.pause_act = function(){ //ÀÏ½Ã µ¿ÀÛ
	if(this.time_dealy_pause){
		var this_s = this;
		var act = function(){this_s.resume();this_s.time_timer_pause=null;}
		if(this.time_timer_pause){clearTimeout(this.time_timer_pause);}
		this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
		this.pause();
	}
}
js_rolling.prototype.pause = function(){ //ÀÏ½Ã ¸ØÃã
	this.is_rolling = false;
}
js_rolling.prototype.resume = function(){ //ÀÏ½Ã ¸ØÃã ÇØÁ¦
	if(!this.mouseover){
		this.is_rolling = true;
	}
}
js_rolling.prototype.stop = function(){ //·Ñ¸µÀ» ³¡³¿
	this.is_rolling = false;
	if(!this.time_timer){
		clearInterval(this.time_timer);
	}
	this.time_timer = null
}