Event.observe(document, "dom:loaded", function() {
	if($("topBtn")) {
		imgChange($("topBtn"));
	}
});

function imgChange(obj) {
	var container = $(obj);
	$(container).select("img").each(function (item, i) {
		item.observe("mouseover", function() {
			item.src = item.src.replace(".png", "On.png");
			item.observe("mouseout", function() {
				item.src = item.src.replace("On.png", ".png");
			});
		});
	});
}



function gnbInit() {
	var menuName = "";
	var pageUrl = location.href;
	
	var pageUrlSplit = pageUrl.split("/");
	var now2Depth = pageUrlSplit[3];
	var now3Depth = pageUrlSplit[4];
	var now4Depth = pageUrlSplit[5];
	var now4DepthGbn = now4Depth.split("?");
	var now4DepthGbn = now4DepthGbn[0];

	if(now3Depth != "bbs") {
		switch(now3Depth) {
			case "brand" : menuName = "visual1.swf";
				break;
			case "product" : menuName = "visual2.swf";
				break;
			case "info" : menuName = "visual3.swf";
				break;
			case "customer" : menuName = "visual4.swf";
				break;
			case "buy" : menuName = "visual5.swf";
				break;
			case "mypage" : menuName = "visual6.swf";
				break;
			case "member" : 
				if(now4DepthGbn == "leave.php"){
					menuName = "visual6.swf";
				}else{
					menuName = "visual7.swf";
				}

				break;
			default: break;			
		}
	} else if(now3Depth == "bbs" && now4DepthGbn != "register.php" && now4DepthGbn != "login.php" ){
//alert(now4DepthGbn);
		if(now4DepthGbn != "register_form.php" &&  now4DepthGbn != "member_confirm.php" &&  now4DepthGbn != "leave.php"){
//alert('1');
			var param = now4Depth.split("bo_table=");
			var paramValue = param[1].substring(0, 4);
			switch(paramValue) {
				case "tb01" : menuName = "visual1.swf";
					break;
				case "tb02" : menuName = "visual1.swf";
					break;
				case "tb03" : menuName = "visual1.swf";
					break;
				case "tb04" : menuName = "visual1.swf";
					break;
				case "tb05" : menuName = "visual1.swf";
					break;
				case "tb12" : menuName = "visual4.swf";
					break;
				case "tb15" : menuName = "visual4.swf";
					break;
				case "tb14" : menuName = "visual4.swf";
					break;
				case "tb13" : menuName = "visual4.swf";
					break;
				case "tb21" : menuName = "visual5.swf";
					break;
				default : 
					break;
			}
		//¸É¹ö½Ê
		}else if( now4DepthGbn == "member_confirm.php" ){ 
			menuName = "visual7.swf";
		//¸¶ÀÌÆäÀÌÁö
		}else{ 
			menuName = "visual6.swf";
		}
	} else {
		menuName = "visual7.swf";
	}
	return menuName;
}



function mapOver(num) {
	$("mapImg").src = $("mapImg").src.replace(".gif",num+".gif");
}
function mapOut(num) {
	$("mapImg").src = $("mapImg").src.replace(num+".gif", ".gif");
}

function familySiteView() {
	$("footArea").down(".familySite").down("div").show();
}
function familySiteHide() {
	$("footArea").down(".familySite").down("div").hide();
}


/* flash Embed*/


function setEmbed(){ 
	var objId = new String; 
	var parameter = new String; 
	var clsid = new String; 
	var codebase = new String; 
	var pluginspage = new String; 
	var embedType = new String; 
	var src = new String; 
	var width = new String; 
	var height = new String; 

	this.init = function(oSrc, oWidth, oHeight, oId) {
		thisFileName = getFileName(oSrc).split(".")[0];
		thisFileType = getFileName(oSrc).split(".")[1];
		thisFileType = thisFileType.replace(" ", "");
		
		if (!oId){
			oId = thisFileName;
		}

		switch(thisFileType){
			case "swf" : {
				embedType = "application/x-shockwave-flash";
				mediaType = "flash";
				} break;
			case "wmv" : {
				embedType = "video/x-ms-wmv";
				mediaType = "movie";
				} break;
			case "wma" : {
				embedType = "audio/x-ms-wma";
				mediaType = "movie";
				} break;
			case "mp3" : {
				embedType = "audio/mpeg";
				mediaType = "movie";
				} break;
			case "asf" : {
				embedType = "video/x-ms-asf ";
				mediaType = "movie";
				} break;
			case "avi" : {
				embedType = "video/x-msvideo";
				mediaType = "movie";
				} break;
			case "mpeg" :
			case "mpg" : {
				embedType = "video/mpeg";
				mediaType = "movie";
				} break;
		}

		if (mediaType == "flash"){ 
			clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
			codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0"; 
			pluginspage = "http://www.macromedia.com/go/getflashplayer"; 
			parameter += "<param name='quality' value='high'>\n"; 
		} 
		else if (mediaType == "movie"){ 
			clsid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6";
			codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715";
			pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp";
		} 

		if (thisFileType == "mov"){ 
			clsid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
			codebase="http://www.apple.com/qtactivex/qtplugin.cab";
			pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp";
			embedType="video/quicktime";
		} 

		src = oSrc;
		width = oWidth;
		height = oHeight;
		objId = oId;	
	} 

	this.param = function(parm , value) {      
		parameter += "<param name='"+parm +"' value='"+ value + "'>\n";
	}  


	this.show = function(chk) { 
		if (clsid){ 
			obj = '<object classid="clsid:'+ clsid +'" codebase="'+ codebase +'" width="'+ width +'" height="'+ height +'" id="' + objId + '">\n';
			obj += '<param name="src" value="'+ src + '">\n';
			obj += '<param name="url" value="'+ src + '">\n';
			obj += parameter;
			obj += '<!--[if !IE]>-->';
			obj += '<object data="' + src + '" type="' + embedType + '" width="'+ width +'" height="'+ height +'" name="' + objId + '" >';
			obj += '<param name="src" value="'+ src + '">\n';
			obj += parameter;
			obj += 'You need to get the latest <a href="http://www.macromedia.com/go/getflashplayer">Flash Player</a> to see this object.<br />';
			obj += 'ÃÖ½ÅÀÇ <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14157&sliceId=1">ÇÃ·¡½Ã ÇÃ·¹ÀÌ¾î</a>°¡ ÇÊ¿äÇÕ´Ï´Ù.';
			obj += '</object>\n';
			obj += '<!--<![endif]-->';
			obj += '</object>\n'; 
			//eval("window." + objId + " = document.getElementById('" + objId + "');");
		}
		
		if(!chk){
			document.write(obj);
		}else{
			chk.innerHTML = obj;
		}
	}
}

function getFileName(uri){
	if(uri.indexOf("#")>0)uri = uri.substr(0,uri.indexOf("#"));
	if(uri.indexOf("&")>0)uri = uri.substr(0,uri.indexOf("&"));
	if(uri.indexOf("?")>0)uri = uri.substr(0,uri.indexOf("?"));
	var thisUriArray = uri.split(/\//);
	var thisFileName = thisUriArray[thisUriArray.length-1];
	return thisFileName;
}

function getSWF(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
		if (window.document[movieName])	return window.document[movieName];
    }
	else {
		if (!window.document[movieName]) return document.getElementById(movieName);
		if(document[movieName].length != undefined)	return document[movieName][1];
    }
}


function IE_HtmlRewrite(objParent) {
	if (window.ActiveXObject && objParent) {
		objParent.innerHTML = objParent.innerHTML;
	}
}

var stimpack = new Object();
/*------------------------------Stimpack :: RemoteCtr :: START :: prototype Base --------------------------------------------*/
stimpack.remoteCtr = remoteCtrFn;
function remoteCtrFn(){
	var remoteObj;
	var objWid;
	var objHei;
	var objTop = 0;
	var objBtm = 0;
	var topLimit = 0;
	var btmLimit = 0;
	var moveTop;
	var speedNum = 5;
	var sInterval;
	var Body = document.body ? document.documentElement : document.body ;
	var sideChk = false;
	
	//¿¤¸®¸ÕÆ® (¶Ç´Â ¾ÆÀÌµð) , °¡·Î°ª , ¼¼·Î°ª
	this.init = function(oObj,oWid,oHei){
		remoteObj = $(oObj);
		objWid = oWid;
		objHei = oHei;
	};
	
	//½ÇÁ¦·Î Àû¿ë ±¸¹®
	this.show = function(){
		if(!sideChk){
			remoteObj.setStyle({
				"left":"0px"
			});
			sideChk = true;
		};
		remoteObj.setStyle({
			"position":"absolute",
			"display":"block",
			"top":topLimit+"px",
			"width":objWid+"px",
			"height":objHei+"px"
		});
		sInterval = setInterval(this.sliding,"30");
	};
	
	//½½¶óÀÌµù ÇÔ¼ö
	this.sliding = function(){
		moveTop = topLimit + remoteObj.cumulativeScrollOffset().top;
		btmLimit = Body.scrollHeight - remoteObj.getHeight() - objBtm;
		if(moveTop>btmLimit){
			moveTop = btmLimit;
		}
		objTop += ( Number(moveTop) - Number(objTop) )/speedNum; // ÀÌ°Ô ½½¶óÀÌµù ÇÔ¼ö
		
		remoteObj.setStyle({
			"top":objTop+"px"
		});
		
	};
	
	//¼ÓµµÁ¶Àý
	this.speed = function(num){
		if(num){
			speedNum = Number(num);
		}else{
			speedNum = 5;
		}
	};
	
	//»ó´Ü¿¡¼­ ¾ó¸¶³ª ¶³¾î¶ß¸±°ÍÀÎ°¡.
	this.top = function(num){
		topLimit = Number(num);
	};
	//ÇÏ´Ü¿¡¼­ ¾ó¸¶³ª ¶³¾î¶ß¸±°ÍÀÎ°¡.
	this.btm = this.bottom = function(num){
		objBtm = Number(num);
	};
	
	this.left = function(num){
		if(!sideChk){
			remoteObj.setStyle({
				"left":num+"px"
			});
			sideChk = true;
		};
	};
	this.right = function(num){
		if(!sideChk){
			remoteObj.setStyle({
				"right":num+"px"
			});
			sideChk = true;
		};
	};
	this.pos = this.position = function(top,right,bottom,left){
		right = Number(right);
		right = Number(left);
		if(!top.empty()){
			this.top(top);
		}
		if(!right.empty() || right!=0){
			this.right(right);
		}
		if(!bottom.empty()){
			this.bottom(bottom);
		}
		if(!left.empty() || left!=0){
			this.left(left);
		}
	};
	this.fixed = function(chkId){
		$(chkId).checked
	};
	
};
