document.domain = "wemade.net";

/***********************************************
	Function Name		:	GnxFlashActivate
	Developer			:	
	Create Date		:
	Description			:	Flash 실행
	<script type="text/javascript" language="JavaScript">
// <![CDATA[
	GnxFlashActivate('./sub_nav.swf',890,175,'opaque','TopNavi','TopNavi','Flashvars');
// ]]>
	</script>
***********************************************/
function GnxFlashActivate( strFlashUrl , n4Witdh , n4Height , strWmode , strId , strClassName , strFlashvar, strFullScreen ){
	//width,height 여부 & 묶음 (width,height가 없을때는 0 으로 선언)
	if (n4Witdh != 0) {
		objSize_attribute = " width='"+ n4Witdh +"' height='"+ n4Height +"'";
	} else {
		objSize_attribute = "";
	}
	//id 여부 (ID 셀렉렉터가 없을경우 0으로선언)
	if (strId != 0) {
		objId_attribute = " id='" + strId + "'";
		objId_IE_attribute = " id='" + strId + "'";
	} else {
		objId_attribute = "";
		objId_IE_attribute = "";
	}
	//class 여부 (class가 없을때는 0 으로 선언)
	if (strClassName != 0) {
		className_attribute = " class='" + strClassName + "'";
	} else {
		className_attribute = "";
	}
	//wmode 여부 (wmode가 없을때는 0 으로 선언)
	if (strWmode != 0) {
		wmode_param = "<param name='wmode' value='" + strWmode + "' />";
		wmode_attribute = " wmode='" + strWmode + "'";
	} else {
		wmode_param = "";
		wmode_attribute = "";
	}
	//Flashvar 여부 (wmode가 없을때는 0 으로 선언)
	if (strFlashvar != 0) {
		Flashvar_param = "<param name='flashvars' value='" + strFlashvar + "' />";
		Flashvar_attribute = " Flashvars='" + strFlashvar + "'";
	} else {
		Flashvar_param = "";
		Flashvar_attribute = "";
	}
	// allowFullScreen 여부 
	if (strFullScreen != undefined){
		FullScreen_param = "<param name='allowFullScreen' value='" + strFullScreen + "' />";
		FullScreen_attribute = " allowFullScreen='" + strFullScreen + "'";
	}else{
		FullScreen_param = "";
		FullScreen_attribute = "";
	}
	document.writeln( "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,42,34' " + objSize_attribute + objId_IE_attribute + className_attribute + ">" );
	document.writeln( "<param name='movie' value='"+ strFlashUrl +"' />" );
	document.writeln( "<param name='quality' value='high' />" );
	document.writeln( "<param name='menu' value='0' />" );
	document.writeln( "<param name='allowScriptAccess' value='always' />" );
	document.writeln( "<param name='scale' value='noscale' />" );
	document.writeln( "<param name='salign' value='t' />" );
	document.writeln( wmode_param );
	document.writeln( Flashvar_param );
	document.writeln( FullScreen_param );
	document.writeln( "<!-- Hixie method -->" );
	document.writeln( "<!--[if !IE]> <-->" );
	document.writeln( "<object type='application/x-shockwave-flash' showLiveConnect='true' allowScriptAccess='always' data='"+ strFlashUrl +"'" + Flashvar_attribute + objSize_attribute + objId_attribute + wmode_attribute + className_attribute + FullScreen_attribute + "></object>" );
	document.writeln( "<!--> <![endif]-->" );
	document.writeln( "</object>" );
}


/***********************************************
	Function Name		:	GnxMovieActivate
	Developer			:	
	Create Date		:
	Description			:	MediaPlayer 실행
	<script type="text/javascript" language="JavaScript">
//	 <![CDATA[
		GnxMovieActivate ( 'http://party.paran.com/hp/wmv/[MV]20050511_Side-B_JustDoIt(500k).wmv' , 320 , 240 , 'movie01' , 1 , 1 )
//	 ]]>
	</script>
***********************************************/
function GnxMovieActivate ( strMovieUrl , n4Width , n4Height , strId , n4AutoStart , n4ShowControls ) {
	//width,height 여부 & 묶음 (width,height가 없을때는 0 으로 선언)
	if (n4Width != 0) {
		if (n4ShowControls == 0) {
			Realn4Height = n4Height;	
		} else {
			Realn4Height = n4Height + 45;
		}
		objSize_attribute = " width='"+ n4Width +"' height='"+ Realn4Height +"'";
	} else {
		objSize_attribute = "";
	}
	//id 여부 (ID 셀렉터가 없을경우 0으로 선언 반드시 선언되어야함)
	if (strId != 0) {
		objId_attribute = " id='" + strId + "'";
		objId_IE_attribute = " id='" + strId + "IE'";
	} else {
		objId_attribute = "";
		objId_IE_attribute = "";
	}

	//ShowControls 여부 (컨트롤화면을가리고 싶을때는 0, 보이고 싶을때는 1)
	if (n4ShowControls == 0) {
		ShowControls_param = "<param name='showcontrols' value='false' />";
		ShowControls_attribute = " showcontrols='0'";
	} else if (n4ShowControls == 1){
		ShowControls_param = "<param name='showcontrols' value='true' />";
		ShowControls_attribute = " showcontrols='1'";
	}

	//AutoStart 여부 (컨트롤화면을가리고 싶을때는 0, 보이고 싶을때는 1)
	if (n4AutoStart == 0) {
		AutoStart_param = "<param name='autostart' value='false' />";
		AutoStart_attribute = " autostart='0'";
	} else if (n4AutoStart == 1){
		AutoStart_param = "<param name='autostart' value='true' />";
		AutoStart_attribute = " autostart='1'";
	}

	document.writeln( "<object id='objWMPlayer' name='objWMPlayer' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95'" + objId_IE_attribute + objSize_attribute +" codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'>");
	document.writeln( "	<param name='AudioStream' value='-1' />");
	document.writeln( "	<param name='AutoSize' value='false' />");
	document.writeln( "	<param name='AnimationAtStart' value='true' />");
	document.writeln( "	<param name='AllowChangeDisplaySize' value='true' />");
	document.writeln( "	<param name='BufferingTime' value='5' />");
	document.writeln( "	<param name='Enabled' value='true' />");
	document.writeln( "	<param name='EnableContextMenu' value='true' />");
	document.writeln( "	<param name='EnableTracker' value='true' />");
	document.writeln( "	<param name='PlayCount' value='1' />");
	document.writeln( "	<param name='Rate' value='1' />");

	document.writeln( "	<param name='ShowCaptioning' value='false' /> <!-- 자막 -->");
	document.writeln( "	<param name='ShowAudioControls' value='true' /> <!-- 볼륨조절 -->");
	document.writeln( "	<param name='ShowDisplay' value='false' /> <!-- 미디어정보 -->");
	document.writeln( "	<param name='ShowPositionControls' value='true' /> <!-- Forward,Rewind -->");
	document.writeln( "	<param name='ShowStatusBar' value='false' /> <!-- 상태바 -->");
	document.writeln( "	<param name='ShowTracker' value='true' /> <!-- 탐색바 -->");
	
	document.writeln( "	<param name='Mute' value='false' />");
	document.writeln( AutoStart_param );
	document.writeln( ShowControls_param );
	document.writeln( "	<param name='FileName' value='" + strMovieUrl + "'>");

	document.writeln( "	<!-- Hixie method -->");
	document.writeln( "	<!--[if !IE]> <-->");
	document.writeln( "		<object id='objWMPlayer' name='objWMPlayer' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' data='" + strMovieUrl + "' " + objSize_attribute + objId_attribute + AutoStart_attribute + ShowControls_attribute + ">");
	document.writeln( "	<!--> <![endif]-->");

	document.writeln( "</object>");

}


//png배경처리(css사용)
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='http://wemade-image.gscdn.com/null.gif';
	return '';
}

//go Top Start
function goPageTop(){
	if (navigator.userAgent.indexOf("Chrome") > 0) {		//크롬에선 적용되지 않음
		location.href = "#goTop";
	} else {
		document.documentElement.scrollTop=0;
	}
}

function getStyleAtt(obj,stylePrp){
	var att="";
	if(obj.currentStyle){
		stylePrp=stylePrp.replace(/\-(\w)/g,function(k,z){return z.toUpperCase();});
		att=obj.currentStyle[stylePrp];
	}else if(document.defaultView&&document.defaultView.getComputedStyle)att=document.defaultView.getComputedStyle(obj,null).getPropertyValue(stylePrp);
	return att;
}

function getScrollY(){
	var scrollY;
	if(document.documentElement.scrollTop) {
		scrollY=document.documentElement.scrollTop;
	} else if(document.body.scrollTop) {
		scrollY=document.body.scrollTop;
	} else if(window.pageYOffset) {
		scrollY=pageYOffset;
	} else {
		scrollY=0;
	}
	return scrollY;
}

function getUserWindowY() {
	var winY;
	if(window.innerHeight) {
	winY=window.innerHeight;
	} else if(document.documentElement.clientHeight) {
		winY=document.documentElement.clientHeight;
	} else if(document.body.clientHeight) {
		winY=document.body.clientHeight;
	}
	return winY;
}

function scrollingPageTop(obj,parent,offset){
	var k=0.1;
	var objH=parseInt(getStyleAtt(obj,"height"));
	if(isNaN(objH))return false;
	if(parent)var parentEl=document.getElementById(parent);

	setInterval(function() {
	var agentY=getUserWindowY();
	var scrollY=getScrollY();
	var objY=parseInt(getStyleAtt(obj,"top"));
	var targetY=agentY+scrollY-(objH+offset);
	var distanceY=objY-targetY;
	var steps=Math.abs(distanceY)*k;
	//브라우저별 위치값 적용하기
	var setAgentY = setBrowserPosition(93);
	if(objY<targetY){
		if(parent){
			if(parseInt(obj.style.top)<parentEl.clientHeight-obj.clientHeight-setAgentY)objY+=Math.ceil(steps);
		}
		else objY+=Math.ceil(steps);
	} else if(objY>targetY)objY-=Math.ceil(steps);
		obj.style.top=objY+"px";
	},1);
}

//브라우저별 값 적용하기 기준값은 IE7.0
function setBrowserPosition(offset) {
	var intPosition;
	if (navigator.userAgent.indexOf("MSIE 6") > 0) intPosition = -10;        // IE 6.x
	else if(navigator.userAgent.indexOf("MSIE 7") > 0) intPosition = 0;    // IE 7.x
	else if(navigator.userAgent.indexOf("Firefox") > 0) intPosition = -30;   // FF
	else if(navigator.userAgent.indexOf("Opera") > 0) intPosition = -42;     // Opera
	else if(navigator.userAgent.indexOf("Netscape") > 0) intPosition = -70;  // Netscape
	else if(navigator.userAgent.indexOf("Chrome") > 0) intPosition = -42;  // Chrome

	return offset + intPosition;
}

function errMsg(thisfield, msg) {
	alert (msg);
	thisfield.focus();
}

function setCookie(name, value, date){
	var now = new Date();
	var year = (now.getYear() < 2000) ?  now.getYear() + 1900: now.getYear();
	var cookieStr = name + "=" + escape(value) + ";ages = -1";
	cookieStr += "; path=/";
	if (date != undefined){
		var today = new Date(year, now.getMonth(), now.getDate() + date, now.getHours(),  now.getMinutes(), 0, 0);
		cookieStr += "; expires=" + today.toGMTString() + ";";
	}
	document.cookie = cookieStr;
}

function getCookieVal(offset){
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
// 해당 쿠키 변수에 해당하는 값을 getCookieVal를 통해서 리턴한다.

function getCookie(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;

	while( i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i,j) == arg)
		return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i==0) break;
	}
	return null;
}

function deleteCookie(cookieName){
	var expireDate = new Date();

	//어제 날짜를 쿠키 소멸 날짜로 설정한다.
	expireDate.setDate( expireDate.getDate() - 1 );
	document.cookie = cookieName + "= ; expires=" + expireDate.toGMTString() + "; path=/";
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}else{
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

//ajax형태의 페이지 로그
function saveCurPageLogAfter(myAjax) {}
function saveCurPageLog(obj){
	var strParams = ''; var arrPageLog = document.getElementsByName('txtPageLogVal');
	if (obj != undefined)	{arrPageLog = document.getElementsByName('txtAjaxPageLogVal');	}
	var strLogTxt, arrLogTxt;
	for (var i = 0; i < arrPageLog.length ; i++ ){
		if (arrPageLog[i] != undefined){
			if (i > 0) strParams += '&'; strLogTxt = arrPageLog[i].value;
			if (strLogTxt.indexOf(',') >= 0) {arrLogTxt = strLogTxt.split(','); strLogTxt = arrLogTxt[0];}
			strParams += arrPageLog[i].id + '=' + strLogTxt;
		}
	}
	var myAjax = new net.ContentLoader('/sitelib/set_curpagelog.asp', saveCurPageLogAfter, null, 'POST', strParams);
}


// 전역 변수임. 절대 삭제하면 안됨.
var sndFlag = false;

var screenWidth = screen.availwidth;
var screenHeight = screen.availheight;
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if Internet Explorer
	
	
//인풋박스 변경
function box_input(obj){
	var strClass = document.getElementById(obj).className;
	strClass = strClass.replace(/input_brown/gi,'input_green');
	document.getElementById(obj).className=strClass;
}

function box_output(obj){
//	document.getElementById(obj).className="input_brown";
	var strClass = document.getElementById(obj).className;
	strClass = strClass.replace(/input_green/gi,'input_brown');
	document.getElementById(obj).className=strClass;
}

/***********************************************
	Function Name		:	popup_newWin
	Developer			:	
	Create Date		:
	Description			:	새창 여는 함수
***********************************************/
function popup_newWin(url, winName, sizeW, sizeH, scroll) {
	var nLeft = screen.width/2 - sizeW/2;
	var nTop = screen.height/2 - sizeH/2;

	opt = ", toolbar=no, menubar=no, location=no, scrollbars="+scroll+", status=no";
	window.open(url, winName, "left="+nLeft+", top="+nTop+", width="+sizeW+", height="+sizeH + opt);
}


/***********************************************
	Function Name		:	winResize
	Developer			:	
	Create Date		:	2010.03.03
	Description			:	팝업창 사이즈 조절 (onload에 넣어줌)
***********************************************/
function winResize() {
	var Dwidth = parselnt(document.body.scrollWidth);
	var Dheight = parselnt(document.body.scrollHeight);
	var divEl = document.createElement("div");
	divEl.style.postion = "absolute";
	divEl.style.left = "0px";
	divEl.style.top = "0px";
	divEl.style.width = "100%";
	divEl.style.height = "100%";

	document.body.appendChild(divEl);

	window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight);
	document.body.removeChild(divEl);
}

/***********************************************
	Function Name		:	selfResize
	Developer			:	
	Create Date		:	2010.03.03
	Description			: 사이즈 임의로 조절 (onload에 넣어줌)
***********************************************/
function selfResize(x, y) {
	var Dwidth = screen.availWidth;
	var Dheight = screen.availHeight;
	var PositionX = 0;
	var PositionY = 0;

	if (Dwidth > 800) {
		PositionX = (Dwidth-800)/2;
		PositionY = 0;
		Dwidth = x;
		Dheight = y;
	}

	self.moveTo(PositionX,PositionY);
	self.resizeTo(Dwidth,Dheight);
}