﻿Event.observe(document, "dom:loaded", function() {
	
	var faqList = $("faqList");
	if(faqList) faqListAct(faqList);
	
	var thisUrl = window.location.href;
	if(thisUrl) splitUrl(thisUrl);

	var gnbList = $("headArea").down(".gnbMenu");
	if(gnbList) {
		gnbList.select("li").each(function(menu, i) {
			menu.observe("click", function() {
				switch(i){
					case 0 : location.href = "../about/about01.php"
						break;
					case 1 : location.href = "../eassda/eassda01.php"
						break;
					case 2 : location.href = "../module/modules.php"
						break;
					case 3 : location.href = "../meeting/meeting01.php"
						break;
					case 4 : location.href = "../part/part01.php"
						break;
					case 5 : location.href = "../news/newsList.php"
						break;
					case 6 : location.href = "../links/links.php"
						break;
				}
			});
		});
	}
});

function splitUrl(thisUrl) {
	var thisUrl = thisUrl;
	var menu = null;

	if(thisUrl.indexOf("/about/") > 0) menu = 1;
	if(thisUrl.indexOf("/eassda/") > 0) menu = 2;
	if(thisUrl.indexOf("/module/") > 0) menu = 3;
	if(thisUrl.indexOf("/meeting/") > 0) menu = 4;
	if(thisUrl.indexOf("/part/") > 0) menu = 5;
	if(thisUrl.indexOf("/news/") > 0) menu = 6;
	if(thisUrl.indexOf("/news1/") > 0) menu = 6;
	if(thisUrl.indexOf("/links/") > 0) menu = 7;
	
	if(menu) {
		//gnb(menu);
	}
}


function gnb(num) {
	var onImg = new Element("img", {src: "../images/common/imgGnb0" + num + "On.gif", "class": "on", style: "display:none"});
	$("headArea").down(".gnbMenu").down("li", num-1).insert(onImg);
	onImg.appear({ duration: 1.0});
}

function addPop(num,sPage,lncnt,table) {
	alert(num+"_"+sPage+"_"+lncnt+"_"+table);
	 window.open("/news/file_upload_form.php?no="+num+"&sPage="+sPage+"&ln_cnt="+lncnt+"&Table="+table, "pop" , "width=500, height=200, scrollbars=false");	
}
function addPop1(num,sPage,lncnt,Table) {
	 window.open("../news1/file_upload_form.php?no="+num+"&sPage="+sPage+"&ln_cnt="+lncnt+"&Table="+Table, "pop" , "width=500, height=200, scrollbars=false");	
}



/*
*
* multi object embed
* for standard
* Reflexion co.
*
*/
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=9,0,115,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() { 
		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 += '<a href="' + pluginspage + '" onclick="window.open(this.href);return false;">Click here to download plugin</a>';
			obj += '</object>\n';
			obj += '<!--<![endif]-->';
			obj += '</object>\n'; 
			eval("window." + objId + " = document.getElementById('" + objId + "');");
		} 
		document.write(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;
}

