//롤링배너
function rollingbanner(myurl, mywidth, myheight, isscroll) {
	//alert("mywidth="+mywidth+"- myheight="+myheight+"- isscroll="+isscroll+"- myurl="+myurl);
	if(mywidth == "0" && myheight == "0") {
		if(isscroll == "0" ) {
			document.location.href= myurl;
		} else {
			window.open(myurl,"_blank");
		}
	} else {
		open_popup(myurl,mywidth,myheight,isscroll,"lolgamebanner" );
	}
}

/* 로그인 도움말 */
function ncShowLoginX(e)
{
	var eX;
	if (window.event)
	{
		if (document.documentElement.clientWidth) eX = event.clientX + document.documentElement.scrollLeft;
		else eX = event.clientX + document.body.scrollLeft;
	}
	else
	{
		eX = e.pageX;
	}
	return eX;
}

function ncShowLoginY(e)
{
	var eY;
	if (window.event)
	{
		if (document.documentElement.clientHeight) eY = event.clientY + document.documentElement.scrollTop;
		else eY = event.clientY + document.body.scrollTop;
	}
	else
	{
		eY = e.pageY;
	}
	return eY;
}

function ncShowLogin(e,layername) {
	var x = ncShowLoginX(e);
	var y = ncShowLoginY(e);

	if(layername == "logintip1"){
		document.getElementById("logintip1").style.display = "block";
		document.getElementById("logintip1").style.top = y + "px";
		document.getElementById("logintip1").style.left = x + "px";
	}else{
		document.getElementById("logintip2").style.display = "block";
		document.getElementById("logintip2").style.top = y + "px";
		document.getElementById("logintip2").style.left = x + "px";
	}
}

function hideAll(){
	document.getElementById("logintip1").style.display = "none";
	document.getElementById("logintip2").style.display = "none";
}
 


//메인-스튜디오7노트 
var RollingDisplay = function(cid,count,interval,n) {
	this.cid = cid;
	this.count = count;
	if(n == "random")this.n = Math.floor(Math.random() * (this.count) + 1);
	else this.n = (n)? n:"1";
	this.onchange = null;

	for(var k=1; k<=this.count; k++) document.getElementById(this.cid+"_"+k).style.display="none";
	document.getElementById(this.cid+"_"+this.n).style.display="block";

	this.div = document.getElementById(this.cid);
	this.div.onmouseover = function(){this.isover=true; }
	this.div.onmouseout  = function(){this.isover=false;}
	this.btn_next = document.getElementById("btn_"+this.cid+"_next");
	this.btn_prev = document.getElementById("btn_"+this.cid+"_prev");
	
	if(document.getElementById(this.cid + "_current")){
		this.currentPageDiv = document.getElementById(this.cid + "_current");	
		this.currentPageDiv.innerHTML = "<strong id='"+ this.cid +"_count'>"+this.n+"</strong> /&nbsp;" + count;	
		this.currentPage = document.getElementById(this.cid + "_count");
	}

	var self=this;
	if(this.btn_next) this.btn_next.onclick=function(){self.next() }
	if(this.btn_prev) this.btn_prev.onclick=function(){self.prev() }
	//if(interval > 0) setInterval(function(){self.play()}, interval);
}
RollingDisplay.prototype = {
	play : function(){
		if(this.div.isover) return;
		this.next();
	},	
	prev : function(){
		document.getElementById(this.cid+"_"+this.n).style.display="none";
		this.n=(this.n==1)?this.count:--this.n;
		document.getElementById(this.cid+"_"+this.n).style.display="block";	
		if(document.getElementById(this.cid + "_current")){this.currentPage.innerText = this.n;}
	},
	next : function(){		
		document.getElementById(this.cid+"_"+this.n).style.display="none";
		this.n=(this.n==this.count)? 1:++this.n;
		document.getElementById(this.cid+"_"+this.n).style.display="block";
		if(document.getElementById(this.cid + "_current")){this.currentPage.innerText = this.n;}
	}
};
 
/* 메인-공지사항 */
function toggleMenu_notice(menu, sub) {
	var toggleid = document.getElementById(menu);
	var togglediv = sub.split('.');
	var togglesub = toggleid.getElementsByTagName(togglediv[0]);
	this.openContents = function() {
		var currentmenu = navigator.userAgent.indexOf("MSIE") == -1 ? this.nextSibling.nextSibling : this.nextSibling;
		var menustatus = currentmenu.style.display == 'block' ? 1 : 0;
		var closemenu = this.parentNode.getElementsByTagName(currentmenu.tagName);
		for (i=0;i<closemenu.length;i++) {
			closemenu[i].style.display = 'none';
		}
		for (i=0;i<togglesub.length;i++) {
			togglesub[i].className = togglesub[i].className.replace("on", "");
		}
		if (menustatus) return;
		this.className += "on";
		currentmenu.style.display = 'block';
	};
	for (i=0;i<togglesub.length;i++) {
		if (togglediv[1]) {
			if (togglesub[i].className != togglediv[1]) {
				togglesub[i].onclick = this.openContents;
			}
		}
		else {
			togglesub[i].onclick = this.openContents;
		}
	}
}

/* 프론티어테스트 */
function frontiereTester () {
	var url = '/event/proposal/tester/isTester';
	try {
		new Ajax.Request(
			url,
			{	method:'post',
				encoding:'UTF-8',
				onComplete: function(result) {
					if (result.responseText.trim() == '-1') {
						alert('로그인이 필요한 서비스 입니다.');
						GNBLogin();
					} else if (result.responseText.trim() == 'true') {
						alert('이미 스틸독 프런티어 테스터로 당첨되셨습니다.\n테스트는 5월 28일부터 6월 1일까지 평일\n03:00~22:00 주말 02:00~22:00에 진행됩니다.\n감사합니다.');
					} else {
						window.open ('/event/proposal/090518_tester','tester','width=400,height=222,toolbar=0,status=no,scrollbars=no,resizable=0');
					}
				},
				onFailure: function() {
					alert('테스터 정보를 가져오지 못했습니다.\n잠시 후에 다시 시도해주시기 바랍니다.');
				}
			}
		);
	} catch(e) {
		alert(e.description);
	}
}

/* 동영상 플레이어 스킨 */
function playncPlayer(movieCode, playerWidth, playerHeight, autostart){
	if(isNaN(Number(playerWidth)) || isNaN(Number(playerHeight)) || playerWidth<320 || playerHeight<240) {
		playerWidth = 320;
		playerHeight = 240;
	}
	if(autostart!=1) autostart=3;
	else autostart=0;
	document.write('<OBJECT WIDTH='+playerWidth+' HEIGHT='+playerHeight+' id="playncPlayer"><PARAM NAME="movie" VALUE="http://static.plaync.co.kr/plaza/pcc/view/viewskin_s.swf?logo_sta='+autostart+'&movie_id='+movieCode+'">');
	document.write('<PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="#FFF"><PARAM NAME="wmode" VALUE="window"><PARAM NAME="allowFullScreen" VALUE="true">');
	document.write('<EMBED src="http://static.plaync.co.kr/lineage_v2/multimedia/playncPlayer_skin.swf?logo_sta='+autostart+'&movie_id='+movieCode+'" allowFullScreen="true" quality="high" bgcolor="#FFF" WIDTH='+playerWidth+' HEIGHT='+playerHeight+' NAME="playncPlayer"></EMBED></OBJECT>');
}


/*
function gstarMoviePlayer(movieCode, playerWidth, playerHeight){if(isNaN(Number(playerWidth)) || isNaN(Number(playerHeight)) || playerWidth<320 || playerHeight<240) {playerWidth = 320;playerHeight = 240;}
	document.write('<div class="movie_player">');
	document.write('<OBJECT WIDTH='+playerWidth+' HEIGHT='+playerHeight+' id="playncPlayer"><PARAM NAME="movie" VALUE="http://static.plaync.co.kr/plaza/pcc/view/viewskin_s.swf?logo_sta=3&movie_id='+movieCode+'&allowfullscreen=true">');
	document.write('<PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="#FFF"><PARAM NAME="wmode" VALUE="window"><PARAM NAME="allowFullScreen" VALUE="true">');
	document.write('<EMBED src="http://static.plaync.co.kr/plaza/pcc/view/viewskin_s.swf?logo_sta=3&movie_id='+movieCode+'&allowfullscreen=true" quality="high" bgcolor="#FFF" WIDTH='+playerWidth+' HEIGHT='+playerHeight+' NAME="playncPlayer" allowFullScreen="true"></EMBED></OBJECT>');
	document.write('</div>');
}; 
*/

//100504 showFlash
var isFlashInstalled=0;
function flashvalidator() {
	if (isFlashInstalled!==0) return isFlashInstalled;
	var agent=navigator.userAgent.toLowerCase();
	isFlashInstalled = true;
	if (agent.indexOf('msie')!=-1) {
		isFlashInstalled = true;	
	} else {
		if (!(typeof !navigator.plugins && typeof navigator.plugins['Shockwave Flash'] == 'object')) 
			isFlashInstalled = false;
	}
	return isFlashInstalled;
}

function showFlash() {
if (flashvalidator()===false) {
if (typeof arguments[1]=='object') {
if (arguments[1]['css']!='') {
var css = document.createElement('link');
css.setAttribute('rel', 'stylesheet')
css.setAttribute('type', 'text/css');
css.setAttribute('href', arguments[1]['css']);
document.getElementsByTagName('head')[0].appendChild(css);
}
if (arguments[1]['type'] == 'src') {
document.writeln('<div id=\"'+ arguments[1]['target'] +'\"></div>')
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', arguments[1]['content']);
document.getElementsByTagName('head')[0].appendChild(script);
} else {
document.write(arguments[1]['content']);
}
}
return false;
}
var Options=(arguments.length>0) ? arguments[0] : {};
var Default={
id:'ShockwaveFlash1',
movie:'',
menu:'false',
scale:'noscale',
allowFullScreen:'false',
allowScriptAccess:'always',
width:'0',
height:'0',
quality:'high',
wmode:'transparent',
bgcolor:'',
xml:false
};
for (var attr in Default) {
if (typeof Options[attr]=='undefined')
Options[attr]=Default[attr];
}
if (Options['xml']!==false)
Options['movie']=Options['movie'] + ((Options['movie'].match(/=/)) ? '&' : '?') + 'server=' + Options['xml'] + '&chkMovie=0'; 
var docProtocol=(location.href.indexOf('https')==0) ? 'https' : 'http';
var SwfMarkUp=[];
SwfMarkUp.push('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+docProtocol+'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" width="'+Options['width']+'" height="'+Options['height']+'" id="'+Options['id']+'" align="middle">');
for (var key in Options) {
if (key!='id'&&key!='xml')
SwfMarkUp.push('<param name=\"' + key + '\" value=\"' + Options[key] + '\" />');
}
SwfMarkUp.push('<param name="wmode" value=\"' + Options['wmode'] + '\" />');
SwfMarkUp.push('<param name="allowScriptAccess" value=\"always\" />');
SwfMarkUp.push('<param name="menu" value="false" />');
SwfMarkUp.push('<param name="quality" value="high" />');
SwfMarkUp.push('<embed src="'+Options['movie']+'" allowScriptAccess="always" menu="false" quality="high" bgcolor="'+Options['bgcolor']+'" wmode="'+Options['wmode']+'" width="'+Options['width']+'" height="'+Options['height']+'" name="'+Options['id']+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
SwfMarkUp.push('</object>');
document.write(SwfMarkUp.join(''));
}
// Prototype.js Referenced(noneflash)
function insertAltContent(target, content) {
	if (!$(target)) return;
	$(target).insert({after:content});
	$(target).remove();
}