//document.domain='gomtv.com';
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/gi, "");
}
var j$ = jQuery.noConflict();//$ÇÔ¼ö°¡ °ãÄ¡Áö ¾Ê°Ô

/*
* add ÇØÁÖ´Â ÇÔ¼ö´Â oncomplete½Ã ajaxQue.playNext();¸¦ È£ÃâÇØ¾ß ÇÑ´Ù.
*/
var ajaxQue={
/* private property */
	index : -1,//ÇöÀçÀÛ¾÷¹øÈ£
	count : 0,//ÀüÃ¼°³¼ö
	isplaying : 0,//ÇöÀç ÀÛ¾÷ ÁßÀÎ°¡
	arrAjaxQue : new Array(),//eval()·Î Ã³¸®ÇÒ string
// public
	add : function(str) {
		this.arrAjaxQue[this.count]=str;
		this.count++;
	},
	play : function(){
		if(this.isplaying){
			return false;
		}
		this.isplaying=1;
		this.index++;
		if(this.arrAjaxQue[this.index]){
			eval(this.arrAjaxQue[this.index]);
		}
	},
	addAndPlay : function(str) {
		this.add(str);
		if(!this.isplaying){
			this.play();
		}
	},
	playNext : function(){
		this.isplaying=0;
		this.play();
	}
// private
};

// class ¹ÌÀû¿ë½Ã Àû¿ë, Àû¿ëÀÌ µÇ¾îÀÖÀ¸¸é ¹ÌÀû¿ë
var toggleJs  =function(jType, id, className){
	if(jType == 'class'){
		j$(id).toggleClass(className);
	}else if(jType == 'attr'){
		j$(id).toggle();
	}
}

// class ¹ÌÀû¿ë½Ã Àû¿ë, Àû¿ëÀÌ µÇ¾îÀÖÀ¸¸é ¹ÌÀû¿ë
var toggleButton  =function(jType, id, className){
	if(jType == 'class'){
		j$(id).toggleClass(className);
	}else if(jType == 'attr'){
		j$(id).toggle();
		j$(id + " " +".mdbtn_series_high").hide();
		j$(id + " " +".mdbtn_series_low").hide();
	}
}

var axShowPlayBtn = function(type, no){
	if(!no){
		var btnid="#piece"+type;
	}else{
		var btnid="#seriespiece"+type+no;
	}
	j$(".mdbtn_series_high").hide();
	j$(".mdbtn_series_low").hide();
	if(type)
		j$(btnid).show();
}

var axShowSeries = function(no){
	if(j$("#series_"+no).css("display")=="none")
		var show=1;
	j$(".mdbtn_gr_ly").hide();
	if(show){
		j$("#series_"+no).show();
		j$("#series_"+no+" .btn_highs").focus();
	}
	//1ºÎ,2ºÎ...
	j$(".mdbtn_series_high").hide();
	j$(".mdbtn_series_low").hide();
}

var imgToggle = function(id, src, src2){
	if(j$("#"+id).attr("src")==src){
		j$("#"+id).attr("src",src2);
	}else{
		j$("#"+id).attr("src",src);
	}
}

var switchLayer = function(id1, id2){
	j$(id1).show();
	j$(id2).hide();
}

function LayerTab(layer1,layer2){
	document.getElementById(layer1).style.display = "block";
	document.getElementById(layer2).style.display = "none";
}

var viewresize = function(){
	try
	{
		if(top.document.getElementById('gomFrame'))
		{
			top.document.getElementById('gomFrame').style.height = document.body.scrollHeight;//iframe »çÀÌÁî Á¶Àý
		}
	}
	catch (e1)
	{
	}
}

var goLocationHash = function(id){
	self.location.hash=id;
}

function openWindow(url)
{
	var dsi = getCookieAutoPlay( 'dsi');
	var URL;
	if(dsi == '') {
		URL = url;
	}else{
		URL = 'http://tv.gomtv.com/gotoweb.cgi?key='+dsi+'&returl=' + escape(url);
	}
	window.open( URL );
}

function openWindowFix(url,name,width,height)
{
	var dsi = getCookieAutoPlay( 'dsi');
	var URL;
	if(dsi == '') {
		URL = url;
	}else{
		URL = 'http://tv.gomtv.com/gotoweb.cgi?key='+dsi+'&returl=' + escape(url);
	}
	window.open( URL,name, 'width='+width+',height='+height+',menubars=no,scrollbars=no');
}

// ´Ù¿î·Îµå °ü·Ã ½ºÅ©¸³Æ®
var setDownKey = function(systype,dispid,number){
	var url = "http://dstore.gomtv.com/include/appDownPop.gom";
	var NumString = /[0-9]/g		// ¼ýÀÚ
	if(number == 'all'){
		var param = "number=all";
		param += "&systype="+systype;
		param += "&dispid="+dispid;
	}else if(number.match(NumString)){
		var param = "systype="+systype;
		param += "&dispid="+dispid;
		param += "&number="+number;
	}else{
		var param = j$('dnfm').serialize();
		param += "&systype="+systype;
		param += "&dispid="+dispid;
	}
	var path = url+"?"+param;
	openWindowFix(path,"gomtv",420,285);
	return false;
}


// ´Ù¿î·Îµå °ü·Ã ½ºÅ©¸³Æ®
var setNewDownKey = function(systype,fileid,dispid,vodid){
	var url = "http://www.gomtv.com/order/order.gom?ordertype=MovieDownload";
	var NumString = /[0-9]/g		 // ¼ýÀÚ
	if(fileid.match(NumString)){
		var param = "systype="+systype;
		param += "&fileid="+fileid;
		param += "&dispid="+dispid;
		param += "&vodid="+vodid;
	}
	var path = url+"&"+param;
	window.open( path,"cashBill", 'width=425,height=290,menubars=no,scrollbars=auto,top=0');
	return false;
}

var afterLogin = function(){
	window.location.reload();
}


/* ¸¶´Ã/¾ÆÀÌÅÛ ¼±¹°ÇÏ±â */
var showNameLayer = false;         //·¹ÀÌ¾î³ëÃâ¿©ºÎ
var showNametype = 0;                 //·¹ÀÌ¾îÅ¬¸¯À§Ä¡ 0ÀÌ¸é, ´Ð³×ÀÓÀÌ¿Ü - 1ÀÌ¸é, ´Ð³×ÀÓ
function fncCloseGarlic()              //¹Ùµð¸¦ Å¬¸¯ÇÏ¸é ¹«Á¶°Ç ½ÇÇàµÈ´Ù.
{
	if(showNameLayer == true && showNametype == 0)
	{
		document.getElementById('web_gift_layer').style.display = 'none';
	}
	else if(showNametype==1)
		showNametype = 0;
}
function fncClickGarlic(value, e)        //´Ð³×ÀÓÀ» Å¬¸¯½Ã È£Ãâ
{
	//Å¬¸¯ À§Ä¡ ¾Ë¾Æ³»±â
	var keyvalue = value;
	var layerx = 0;
	var layery = 0;

	layerx = (document.body.scrollLeft) + e.clientX;
	layery = (document.body.scrollTop) + e.clientY;

	document.getElementById('web_gift_layer').style.left = layerx;
	document.getElementById('web_gift_layer').style.top = layery;
	document.getElementById('web_gift_layer').style.display = 'block';
	document.getElementById('giftKeyValue').value = keyvalue;
	showNameLayer = true;
	showNametype = 1;
}
function fncGiftUser(type)              //ÆË¾÷ Ã¢ÀÌ ¿­¸³´Ï´Ù.
{
	var keyvalue = document.getElementById('giftKeyValue').value;
	if(type==1)
	{
		window.open('http://pay.gomtv.com/cgi-bin/pay/gift/sendGiftForm.cgi?userid='+keyvalue,'GOMTV_POP','420','420');
	}
	if(type==2)
	{
		window.open('http://pay.gomtv.com/cgi-bin/pay/item/giftItemForm.cgi?userid='+keyvalue,'GOMTV_POP','420','420');
	}
	return;
}
/* ¸¶´Ã/¾ÆÀÌÅÛ ¼±¹°ÇÏ±â */

// tr ·Ñ¿À¹ö //
function fnBackColor(obj,color){
	obj.style.background = color;
}

function gomtvPop(url,width,height){
	window.open(url,'gomtv','width='+width+',height='+height+',scrollbars=auto,menubars=no');
}

function frameLogin(){
	var returl = document.URL;
	returl = escape(returl);
	try
	{
		if(!top.document.getElementById('gomFrame'))
		{
			document.location.href = 'http://private.gomtv.com/cgi-bin/login.cgi?returl=' + returl;
		}else{
			top.pLogin();
		}
	}
	catch (e1)
	{
	}
}
