/* 메뉴 함수 */

function goMenu(num)
{
	switch(num)
	{
		case 1:
			location.href = "/foundation/object/";
			break;
		case 2:
			location.href = "/foundation/history/";
			break;
		case 3:
			location.href = "/foundation/chairman/";
			break;
		case 4:
			location.href = "/foundation/greeting/";
			break;
		case 5:
			location.href = "/foundation/officer/";
			break;
		case 6:
			location.href = "/business/scholarship/";
			break;
		case 7:
			location.href = "/business/education/";
			break;
		case 8:
			location.href = "/business/literature/";
			break;
		case 9:
			location.href = "/business/academic/";
			break;
		case 10:
			location.href = "/business/service/";
			break;
		case 11:
			location.href = "/business/support/";
			break;
		case 12:
			location.href = "/events/edu_award/";
			break;
		case 13:
			location.href = "/events/liter_award/";
			break;
		case 14:
			location.href = "/events/verse_award/";
			break;
		case 15:
			location.href = "/events/carve_award/";
			break;
		case 16:
			location.href = "/events/olympiad_award/";
			break;
		case 17:
			top.location.href = "/bbs/summary/";
			break;
		case 18:
			location.href = "/events/carve_award/";
			break;
		case 19:
			location.href = "/lounge/scholarship/";
			break;
		case 20:
			location.href = "/lounge/prizewinner/";
			break;
		case 21:
			location.href = "/lounge/genius/";
			break;
		case 22:
			location.href = "/gallery/sanctuary/";
			break;
		case 23:
			location.href = "/gallery/winner/";
			break;
		case 24:
			location.href = "/foundationnews/news/";
			break;
		case 25:
			location.href = "/foundationnews/schedule/";
			break;
		case 26:
			location.href = "/foundationnews/report/";
			break;
		case 27:
			location.href = "/foundationnews/photo/";
			break;
		case 28:
			location.href = "/bbs/nboard/";
			break;
		case 29:
			location.href = "/bbs/faq/";
			break;
		case 30:
			location.href = "/bbs/storage/";
			break;
		case 31:
			location.href = "/lounge/childliterature/";
			break;
	}
}
// 페밀리 사이트 가기
	function gosit(site)
	{
		if(site.selectedIndex > 0)
			window.open(site[site.selectedIndex].value)
			//location.href = ;
	}
 
// Use a regular expression to replace leading and trailing 
// spaces with the empty string
String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.replaceAll = function(param1, param2){
	var str = this;
	var search = str.indexOf(param1);
	while(search > -1){
		str = str.replace(param1, param2);
		search = str.indexOf(param1);
	}

	return str;
}
//==================================================================================================
//공백을 제외한 길이
//형식 : ExceptBlankLength(폼value값)
//예 : ExceptBlankLength(document.form1.name.value)
//결과 : 길이반환
function ExceptBlankLength(strOriginal)
{
	var position, strOri_Length;

	position = strOriginal.indexOf(' ');

	while (position != -1){
		strOriginal = strOriginal.replace(' ', '');
		position    = strOriginal.indexOf(' ');
	}

	strOri_Length = strOriginal.length;

	return strOri_Length;
}

/*	기능	: 입력된 값이 유효한 이메일 주소인지 체크
	사용법	: 체크하려는 텍스트요소를 파라미터로 넘김
	반환값	: true/false	*/
function EmailCheck(item) {	
	if (item.value.length >0){
		var where = item.value.indexOf('@',0) + 1
		if (where == 0) {
			item.focus();
			item.select();
			return false ;
		} 
	
		var where = item.value.indexOf('.',0) + 1
		if (where == 0) {
			item.focus();
			item.select();
			return false ;
		}

		var where = item.value.indexOf(' ',0) + 1
		if (where != 0) {
			item.focus();
			item.select();
			return false ;
		}
		if(item.value.length<6){
			item.focus();
			item.select();
			return false;	
		}
		if(EmailChar_chk(item)){
			item.focus();
			item.select();
			return false;
		}
		return true;
	}else{
		return true;
	}
}


/*	기능	: 체크박스/라디오버튼의 체크된 갯수 카운트
	사용법	: 체크하려는 체크박스/라디어버튼 요소를 파라미터로 넘김
	반환값	: 체크된 갯수	*/
function Check_CNT(item){
	var tot_cnt = 0;

	if(item == null){
	}else{
		if(item == null){
			tot_cnt = 0;
		}else{
			if(item.length == null){
				if(item.checked==true) tot_cnt++;
			}else{
				for(i=0; i < item.length; i++){
					if(item[i].checked == true) tot_cnt++;
				}
			}
		}
	}
	return tot_cnt;
}

/*	기능	: 체크박스의 체크된 요소의 Value들을 콤마단위로 연결하여 넘김
	사용법	: 체크하려는 체크박스 요소를 파라미터로 넘김
	반환값	: 체크된 요소값(콤마단위)	*/
function Check_Value(item){
	var chk_value = "";
	var chk_cnt = 0;

	if(item == null){
	}else{
		if(item.length == null){
			if(item.checked==true) chk_value = item.value;
		}else{
			for(i=0; i < item.length; i++){
				if(item[i].checked == true){
					if(chk_cnt == 0){
						chk_value = item[i].value;
					}else{
						chk_value += ","+item[i].value;
					}
					chk_cnt++;
				}
			}
		}
	}
	return chk_value;
}

/*	기능	: 라디오버튼의 체크된 요소의 Value를 넘김
	사용법	: 체크하려는 라디오버튼 요소를 파라미터로 넘김
	반환값	: 체크된 요소값	*/
function Radio_Value(item){
	var rdo_value = "";
	if(item == null){
	}else{
		if(item.length == null){
			if(item.checked==true) rdo_value = item.value;
		}else{
			for(i=0; i < item.length; i++){
				if(item[i].checked == true){
					rdo_value = item[i].value;
					break;
				}
			}
		}
	}
	return rdo_value;
}


/*	기능	: 체크박스 전체선택/전체 해제
	사용법	: 전체선택/선택취소 하려는 체크박스 요소 및 구분값('',1,2) 넘김
	반환값	: 	*/
function Check_All(item,mode){
	var i, max=0;

	if(item == null){
		return;
	}else{
		if(mode==null || mode ==""){	// 체크된 요소가 없거나 일부가 되어있는 경우 전체선택/ 전체선택되어있는 경우는 선택 취소
			if( item.length == null ){
				if( item.checked == true ) max++;
				if (max==0){
					item.checked = true;
				}else{
					item.checked = false;
				}
				return;
			}else{
				for( i = 0; i < item.length; i++ )
				{
					if( item[i].checked == true ) max++;
				}
				if( max == 0 ){
					for( i = 0; i < item.length; i++ )
					{
						item[i].checked = true;
					}
					return;
				}else{
					for( i = 0; i < item.length; i++ )
					{
						item[i].checked = false;
					}
					return;
				}
			}
		}else if(mode==1){	//전체선택
	
			if(item.length == null){
				item.checked = true;
			}else{
				
				for( i = 0; i < item.length; i++ )
				{	
//						
					item[i].checked = true;
				}

			}
		}else if(mode==2){	//선택취소
			if(item.length == null){
				item.checked = false;
			}else{
				for( i = 0; i < item.length; i++ )
					item[i].checked = false;
			}
		}
	}
}

function printFlashObject(flash_src,name,width,height,option_param_tag)/*{{{*/
{
  obj_html = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+width+"' height='"+height+"' id='"+name+"' align='middle'>\
  <param name='allowScriptAccess' value='always' />\
  <param name='movie' value='"+flash_src+"' />\
  <param name='quality' value='high' />\
  <param name='bgcolor' value='#ffffff' />\
  <param name='wmode' value='transparent'>\
  <param name='menu' value='false'>";

  obj_html = obj_html + option_param_tag;

  obj_html = obj_html + "<embed src='"+flash_src+"' quality='high' bgcolor='#ffffff' width='"+width+"' height='"+height+"' name='"+name+"' align='middle' allowscriptaccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\
  </object>";

  document.write(obj_html);
}/*}}}*/

/* XMLHTTP 사용 함수 */

	function Ajax_XmlHttp(URL)
	{
		var req = false;
		var reValue = "ER";
		if (window.XMLhttpRequest)
		{
			try
			{
				req = new XMLHttpRequest();
			}
			catch(e)
			{
				req = false;
			}
		}
		else if(window.ActiveXObject)
		{
			try
			{
				req = new ActiveXOjbect("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try
				{
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e)
				{
					req = false;
				}
			}
		}
		if(req)
		{
			req.open("get",URL,false);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send(null);
			if (req == null || req.readyState != 4) return reValue;
			if(req.responseText.length == 0) return reValue;

			reValue = req.responseText;
		}
		return reValue;
	}
	
	function Ajax_XmlHttp_XML(URL)
	{
		var req = false;
		var reValue = "ER";
		if (window.XMLhttpRequest)
		{
			try
			{
				req = new XMLHttpRequest();
			}
			catch(e)
			{
				req = false;
			}
		}
		else if(window.ActiveXObject)
		{
			try
			{
				req = new ActiveXOjbect("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try
				{
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e)
				{
					req = false;
				}
			}
		}
		if(req)
		{
			req.open("post",URL,false);
			req.setRequestHeader("Content-Type", "text/xml");
			req.send(null);
			if (req == null || req.readyState != 4) return reValue;
			if(req.responseXML.length == 0) return reValue;

			reValue = req.responseXML;
		}
		return reValue;
	}

	function na_restore_img_src(name, nsdoc)
	{
	  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	  if (name == '')
	    return;
	  if (img && img.altsrc) {
	    img.src    = img.altsrc;
	    img.altsrc = null;
	  } 
	}
	
	function na_preload_img()
	{ 
	  var img_list = na_preload_img.arguments;
	  if (document.preloadlist == null) 
	    document.preloadlist = new Array();
	  var top = document.preloadlist.length;
	  for (var i=0; i < img_list.length-1; i++) {
	    document.preloadlist[top+i] = new Image;
	    document.preloadlist[top+i].src = img_list[i+1];
	  } 
	}
	
	function na_change_img_src(name, nsdoc, rpath, preload)
	{ 
	  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	  if (name == '')
	    return;
	  if (img) {
	    img.altsrc = img.src;
	    img.src    = rpath;
	  } 
	}
	
	// 라운지 회원 신청 //
	function regloungeuser(cat_no)
	{
		
		var win = window.open("/lounge/common/regloungeform.asp?cat_no=" + cat_no, "regloungeform", "width=400,height=504,scrollbars=no,resizeable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no");
		win.focus();
		//frameHidden.location.href = "/lounge/common/reglounge.asp?cat_no=" + cat_no;
		//location.href = "/lounge/common/reglounge.asp?cat_no=" + cat_no;
	}
