// JavaScript Document

//투명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 '';
}
// 이벤트 아이프레임 높이조절
function ifr_Height() {
    var height = document.getElementById("iframe_id").contentWindow.document.body.scrollHeight;
    document.getElementById("iframe_id").height = height;
}
//스샷게시판 사용법팝업
function SShow() {
  window.open('/community/SsPop.asp','SShow','width=400,height=290');
}
//플래쉬가이드
function manualPop() {
  window.open('/playguide/manual.asp','manual','width=800,height=600');
}
//커뮤니
function comuhow() {
  window.open('/community/comuHow.asp','SShow','scrollbars=yes,width=800,height=600');
}
// 스갤 팝업이미지
function funImgView(imgfile, width, height) {
	var img = window.open("SSimgView.asp?imgfile="+imgfile,"","top=100,left=100,width="+width+",height="+height);
	img.focus();
}

function shopOpen(URL){
	var windowW = screen.width
	var widnowH = screen.height
	var clientW = document.body.clientWidth
	var clinetH = document.body.clientHeight
	
	MM_openBrWindow(URL,'WinPop','scrollbars=yes,left=0,width=804,height='+widnowH);
}

function rankOpen(URL){
	var windowW = screen.width
	var widnowH = screen.height
	var clientW = document.body.clientWidth
	var clinetH = document.body.clientHeight
	
	MM_openBrWindow(URL,'WinPop','scrollbars=no,left=0,width=765,height=400');
}

// 이미지로 팝업띄우기


function showImgWin(img){
	imgWin=window.open("","","width=100, height=100, resizable=yes");
	imgWin.document.write("<html><head></head>");
	imgWin.document.write("<script>");
	imgWin.document.write("function resizeWin() {");
	imgWin.document.write("var obj = document.getElementById('img');");
	imgWin.document.write("var w = obj.width;");
	imgWin.document.write("var h = obj.height;");
	imgWin.document.write("window.resizeTo(w + 10, h + 50);");
	imgWin.document.write("}");
	imgWin.document.write("</script>");
	imgWin.document.write("<body topmargin=0 leftmargin=0 onLoad='resizeWin();'>");
	imgWin.document.write("<img src='"+img+"' onclick='self.close()' style=cursor:pointer id='img'>");
	imgWin.document.close();
}


// 플래쉬 삽입 스크립트 (IE ActivX Patch Virson )
function flashWrite(url,w,h,id,bg,vars,win,me){
	var flashStr=
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='FlashVars' value='"+vars+"' />"+
	"<param name='wmode' value='"+win+"' />"+
	"<param name='loop' value='true' />"+
	"<param name='quality' value='high' />"+
	"<param name='bgcolor' value='"+bg+"' />"+
	"<param name='menu' value='"+me+"' />"+
	"<embed src='"+url+"' FlashVars='"+vars+"' wmode='"+win+"' menu='"+me+"' loop='true' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";
	document.write(flashStr);
}

//로긴 inputBG
function OutputBackImg(input_name){
        input_name.style.backgroundImage = "";
}
function InputBackImg(input_name,img_name){
    if(input_name.value == ""){
        input_name.style.backgroundImage = "url(" + img_name + ")";
        }
}


// 동영상 삽입(IE ActivX Patch Virson )
function movieWrite(url,w,h,id,bar,start,loop){

	var movieStr=
	"<object id='MediaPlayer1' classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' type='application/x-oleobject' width='"+w+"' height='"+h+"' id='"+id+"' standby='Loading Microsoft Windows Media Player components...'>"+
	"<param name='Filename' value='"+url+"' />"+
	"<param name='showcontrols' value='"+bar+"' />"+
	"<param name='autostart' value='"+start+"' />"+
	"<param name='loop' value='"+loop+"' />"+
	"<embed src='"+url+"' width='"+w+"' height='"+h+"' name='"+id+"' showcontrols='"+bar+"' autostart='"+start+"' loop='"+loop+"' align='middle' type='application/x-mplayer2' pluginspage = 'http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/'>"+
	"</embed>"+
	"</object>";

	document.write(movieStr);

}

// 따라다니는 상단버튼 스크립트
// var stmnLEFT = 790; 
var stmnGAP1 = 300; // 
var stmnGAP2 = 20; //
var stmnBASE = 500; //
var stmnActivateSpeed = 200; //
var stmnScrollSpeed = 5; //

var stmnTimer;

function ReadCookie(name){
		var label = name + "=";
		var labelLen = label.length;
		var cLen = document.cookie.length;
		var i = 0;
		while (i < cLen) {
			var j = i + labelLen;
			if (document.cookie.substring(i, j) == label) {
				var cEnd = document.cookie.indexOf(";", j);
				if (cEnd == -1) cEnd = document.cookie.length;
				return unescape(document.cookie.substring(j, cEnd));
			}
			i++;
		}
		return "";
	}
function SaveCookie(name, value, expire){
	var eDate = new Date();
	eDate.setDate(eDate.getDate() + expire);
	document.cookie = name + "=" + value + "; expires=" +  eDate.toGMTString()+ "; path=/";
}
function RefreshStaticMenu(){
	var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;
	stmnStartPoint = parseInt(document.getElementById("STATICMENU").style.top, 10);
	stmnEndPoint = document.documentElement.scrollTop + stmnGAP2;
	if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;
	stmnRefreshTimer = stmnActivateSpeed;
	if ( stmnStartPoint != stmnEndPoint ) {
		stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
		document.getElementById("STATICMENU").style.top = parseInt(document.getElementById("STATICMENU").style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount );
		stmnRefreshTimer = stmnScrollSpeed;
	}
	stmnTimer = setTimeout("RefreshStaticMenu()", stmnRefreshTimer);
}
function ToggleAnimate(){
	if (ANIMATE.checked) {
		RefreshStaticMenu();
		SaveCookie("ANIMATE", "true", 300);
	}
	else {
		clearTimeout(stmnTimer);
		document.getElementById("STATICMENU").style.top = stmnGAP1;
		SaveCookie("ANIMATE", "false", 300);
	}
}
function InitializeStaticMenu(){
 if (ReadCookie("ANIMATE") == "false") {
		document.getElementById("ANIMATE").checked = false;
		document.getElementById("STATICMENU").style.top = document.body.scrollTop + stmnGAP1;
	}
	else {
		document.getElementById("ANIMATE").checked = true;
		document.getElementById("STATICMENU").style.top = document.body.scrollTop + stmnBASE;
		RefreshStaticMenu();
	}
}



function itViewPop() { //v6.0  아이템샵팝업띠우기
  var i,p,v,obj,args=itViewPop.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}





//롤오버,스왑,접프 등등..///////////////////////////////////////////////////////////////

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}




function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

///////////////////////////////////////////////////////////////////////////////////












// Program JavaScript

var imgzips = new Array("jpg", "gif", "jpeg", "bmp", "png", "pcx", "zip", "rar");
//var imgs = new Array("jpg", "gif", "jpeg", "bmp", "png", "pcx");
var imgs = new Array("jpg", "gif", "bmp");

function isImgZip(str) {
	var ext = str.substring(str.lastIndexOf(".") + 1, str.length);
	for (var i = 0; i < imgzips.length; i++) {
		if (ext.toLowerCase() == imgzips[i])
			return true;
	}
	return false;
}

function isImg(str) {
	var ext = str.substring(str.lastIndexOf(".") + 1, str.length);
	for (var i = 0; i < imgs.length; i++) {
		if (ext.toLowerCase() == imgs[i])
			return true;
	}
	return false;
}

function isTxt(str) {
	var ext = str.substring(str.lastIndexOf(".") + 1, str.length);
	if (ext.toLowerCase() == "txt")
		return true;
	else
		return false;
}

function isSpace(chkValue) {
	if (chkValue.length == 0) {
		return true;
	} else {
		for (i = 0; i < chkValue.length; i++) {
			var chk = chkValue.charAt(i);
			if (chk == " ") {
				return true;
				break;
			}
		}
	}
}

function isTXTEmpty(chkValue) {
	var isEmpty = true;
	if (chkValue.length == 0) {
		return isEmpty;
	} else {
		for (i = 0; i < chkValue.length; i++) {
			var chk = chkValue.charAt(i);
			if (chk != " ")
				isEmpty = false;
		}
	}
	return isEmpty;
}

function isCHKEmpty(chkEntity) {
	var isEmpty = true;
	for (i = 0; i < chkEntity.length; i++) {
		if (chkEntity(i).checked)
			isEmpty = false;
	}
	return isEmpty;
}

function isHan(chkValue) {
	schar = new Array('!','@','#','$','%','^','&','*','(',')','-','=','+','\\','|','/',',','?','<','>','.','{','}','[',']','`','~');
	for(i = 0; i < chkValue.length; i++) {
		c = chkValue.charAt(i);
		for (j = 0; j < schar.length; j++) {
			if (schar[j] == c)
				return false;
		}
		if(!((c < '0' || c > '9')&&(c < 'a' || c > 'z')&&(c < 'A' || c > 'Z')))
			return false;
	}
	return true;
}

function isHanAlpha(chkValue) {
	schar = new Array('!','@','#','$','%','^','&','*','(',')','-','=','+','\\','|','/',',','?','<','>','.','{','}','[',']','`','~');
	for(i = 0; i < chkValue.length; i++) {
		c = chkValue.charAt(i);
		if(!isNaN(c))		return false;

		for (j = 0; j < schar.length; j++) {
			if (schar[j] == c)		return false;
		}
	}
	return true;
}

function isAlphaNumber(chkValue) {
	for(i = 0; i < chkValue.length; i++) {
		c = chkValue.charAt(i);
		if(!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
		   return false;
	}
	return true;
}

function isAlphaNumUnder(chkValue) {
	for(i = 0; i < chkValue.length; i++) {
		c = chkValue.charAt(i);
		if(!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'))
		   return false;
	}
	return true;
}

function isAlphaNumUnderDot(chkValue) {
	for(i = 0; i < chkValue.length; i++) {
		c = chkValue.charAt(i);
		if(!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '.'))
		   return false;
	}
	return true;
}

function isAlphaUnder(chkValue) {
	for(i = 0; i < chkValue.length; i++) {
		c = chkValue.charAt(i);
		if(!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'))
		   return false;
	}
	return true;
}

function isAlpha(chkValue) {
	for(i = 0; i < chkValue.length; i++) {
		c = chkValue.charAt(i);
		if(!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
		   return false;
	}
	return true;
}

function isPassword(chkValue) {
	if (isAlpha(chkValue)) {
		return false;
	} else if (!isNaN(chkValue)) {
		return false;
	}

	return true;
}

function isEmail(chkValue) {
	var at = chkValue.indexOf("@");
	var dot = chkValue.indexOf(".");

	if (at < 2)
		return false;
	else {
		for(i = 0; i < chkValue.length; i++) {
			c = chkValue.charAt(i);
			if(!((!isNaN(c)) || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-' || c == '@' || c == '.'))
			   return false;
		}
	}
	return true;
}

function txtByte(chkValue) {
	var nbytes = 0;
	for (i=0; i<chkValue.length; i++) {
		var ch = chkValue.charAt(i);
		if(escape(ch).length > 4)					nbytes += 2;
		else if (ch == '\n') {
			if (chkValue.charAt(i-1) != '\r')		nbytes += 1;
		} else if (ch == '<' || ch == '>')			nbytes += 4;
		else										nbytes += 1;
	}
	return nbytes;
}

function isLength(str, len) {
	cnt = txtByte(str);
	if (cnt <= len) {
		return false;
	} else {
		return true;
	}
}

function ampmchange(value, selector) {
	if(value == "am") {
		selector.options[0].text = "00";
	} else {
		selector.options[0].text = "12";
	}
}

function is_yun(yr) {
	if(((yr%4) == 0 && (yr%100) != 0) || (yr%400) == 0)
		return 1;
	else
		return 0;
}

function resetday(yr,mon,selector) {
	if (yr != "default" && mon != "default") {
		monthdays = new Array(12);
		monthdays[0] = 31;
		if(is_yun(eval(yr)))	monthdays[1] = 29;
		else					monthdays[1] = 28;
		monthdays[2] = 31;
		monthdays[3] = 30;
		monthdays[4] = 31;
		monthdays[5] = 30;
		monthdays[6] = 31;
		monthdays[7] = 31;
		monthdays[8] = 30;
		monthdays[9] = 31;
		monthdays[10] = 30;
		monthdays[11] = 31;

		var i=0;
		var	del_idx;
		if(selector.options.length < monthdays[eval(mon)-1]) {
			var NewOpt = Array(3);
			while(selector.options.length < monthdays[eval(mon)-1]) {
				NewOpt[i] = document.createElement('OPTION');
				selector.options.add(NewOpt[i]);
				i++;
			}
		} else if(selector.options.length > monthdays[eval(mon)-1]) {
			while(selector.options.length > monthdays[eval(mon)-1]) {
				del_idx = selector.options.length - 1;
				selector.options.remove(del_idx);
			}
		}
		var	dvalue;
		for(i=1; i<=monthdays[eval(mon)-1]; i++) {
			if(i<10)	dvalue = "0"+i;
			else		dvalue = i;
			selector.options[i-1].value = dvalue;
			selector.options[i-1].text = dvalue;
		}
	}
}

function scratch() {
window.open ('/event/20090910/pop.asp', 'newwin' , 'toolbar=0, location=0, status=0, menubar=0, scrollbars=0, resizable=0, top=300, left=300, width=300, height=260');
}