
//IE6 Flicker Bug
try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}

// 공통 플래쉬
function Cji_Flash(Url, wd, ht, swfId, wm, vars) {// 경로,가로,세로,ID,투명,변수
	var TxtSwf = "" ;
	TxtSwf += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='"+ wd +"' height='"+ ht +"' id='"+ swfId +"'>" ;
	TxtSwf += "<param name='movie' value='"+ Url +"'>" ;
	TxtSwf += "<param name='wmode' value='"+ wm +"'>" ;
	TxtSwf += "<param name='FlashVars' value='" + vars + "'>" ;
	TxtSwf += "<param name='allowScriptAccess' value='always'>" ;
	TxtSwf += "<param name='allowFullScreen' value='true'>" ;
	TxtSwf += "<param name='quality' value='high'>" ;
	TxtSwf += "<param name='menu' value='false'>" ;
	TxtSwf += "<embed src='"+ Url +"' width='"+ wd +"' height='"+ ht +"' wmode='"+ wm +"' name='"+ swfId +"' FlashVars='"+ vars +"' allowScriptAccess='always' allowFullScreen='true'  quality='high' menu='false' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>" ;
	TxtSwf += "</object>" ;
	document.write (TxtSwf);
}

function Cji_DivShow(div_id){
	document.getElementById(div_id).style.display = "block"; 
}
function Cji_DivHide(div_id){
	document.getElementById(div_id).style.display = "none"; 
}

function toggleScribe(el) {
	if(el.className == "b_scribe"){
		el.className = "b_scribe on";
		el.innerHTML = "Subscribed";
	}
	else{
	el.className = "b_scribe";
	el.innerHTML = "Subscribe";
	}
}


var rolling={

	init : function(dt,at,tagId,it,ct) {
		delayTime=dt;
		aniTime=at;
		id=tagId;
		imgTag=it;
		cntTag=ct;
		sCnt=0;
		hCnt=0;
		nOpacity=1;
		nIEOpacity=100;
		flag=0;
		sTimer=null;
		interval=null;
		maxCnt = cntTag.length-1;
		for(var i = 0; i < it.length; i++) {
			if(navigator.appName == "Microsoft Internet Explorer"){
				it[i].getElementsByTagName('div')[0].filters.item("DXImageTransform.Microsoft.Alpha").opacity=100;
			} else {
				it[i].getElementsByTagName('div')[0].style.opacity=1;
			}
		}
		
		if(navigator.appName == "Microsoft Internet Explorer"){
			it[0].getElementsByTagName('div')[0].filters.item("DXImageTransform.Microsoft.Alpha").opacity=0;
		} else {
			it[0].getElementsByTagName('div')[0].style.opacity=0;
		}

		rolling.navi(0,'nOpacity');
	},
	calOp : function(_obj) {
		if(navigator.appName == "Microsoft Internet Explorer") {
			nIEOpacity=_obj.filters.item("DXImageTransform.Microsoft.Alpha").opacity;
			if(nIEOpacity >= 0) {
				nIEOpacity -= 0.2;
				_obj.filters.item("DXImageTransform.Microsoft.Alpha").opacity=parseInt(nIEOpacity);
			} else {
				_obj.filters.item("DXImageTransform.Microsoft.Alpha").opacity=0;
			}
		} else {
			nOpacity = _obj.style.opacity;
			if(nOpacity > 0) {
				nOpacity -= 0.010;
				_obj.style.opacity = nOpacity;
			} else {
				nOpacity = 0;
				_obj.style.opacity = nOpacity;
			}
		}

	},
	navi : function(n,flag) {
		clearInterval(interval);


		if(flag=='click') {
			for(var i = 0; i < imgTag.length; i++) {
				imgTag[i].style.display='none';
				cntTag[i].className = '';
	
				if(!imgTag[hCnt].getElementsByTagName('div')[0].style.opacity) {
					imgTag[i].getElementsByTagName('div')[0].filters.item("DXImageTransform.Microsoft.Alpha").opacity=100;
				} else {
					imgTag[i].getElementsByTagName('div')[0].style.opacity=1;
				}
			}
			if(sTimer) {clearTimeout(sTimer);}
			if(interval) clearInterval(interval);
		}

		if(maxCnt >= n) {
			if(n>0){
				cntTag[n-1].className = '';
				imgTag[n-1].style.display='none';
				
				hCnt = n - 1;
			}
			cntTag[n].className = 'on';
			imgTag[n].style.display='block';
			sCnt = n;
		} else {
			n=0;
			cntTag[maxCnt].className = '';
			cntTag[0].className = 'on';
			imgTag[maxCnt].style.display='none';
			imgTag[0].style.display='block';
			sCnt = n;

			hCnt = maxCnt;
		}
		if(flag!='nOpacity'){
			if(navigator.appName == "Microsoft Internet Explorer") {
				imgTag[hCnt].getElementsByTagName('div')[0].filters.item("DXImageTransform.Microsoft.Alpha").opacity=100;
			} else {
				imgTag[hCnt].getElementsByTagName('div')[0].style.opacity=1;
			}
		}

		interval = setInterval(function() {
			rolling.calOp(imgTag[sCnt].getElementsByTagName('div')[0]);
		}, aniTime);

		n=n+1;
		
		rolling.timer(n);

	},
	timer : function(n) {
		sTimer = setTimeout(function() {
			rolling.navi(n);
		}, delayTime);
	},
	stopRolling : function() {
		clearTimeout(sTimer);
	}
}


$.noConflict();
jQuery(document).ready(function($){	
	 jQuery(".signbox input").focus(function () {
         if(jQuery(this).hasClass("off")){
			 jQuery(this).removeClass("off");
		 }
		 jQuery(this).addClass("on");
    });
	 jQuery(".signbox input").focusout(function () {
         if(jQuery(this).attr('value') == ''){
			 jQuery(this).removeClass("on");
		 }
		 else{
			 jQuery(this).removeClass("on");
			 jQuery(this).addClass("off");
		 }
    });
	/*jQuery(".fr_subscript .sorting").each(function(idx) {
			jQuery(this).bind("mouseover",function() {
				jQuery(".sopt").eq(idx).css('display', 'block');
		});
	});
	jQuery(".fr_subscript .sorting").each(function(idx) {
			jQuery(this).bind("mouseout",function() {
				jQuery(".sopt").eq(idx).css('display', 'none');
		});
	});
	jQuery(".sopt").hover(
		function(){
			jQuery(this).css('display', 'block');
		},
		function(){
			jQuery(this).css('display', 'none');
	});*/
	
	jQuery(".section > li").each(function(idx) {
			jQuery(this).bind("mouseover",function(){
				if(jQuery(".section a").eq(idx).hasClass('on') == false){
					jQuery(".section a").eq(idx).addClass('on');
				}
				jQuery(".subject").animate({height: '99px'}, 200, 'swing');
		});
	});
	jQuery(".subject > ul").each(function(idx) {
			jQuery(this).bind("mouseover",function(){
				if(jQuery(".section a").eq(idx).hasClass('on') == false){
					jQuery(".section a").eq(idx).addClass('on');
				}
		});
	});
	jQuery(".subject > ul").each(function(idx) {
			jQuery(this).bind("mouseout",function(){
				if(jQuery(".section a").eq(idx).hasClass('on') == true){
					jQuery(".section a").eq(idx).removeClass('on');
				}
		});
	});
	jQuery(".section > li").mouseout(function(){
		jQuery(".section a").removeClass('on');
	});
	jQuery(".section a").mouseover(function(){
		jQuery(".subject").removeClass('on');
	});
	jQuery("#GNB_wrap").mouseleave(function(e){
		jQuery(".subject").animate({height: '0'}, 200, 'swing');
		e.stopPropagation(); 
	});
		
	jQuery(".updateNews dt a").click(function(){	    
	    jQuery('.updateNews a').removeClass('fold');
	    jQuery(this).toggleClass("fold");
	    	    
	    jQuery(".updateNews .note").hide();
	    jQuery(this).parent('dt').siblings().show();	    		
	});
});



function Cji_Faq(obj){
	var Faq_dtList = document.getElementById("CJGameFaq").getElementsByTagName("dt");
	var Faq_ddList = document.getElementById("CJGameFaq").getElementsByTagName("dd");
	for (i=0;i<Faq_dtList.length;i++) {
		if(obj.parentNode.parentNode==Faq_dtList[i]){
		Faq_ddList[i].style.display = (Faq_ddList[i].style.display != "block" ? "block" : "none")
		Faq_dtList[i].className = (Faq_dtList[i].className != "on" ? "on" : "")		
		} else {
		Faq_ddList[i].style.display = "none"
		Faq_dtList[i].className = ""
		}
	}
}

function ResizeDimmed(){
	if(document.getElementById('DivDimBox') && document.getElementById('DivDimIfr') && document.getElementById('lp')){
		document.getElementById('DivDimBox').style.height = jQuery('body').outerHeight() + "px";
		document.getElementById('DivDimIfr').style.height = jQuery('body').outerHeight() + "px";
		var conID=document.getElementById('lp')
		var browserH=document.documentElement.clientHeight;
		var contH=conID.clientHeight;
		var scrollT=document.documentElement.scrollTop;
		if( navigator.appVersion.indexOf("MSIE 6") > -1){
			var t = (browserH/2)-(contH/2)+scrollT;
			if(t > 0){
				conID.style.top=t+"px";
			}
			else{
				conID.style.top =0;
			}
		}
		else{
			var t = (browserH/2)-(contH/2);
			if(t > 0){
				conID.style.top=t+"px";
			}
			else{
				conID.style.top =0;
			}
		}
	}
}

function resizeframe(obj) {
	var frame = obj.contentWindow;
	if (frame){
		var framedoc = frame.document;
	}
	else{
	   var framedoc = obj.contentDocument;
	}
	obj.height = framedoc.body.scrollHeight + 15;
	obj.width = framedoc.body.scrollWidth;
}

function NMFlash_Interface ()
{
	alert (arguments[0]);
}

window.onload = ResizeDimmed;
window.onresize = ResizeDimmed;
window.onscroll = ResizeDimmed;
