function msocietyActiveX(obj,div){
	// generate html code
	// for ie obejct
	var html = '<object ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="msocietyActiveXObject'+r+'" name="msocietyActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		else html += 'id="'+obj.name+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
		else html += 'name="'+obj.id+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.classid) html += 'classid="'+obj.classid+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	if (obj.codebase) html += 'codebase="'+obj.codebase+'" ';
	// append events
	for (var i in obj.events){
		if (obj.events[i]){
			html += obj.events[i][0]+'="'+obj.events[i][1]+'" ';
		}
	}
	// end of object tag
	html += '>\n';
	// append params
	for (var i in obj.param){
		html += '<param name="'+obj.param[i][0]+'" value="'+obj.param[i][1]+'"/>\n';
	}

	// for ns embed
	html += '<embed ';
	if (!obj.id && !obj.name){
		var r = Math.round(Math.random()*100);
		html += 'id="msocietyActiveXObject'+r+'" name="msocietyActiveXObject'+r+'" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	// append params
	for (var i in obj.param){
		if (obj.param[i][0]){
			if (obj.param[i][0]=='movie' || obj.param[i][0]=='src'){
				var _src = obj.param[i][1];
			}
			if (obj.param[i][0].toLowerCase()=='flashvars'){
				if (_src){
					var tmpArr = html.split('src="'+_src+'"');
					html = tmpArr[0]+' src="'+_src+'?'+obj.param[i][1]+'" '+tmpArr[1];
				} else {
					obj.param[obj.param.length] = obj.param[i];
				}
			} else {
				html += obj.param[i][0]+'="'+obj.param[i][1]+'" ';
			}
		}
	}
	html += '/>\n';
	html += '</object>';

	var isIE = (document.all)?true:false;
	if (isIE){
		document.getElementById(div).innerHTML = html;
	} else if (obj.type=='application/x-shockwave-flash' || obj.classid.toLowerCase()=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
		// ie¿ÜÀÇ ºê¶ó¿ìÀú¿¡¼­ activex°¡ flash °æ¿ì¸¸ ³ëÃâ
		document.getElementById(div).innerHTML = html;
	} else if (navigator.platform.indexOf('Win')>=0 && obj.classid.toLowerCase()=='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95'){
		// Windows Media PlayerÀÇ °æ¿ì windows platform¿¡¼­¸¸ ³ëÃâ
		document.getElementById(div).innerHTML = html;
	}
}

// ÇÑÆäÀÌÁö¿¡ ÇÑÁ¾·ùÀÇ activeX°¡ º¹¼ö°³ »ðÀÔµÇ´Â °æ¿ì ÇÏ´Ü°ú °°ÀÌ functionÀ» ¸¸µé¾î¼­ »ç¿ë
function msocietyFlash(src,width,height,div, vars){
	var obj = new Object();
	obj.type = 'application/x-shockwave-flash';
	obj.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
	obj.wmode = 'transparent';
	obj.width = width;
	obj.height = height;

	var param = [
		['movie',src],
		['src',src],
		['quality','high'],
		['wmode','transparent'],
		['bgcolor','#FFFFFF'],
		['pluginspage','http://www.macromedia.com/go/getflashplayer'],
		['allowScriptAccess','Always'],
	];
	if(vars){
		param[param.length] = ['FlashVars',vars];
	}
	obj.param = param;
	msocietyActiveX(obj,div);
}

function FuncName(){
	alert('ÁØºñÁßÀÎ ¸Þ´ºÀÔ´Ï´Ù');
	return;
}

function focus_id(){
	var idbox = document.all["id"];
	if(idbox && idbox.type=="text"){
		idbox.focus();
	}
}

function link(i){
	window.status=i;
}

function print_frame(wf){
	wf.focus();
	window.print();
}

function notready(){
	alert('ÁØºñÁßÀÎ ¸Þ´ºÀÔ´Ï´Ù');
	return;
}

function getCookie( name )
{
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length ){
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ){
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
				return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

function pop_cookie_window(pop_nm,Cookie_nm,width,height){
	if ( getCookie(Cookie_nm) != 'done' ) {
	window.open('/Notice/'+pop_nm,Cookie_nm,'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+width+',height='+height+',left=70,top=30');
	}
}

function pop_cookie_window2(pop_nm,Cookie_nm,width,height,pixwidth,pixheight){
	if ( getCookie(Cookie_nm) != 'done' ) {
	window.open('/Notice/'+pop_nm,Cookie_nm,'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+width+',height='+height+',left='+pixwidth+',top='+pixheight);
	}
}

function changeStr(src,s1,s2)
{
	var tmp;

	if ( src.indexOf(s1) == -1)
		return src;

	while( src.indexOf(s1) > -1)
	{
		tmp = src.substr(0, src.indexOf(s1));
		tmp += s2;
		tmp += src.substr(src.indexOf(s1)+s1.length,src.length);
		src = tmp;
	}
	return tmp;
}


function nl2br(src)
{
	var tmp
	if ( src  == "" )
		tmp =  "&nbsp;";
	else
		tmp = changeStr(src, "\n", "<br>");
	return tmp;
}

function FileDown(FileTable,fno){
	var URL = "/Publish/file_download.asp?FileTable="+FileTable+"&FNO="+fno;
	var win = window.open(URL,"file","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=100;");
	win.focus();
}

function FullscreenOpen(pmem_uid,catid,maxpage){
		
    var fullwidth = screen.width-10;
	var fullheight = screen.height-48;
	
	var url = '/viewcatalog/start.asp';
	var newWin = window.open(url+"?full=&right=&normal=&" + maxpage + "=&0=&" + maxpage + "=&zoomgo=&5=&catid=" + catid ,'ppp','titlebar=yes,toolbar=no, location=no,  menubar=no, resizable=no, status=0, left=0, top=0, width=' + fullwidth + ', height=' + fullheight);
	
	newWin.focus();
}
/*
---------------------------------------------------------------------------

 * 	This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2, or (at your option)
 *      any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program (see the file COPYING); if not, write to the
 *      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *      Boston, MA  02111-1307, USA
 
This code is copyright 2003 by Matthew Eernisse (mde@state26.com)

Additional bugfixes by Mark Pruett (mark.pruett@comcast.net)

---------------------------------------------------------------------------	
*/ 

// The var docForm should be a reference to a <form>


//ÀÌ ÇÔ¼ö´Â Â÷ÈÄ »ç¿ëÇÒ °ÍÀÌÁö¸¸, ¾ÆÁ÷ ¼öÁ¤µÇÁö ¾Ê¾Ò½À´Ï´Ù.(2005-11-26)
function formData2QueryString(docForm) {

	var strSubmitContent = '';
	var formElem;
	var strLastElemName = '';
	
	for (i = 0; i < docForm.elements.length; i++) {
		
		formElem = docForm.elements[i];
		switch (formElem.type) {
			// Text fields, hidden form elements
			case 'text':
			case 'hidden':
			case 'password':
			case 'textarea':
			case 'select-one':
				strSubmitContent += formElem.name + '=' + escape(formElem.value) + '&'
				break;
				
			// Radio buttons
			case 'radio':
				if (formElem.checked) {
					strSubmitContent += formElem.name + '=' + escape(formElem.value) + '&'
				}
				break;
				
			// Checkboxes
			case 'checkbox':
				if (formElem.checked) {
					// Continuing multiple, same-name checkboxes
					if (formElem.name == strLastElemName) {
						// Strip of end ampersand if there is one
						if (strSubmitContent.lastIndexOf('&') == strSubmitContent.length-1) {
							strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
						}
						// Append value as comma-delimited string
						strSubmitContent += ',' + escape(formElem.value);
					}
					else {
						strSubmitContent += formElem.name + '=' + escape(formElem.value);
					}
					strSubmitContent += '&';
					strLastElemName = formElem.name;
				}
				break;
				
		}
	}
	
	// Remove trailing separator
	strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
	return strSubmitContent;
}

function xmlhttpPost(strURL, strSubmit, strResultFunc){
	var xmlHttpReq = false;
	
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
			xmlHttpReq = new XMLHttpRequest();
			xmlHttpReq.overrideMimeType('text/xml');
	}
	// IE
	else if (window.ActiveXObject) {
			xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlHttpReq.open('POST', strURL, true);
	xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function(){
		if (xmlHttpReq.readyState == 4) {
			eval(strResultFunc + '(xmlHttpReq.responseText);');
		}
	}
	xmlHttpReq.send(strSubmit);
}

function logout(){
	location.href="member.asp?ex=logout";
}

function __ws__(id){
 
 document.write(id.innerHTML);id.id="";

}

function IsAlpha(str, idx)
{
	if(IsLower(str,idx) || IsUpper(str,idx))
	{
		return true;
	}
	return false;
}

function IsNumber(str){
	var regEx = new RegExp("^[0-9]+$", "i");

	if ( regEx.test(str) ){
		return true;
	}else{
		return false;
	}
}

function IsAlphaNumeric(str, idx)
{
	if(IsAlpha(str,idx) || IsNumber(str,idx))
	{
		return true;
	}
	return false;
}


function IsLower(str, idx)
{
	if(str.charCodeAt(idx) >= 97 && str.charCodeAt(idx) <= 122)
	{
		return true;
	}
	return false;
}

function IsUpper(str, idx)
{
	if(str.charCodeAt(idx) >= 65 && str.charCodeAt(idx) <= 90)
	{
		return true;
	}
	return false;
}

function ChangeParameter(obj){
	var addstr;
	var RealURL	= location.href; 
	var strURL	= RealURL.toLowerCase();
	var s;
	var e;
	var column = obj.name;
	var value	 = obj.value;

	//ÆÄ¶ó¸ÞÅ¸°¡ ¾øÀ¸¸é
	if(strURL.indexOf(column.toLowerCase()+"=")==-1){
		RealURL = AddParameter(RealURL,column+"="+value);
	}else{
		s = strURL.indexOf(column.toLowerCase()+"=");
		e = strURL.indexOf("&",s)==-1?strURL.length:strURL.indexOf("&",s);
		RealURL = RealURL.replace(RealURL.substring(s,e),column+"="+value);
	}

	//gotopage ÆÄ¶ó¸ÞÅ¸¸¦ »èÁ¦ÇÑ´Ù
	if(strURL.indexOf("gotopage=")!=-1){
		s = strURL.indexOf("gotopage=");
		e = strURL.indexOf("&",s)==-1?strURL.length:strURL.indexOf("&",s)+1;
		RealURL = RealURL.replace(RealURL.substring(s,e),"");
	}

	location.href=RealURL;
}

function AddParameter(str,p){
	if(str.indexOf("?")==-1){
		str += "?"+p;
	}else{
		str += "&"+p;
	}
	return str;
}

function LineUp(column){
	var addstr;
	var strURL = location.href.toLowerCase();
	var s;
	var e;

	//Ä®·³ ¹Ù²Ù±â
	if(strURL.indexOf("ordercolumn=")==-1){
		strURL = AddParameter(strURL,"ordercolumn="+column);
	}else{
		s = strURL.indexOf("ordercolumn=");
		e = strURL.indexOf("&",s)==-1?strURL.length:strURL.indexOf("&",s);
		strURL = strURL.replace(strURL.substring(s,e),"ordercolumn="+column);
	}


	//asc,desc ¹Ù²Ù±â
	if(strURL.indexOf("orderflow=")==-1){
		strURL = AddParameter(strURL,"orderflow=desc");
	}else{
		//** desc¶ó¸é
		if(strURL.indexOf("=desc")!=-1){
			s = strURL.indexOf("orderflow=");
			e = strURL.indexOf("&",s)==-1?strURL.length:strURL.indexOf("&",s);
			strURL = strURL.replace(strURL.substring(s,e),"orderflow=asc");
		//** desc°¡ ¾Æ´Ï¶ó¸é
		}else{
			s = strURL.indexOf("orderflow=");
			e = strURL.indexOf("&",s)==-1?strURL.length:strURL.indexOf("&",s);
			strURL = strURL.replace(strURL.substring(s,e),"orderflow=desc");
		}
	}
	location.href=strURL;
}

String.prototype.trim = function () {
	return this.replace(/(^\s*)|(\s*$)/gi, "");
}

function findStringNum(Str, needle){
	var tempNum		= 0;
	var returnNum	= 0;

	if(Str.indexOf(needle) == -1){
		returnNum = 0;
	}else{
		if(Str.indexOf(needle) > -1 && (Str.indexOf(needle) == Str.lastIndexOf(needle))){
			returnNum = 1;
		}else{
			for(;Str.indexOf(needle, tempNum++) < Str.lastIndexOf(needle);){
				tempNum =	Str.indexOf(needle,tempNum);
				returnNum++;
			}
		}
	}
	return returnNum;
}

function openWin(popnm,url,width,height,scroll){
	var win = window.open(url,popnm,'toolbar=no,location=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no,width='+width+',height='+height+',left=80,top=40');
	win.focus();
}

