if (REQUIRE_ONCE_AJAX_FUNC == null)
{
	// ÇÑ¹ø¸¸ ½ÇÇàµÇ°Ô
	var REQUIRE_ONCE_AJAX_FUNC = true;

	var BlindLayer = null;
	var DlgLayer = null;

	var dlg_widht;
	var dlg_height;

	onresize = function()
	{
		if(this.top.name == "experience")
		{
			if(BlindLayer && BlindLayer.style.visibility == "visible")
			{				
				BlindLayer.style.width = document.body.scrollWidth;
				BlindLayer.style.height = document.body.scrollHeight;
			}
		}
	}

	function alertDeplit()
	{
		alert("ÀÌ°ÅÀÌ´Â ÇÊ¿ä¾øÀ»°Å °°Àºµ¥.. ¾ø¾Ù±î¿ä..?? ¤»¤»");
	}
/*
	function SetUrl( Window, URL )
	{
		if( (typeof(Window) == "undefined") || (typeof(Window.main) == "undefined") || (typeof(Window.main.document) == "undefined") )
		{
			alert("undefined : " + typeof(Window) + typeof(Window.main) + typeof(Window.main.document) );
			setTimeout("SetUrl("+Window+", '"+URL+"')" ,5000);
		}
		else
		{
			alert("ok");
			Window.main.document.location.href = URL;	
			Window.focus();	
		}
	}
*/
	function WindowOpen(href, name)
	{
		var option;
		var newWindow = null;
		if( name == "home" )
		{
			if( !parent.opener || parent.opener.closed )
			{
				var thiswin = location.href;

				if( ( thiswin.search("teacher") == 0 ) || ( thiswin.search("student") == 0 ) || ( thiswin.search("testpool") == 0 ))
					this.name = "experience";

				newWindow = window.open(href, "home");
			}
			else
			{
				newWindow = parent.opener;

				if(newWindow)
				{
					if(newWindow.main)
						newWindow.main.document.location.href=href;
					else
						newWindow.location.href=href;
				}
			}			
		}
		else if( name == "experience")
		{
			newWindow = window.open(href, name);
		}
		else if( name == "bigpopup" )
		{
			if( screen.availHeight-44 > 870 )
				option = "width=1024, height=800, resizable=no, titlebar=yes, memubar=no, toolbar=no, status=no, scrollbars=no";
			else	
				option = "width="+screen.availWidth+", height="+screen.availHeight-44+", resizable=no, titlebar=yes, memubar=no, toolbar=no, status=no, scrollbars=yes";

			newWindow = window.open(href, name, option);
		}
		else if( name == "popup" )
		{
			option = "width=780, height=680, resizable=no, titlebar=yes, memubar=no, toolbar=no, status=no, scrollbars=no";
			newWindow = window.open(href, name, option);
		}
		else
		{
			if( typeof(name) == "undefined" )
				name = "_blank";
			option = "width=1024, height=768, resizable=no, titlebar=yes, memubar=no, toolbar=no, status=yes, scrollbars=yes";
			newWindow = window.open(href, name, option);
		}
		
		if( newWindow )
			newWindow.focus();
//+(screen.availHeight-44)
/*
		if( teacher )
		{
			teacher.main.location.href = href;
			teacher.focus();
		}
		else


		 = "width=";
		 */
		
	}

	function QuickSearch()
	{
		var searchstring = document.getElementById("quicksearch");
		if( searchstring && (searchstring.value != "") )
		{
			location.href="../testpool/findquestion.php?searchkeyword="+searchstring.value;
		}
	}
	function alert_login(ret_page)
	{
		var hwpctrl = document.getElementById("HwpCtrl");
		if( hwpctrl )
			hwpctrl.style.visibility = "hidden";

		var url = "../member/login.php?Style=nohead&_ret_url="+ret_page;

		DoModalPage(url, 543, 313);
	}

	function DoModal(message, width, height)
	{
		if( typeof(width) == "undefined" )
			width = 200;
		if( typeof(height) == "undefined" )
			height = 100;

		/// select ÆûÀÌ Div LayerÀ§·Î ³ªÅ¸³ª´Â Çö»óÀ» ¾ø¾ÖÁÖ±â À§ÇØ
		ShowAllSelect(false);

		/// È­¸é ÀüÃ¼¸¦ µ¤´Â ¹ÝÅõ¸í DIV»ý¼º
		if( !BlindLayer )
		{
			BlindLayer = document.createElement("div");
			document.body.insertBefore(BlindLayer, document.body.firstChild);

			BlindLayer.style.zIndex = 1000;
			BlindLayer.style.visibility = "hidden";
			BlindLayer.style.backgroundColor = "#333333";			
			BlindLayer.style.cursor = "wait";

			BlindLayer.style.top = 0;
			BlindLayer.style.left = 0;	
			
			if( Prototype.Browser.IE )
			{	
				BlindLayer.style.position = "absolute";
				BlindLayer.style.filter = "alpha(opacity=50)";	
			}
			else
			{	
				BlindLayer.style.position = "fixed";
				BlindLayer.style.opacity = 0.5;	
			}
		}
		BlindLayer.style.width = document.body.scrollWidth;
		BlindLayer.style.height = document.body.scrollHeight;
		BlindLayer.onfilterchange = null;
		BlindLayer.style.visibility = "visible";	

		/// Modal DlgÈ¿°ú¸¦ ³»´Â DIV»ý¼º
		var CenterLeft = (document.body.clientWidth - width)/2;
		var CenterTop = (document.body.clientHeight - height)/2;

		if( !DlgLayer )
		{
			DlgLayer = document.createElement("div");
			document.body.insertBefore(DlgLayer, document.body.firstChild);

			DlgLayer.setAttribute("id", "ModalDlg");

			DlgLayer.style.zIndex = 2000;
			
			if( Prototype.Browser.IE )
				DlgLayer.style.position = "absolute";
			else
				DlgLayer.style.position = "fixed";

			DlgLayer.style.visibility = "hidden";
			DlgLayer.style.backgroundColor = "white";
//			DlgLayer.style.border = "double black 3px";
			DlgLayer.style.overflow = "hidden";	
		}	

		DlgLayer.style.left = CenterLeft;
		DlgLayer.style.top = CenterTop;		
		DlgLayer.style.width=width;
		DlgLayer.style.height=height;

		var text = 
"<table cellspacing=0 cellpadding=0 height=100% width=100%><tr>		<td>			<div id='modalMessage' align='center' valign='middle'>loading ...</div>		</td>	</tr></table>";
		document.getElementById("ModalDlg").innerHTML = text;

		DlgLayer.onfilterchange = null;
		DlgLayer.style.visibility = "visible";

		if( typeof(message) != "undefined")			
			document.getElementById("modalMessage").innerHTML = message;		
	}

	function CloseDlg()
	{
		DlgLayer.style.visibility = "hidden";
		BlindLayer.style.visibility = "hidden";	

		ShowAllSelect(true);
	}

	function AddBasket()
	{
		var inputBoxs = document.getElementsByTagName("input");
		var countOfInput = inputBoxs.length;
		var addCount = 0;
		for( var i = 0; i < countOfInput; i++)
		{
			if( (inputBoxs[i].type == "checkbox") && (inputBoxs[i].id.search("findquest_") == 0) )
			{
				if( !inputBoxs[i].disabled && inputBoxs[i].checked )
				{
					var id = inputBoxs[i].id.replace("findquest_", "");
					arrayBasket.push(id);
					inputBoxs[i].disabled = true;
					addCount++;
				}
			}
		}

		if( addCount > 0 )
			CallAjaxFindQuestInId("basket");
		else
			alert("ÀÓ½ÃÀúÀå¸ñ·Ï¿¡ Ãß°¡ÇÒ ¹®Á¦¸¦ ¸ÕÀú ¼±ÅÃÇÏ½Ê½Ã¿À.");
	}
	function RemoveBasket()
	{
		var inputBoxs = document.getElementsByTagName("input");
		var countOfInput = inputBoxs.length;
		var removeCount = 0;
		for( var i = 0; i < countOfInput; i++)
		{
			if( (inputBoxs[i].type == "checkbox") && (inputBoxs[i].id.search("basket_") == 0) )
			{
				if( !inputBoxs[i].disabled && inputBoxs[i].checked )
				{
					var id = inputBoxs[i].id.replace("basket_", "");
					
					var j;
					for( j=0; j< arrayBasket.length; j++)
					{
						if( arrayBasket[j] == id )
							break;
					}

					if( j < arrayBasket.length )
					{
						arrayBasket.splice(j, 1);				
						if( document.getElementById("findquest_"+id) )
						{
							document.getElementById("findquest_"+id).checked = false;
							document.getElementById("findquest_"+id).disabled = false;
						}

						removeCount++;
					}			
				}
			}
		}

		if( removeCount > 0 )
			CallAjaxFindQuestInId("basket");
		else
			alert("ÀÓ½ÃÀúÀå¸ñ·Ï¿¡ »èÁ¦ÇÒ ¹®Á¦¸¦ ¸ÕÀú ¼±ÅÃÇÏ½Ê½Ã¿À.");
	}
	function ShowAllSelect(show)
	{
		if( Prototype.Browser.IE )
		{
			var selectObject = document.getElementsByTagName("select");
			for( var i = 0; i< selectObject.length; i++)
			{
				if(show)
					selectObject[i].style.visibility = "visible";
				else
					selectObject[i].style.visibility = "hidden";
			}			
		}
	}	

	function InitQuestionList()
	{
		var htmlStr;
		htmlStr = "<table align=right cellpadding='0' cellspacing='0' border=0 width=98% height=100% class='txt'></table>";

		document.getElementById("questionlist").innerHTML = htmlStr;
	}

	function BlankQuestionList()
	{
		var htmlStr;
		htmlStr = "<table align=left cellpadding='0' cellspacing='0' border=0 width=200 height=100% class='txt' style='margin-left:5'>";				
		htmlStr += "<tr height=50 valign=middle><td align=center> ÀÛ¼ºµÈ ¹®Á¦ ¸ñ·ÏÀÌ ¾ø½À´Ï´Ù. </td></tr>";
		htmlStr += "</table>";

		document.getElementById("questionlist").innerHTML = htmlStr;
	}

	function AddQuestionList(id, keyword, bunit, munit, ask, count)
	{
		var obj = document.getElementById("questionlist");
		var doc = obj.ownerDocument;
		var tbody = obj.firstChild.firstChild;
		var trs = tbody.childNodes;
		if( doc && trs )
		{
			if( trs.length == 1 )
			{
				if( trs[0].firstChild.firstChild.nodeValue && (trs[0].firstChild.firstChild.nodeValue.search("ÀÛ¼ºµÈ ¹®Á¦ ¸ñ·ÏÀÌ ¾ø½À´Ï´Ù.") > -1) )
				{
					tbody.removeChild(trs[0]);					
					obj.firstChild.removeAttribute("height");
				}
			}
			
			var longString = keyword + "_" + munit + "_" + bunit;
			if( longString.bytes() > 24 )
				longString = longString.cut(24);
			longString += "("+ count + ")";

			var newTR = doc.createElement("tr");
			var newTD = doc.createElement("td");
			var newSPAN = doc.createElement("span");
			var newTEXT = doc.createTextNode(longString);
			var newINPUT = doc.createElement("input");

			newSPAN.setAttribute("title", ask);
			newSPAN.appendChild(newTEXT);

			newINPUT.setAttribute("type", "checkbox");
			newINPUT.setAttribute("id", "questionlist_"+id);
			//newINPUT.setAttribute("style", "padding-right:0;");

			newTD.setAttribute("align", "left");
			
			newTD.appendChild(newINPUT);
			newTD.appendChild(newSPAN);

			newTR.setAttribute("height", "22");
			//newTR.setAttribute("style", "background:url(../img/t_01_listbbs_bg_textline2.jpg) bottom;");			
			newTR.style.background="url(../img/t_bg_board_text.jpg) bottom";
			newTR.appendChild(newTD);
			
			tbody.appendChild(newTR);
		}
	}


	function DoModalPage(url_page, width, height)
	{
		var url = url_page;

		dlg_width = width;
		dlg_height = height;

		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				onComplete: callbackFunction
			}
		);
	}

	function callbackFunction(ajaxResponse)
	{		
		var width, height;
		if( typeof(dlg_width) != "undefined" )
			width = dlg_width;
		if( typeof(dlg_height) != "undefined" )
			height = dlg_height;

		DoModal(ajaxResponse.responseText, width, height);
	}

	function ShowLayer(layerName)
	{
		var object = document.getElementById(layerName);
		if( object )
		{
			if( (object.style.display == "none") || object.style.visibility == "hidden" )
			{
				object.style.display = "block";
				object.style.visibility = "visible";
			}
			else
			{
				object.style.display = "none";
				object.style.visibility = "hidden";
			}
		}
		else
			alert("ÁöÁ¤ÇÑ ±¸¼º¿ä¼Ò°¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
	}

	function ToggleAllCheck(checkboxPrefix)
	{	
		var allCheck = "toggle"+ checkboxPrefix;

		var inputBoxs = document.getElementsByTagName("input");
		var countOfInput = inputBoxs.length;
		var togglevalue = document.getElementById(allCheck).checked;
		;
		for( var i = 0; i < countOfInput; i++)
		{
			if( (inputBoxs[i].type == "checkbox") && (inputBoxs[i].id.search(checkboxPrefix) > -1) )
			{
				if( !inputBoxs[i].disabled )
				{
					inputBoxs[i].checked = togglevalue;
				}
			}
		}
	}
	// CallAjax.phpÀÇ GetContributeÇÔ¼ö¿¡ ´ëÀÀ
	// 

	var treeid;;
	function CallAjaxTree(index)
	{
		var subject, textbook, bunit, munit;
		var parameter = index.split(", ");
		var process = parameter.length;

		if( process > 0 )
			subject = parameter[0];
		if( process > 1 )
			textbook = parameter[1];
		if( process > 2 )
			bunit = parameter[2];
		if( process > 3 )
			munit = parameter[3];
	
		treeid = String(subject);

		if( process == 5 )
			return;

		if( typeof(textbook) != "undefined" )
			treeid += ", " + textbook;
		if( typeof(bunit) != "undefined" )
			treeid += ", " + bunit;
		if( typeof(munit) != "undefined" )
			treeid += ", " + munit;

		var url = '../lib_include/CallAjax.php';
		var pars =  {
			method: "GetAttribute",
			sub: subject,
			text: textbook,
			bunit: bunit,
			munit: munit
		} ;

		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionSearchList
			}
		);
	}

	function callbackFunctionSearchList(ajaxResponse)
	{
		var dom = ajaxResponse.responseXML.documentElement;

		if( !treeview ) {
			treeview = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);	
			//treeview.setOnClickHandler(CallAjaxTree);
			treeview.setOnDblClickHandler(CallAjaxTree);		

		}
		if( dom )
		{		

			var nodes = dom.getElementsByTagName("item");

			if( nodes && nodes.length )
			{						
				if( treeid.match(", ") == null )
					treeid = 0;

				treeview.deleteChildItems(treeid);

				var preItem = firstChildNodeValue(nodes[0], "id");
				treeview.insertNewItem(treeid,firstChildNodeValue(nodes[0], "id"),firstChildNodeValue(nodes[0], "name"),0,0,0,0,"");	
				
				for( var i = 1; i<nodes.length; i++)
				{
					treeview.insertNewNext(preItem, firstChildNodeValue(nodes[i], "id"),firstChildNodeValue(nodes[i], "name"),0,0,0,0,0,"");
				}

			}			
		}
	}

	// selectboxÀÇ ¸ðµç ¾ÆÀÌÅÛÀ» »èÁ¦
	function InitAllItem(Object)
	{
		var i = Object.length;
		while(i >= 0 )
		{
			Object.remove(Object.options[i]);
			i--;
		}
		var default_string;
		if( document.getElementById("title") && ((document.getElementById("title").value == "regquest") || (document.getElementById("title").value == "envview") ) )
			default_string = "¼±ÅÃÇÏ¼¼¿ä";
		else
			default_string = "ÀüÃ¼¼±ÅÃ";

		var opt = new Option(default_string, -1) ;				
		Object.options.add(opt) ;
	}

	// CallAjax.phpÀÇ GetContributeÇÔ¼ö¿¡ ´ëÀÀ
	// Combo(selectbox)ÀÇ ID´Â DB TableÀÇ ¸í¿¡¼­ "T_"¸¦ Á¦¿ÜÇÑ ¸íÀ¸·Î, id, nameÀÇ °ªÀ» ÀÌ¿ëÇÏ¿© SelectÀÇ optionÀ» ±¸¼ºÇØÁØ´Ù.
	var ComboId;
	var callbackAttributeComboId = new Array("Class", "Subject", "Textbook", "Bunit", "Munit", "Sunit");
	var callbackContributeComboId = new Array("Sido", "Gugun", "School");
	var DefaultComboValueClass, DefaultComboValueSubject, DefaultComboValueTextbook, DefaultComboValueBunit, DefaultComboValueMunit, DefaultComboValueSunit;
	var DefaultComboValueSido, DefaultComboValueGugun, DefaultComboValueSchool;
	
	function callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, Combo, DefaultValue)
	{		
		//alert(ajaxResponse.responseText + Combo + DefaultValue);
		var Default = DefaultValue;
		//alert(Default);
		var dom = ajaxResponse.responseXML.documentElement;
		
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("option");
			
			if( nodes )
			{		
				var selectObject = document.getElementById(Combo);
				
				InitAllItem(selectObject);
				
				for(i=0; i < nodes.length; i++) 
				{
					var opt = new Option(nodes[i].firstChild.nodeValue, nodes[i].getAttribute("value")) ;
					if( nodes[i].getAttribute("value") == Default )
						opt.selected = true;
					selectObject.options.add(opt) ;
				}

			}
		}
	}

	function callbackFunctionClassComboFromDBWithDefaultValue(ajaxResponse)
	{
		//alert(ajaxResponse.responseText);
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "Class", DefaultComboValueClass);
	}
	function callbackFunctionSubjectComboFromDBWithDefaultValue(ajaxResponse)
	{
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "Subject", DefaultComboValueSubject);
	}
	function callbackFunctionTextbookComboFromDBWithDefaultValue(ajaxResponse)
	{
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "Textbook", DefaultComboValueTextbook);
	}
	function callbackFunctionBunitComboFromDBWithDefaultValue(ajaxResponse)
	{
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "Bunit", DefaultComboValueBunit);
	}
	function callbackFunctionMunitComboFromDBWithDefaultValue(ajaxResponse)
	{
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "Munit", DefaultComboValueMunit);
	}
	function callbackFunctionSunitComboFromDBWithDefaultValue(ajaxResponse)
	{
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "Sunit", DefaultComboValueSunit);
	}
	function callbackFunctionSidoComboFromDBWithDefaultValue(ajaxResponse)
	{
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "Sido", DefaultComboValueSido);
	}
	function callbackFunctionGugunComboFromDBWithDefaultValue(ajaxResponse)
	{
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "Gugun", DefaultComboValueGugun);
	}
	function callbackFunctionSchoolComboFromDBWithDefaultValue(ajaxResponse)
	{
		callbackFunctionComboFromDBWithDefaultValue(ajaxResponse, "School", DefaultComboValueSchool);
	}

	function CallAjaxComboFromDB(Combo, ReferenceIndex, DefaultValue)
	{
		ComboId = Combo;
		document.getElementById(ComboId).options[document.getElementById(ComboId).selectedIndex].text = "Now loading ..";
		var ReferenceValue = ReferenceIndex;//document.getElementById(Combo).selectedIndex;
		var url = '../lib_include/CallAjax.php';

		var pars =  {
			method: "GetContribute",
			combo: Combo,
			pvalue: ReferenceValue
		} ;

		var callbackFunction = callbackFunctionComboFromDB;

		if( (typeof(DefaultValue) != "undefined") && (DefaultValue != "") )
		{
			switch( ComboId )
			{
				case "Class":
					callbackFunction = callbackFunctionClassComboFromDBWithDefaultValue;
					DefaultComboValueClass = DefaultValue;
					break;
				case "Subject":
					callbackFunction = callbackFunctionSubjectComboFromDBWithDefaultValue;
					DefaultComboValueSubject = DefaultValue;
					break;
				case "Textbook":
					callbackFunction = callbackFunctionTextbookComboFromDBWithDefaultValue;
					DefaultComboValueTextbook = DefaultValue;
					break;
				case "Bunit":
					callbackFunction = callbackFunctionBunitComboFromDBWithDefaultValue;
					DefaultComboValueBunit = DefaultValue;
					break;
				case "Munit":
					callbackFunction = callbackFunctionMunitComboFromDBWithDefaultValue;
					DefaultComboValueMunit = DefaultValue;
					break;
				case "Sunit":
					callbackFunction = callbackFunctionSunitComboFromDBWithDefaultValue;
					DefaultComboValueSunit = DefaultValue;
					break;
				case "Sido":
					callbackFunction = callbackFunctionSidoComboFromDBWithDefaultValue;
					DefaultComboValueSido = DefaultValue;
					break;
				case "Gugun":
					callbackFunction = callbackFunctionGugunComboFromDBWithDefaultValue;
					DefaultComboValueGugun = DefaultValue;
					break;
				case "School":
					callbackFunction = callbackFunctionSchoolComboFromDBWithDefaultValue;
					DefaultComboValueSchool = DefaultValue;
					break;
			}
		}

		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunction
			}
		);
	}

	function callbackFunctionComboFromDB(ajaxResponse)
	{		
		var dom = ajaxResponse.responseXML.documentElement;
		
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("option");
			
			if( nodes )
			{		
				var selectObject = document.getElementById(ComboId);
				
				InitAllItem(selectObject);
				
				for(i=0; i < nodes.length; i++) 
				{
					var opt = new Option(nodes[i].firstChild.nodeValue, nodes[i].getAttribute("value")) ;				
					document.getElementById(ComboId).options.add(opt) ;
				}

			}
		}

		var i;
		for( i = 0; i< callbackAttributeComboId.length; i++)
		{
			if(callbackAttributeComboId[i] == ComboId)
				break;
		}
		if( i < callbackAttributeComboId.length )
		{
			if( document.getElementById("title") && (document.getElementById("title").value == "searchquestion") )
			{
				if( (i == 1) && (treeview != null) )
					treeview.deleteChildItems(0);
			}

			while( ++i < callbackAttributeComboId.length)
			{
				if(document.getElementById(callbackAttributeComboId[i]) && (document.getElementById(callbackAttributeComboId[i]).options.length > 1))
					InitAllItem(document.getElementById(callbackAttributeComboId[i]));
			}
		}
		for( i = 0; i< callbackContributeComboId.length; i++)
		{
			if(callbackContributeComboId[i] == ComboId)
				break;
		}
		if( i < callbackContributeComboId.length )
		{
			while( ++i < callbackContributeComboId.length)
			{
				if(document.getElementById(callbackContributeComboId[i]) && (document.getElementById(callbackContributeComboId[i]).options.length > 1))
					InitAllItem(document.getElementById(callbackContributeComboId[i]));
			}
		}		

		if( document.getElementById("title") )
		{
			if( (document.getElementById("title").value == "regquest") && ( ComboId == "Class" ) )			
				CallAjaxQuestList("questionlist");
			else if ( (document.getElementById("title").value == "searchquestion") && ( ComboId == "Class" ) )			
			{
				CallAjaxFindQuestInId('basket');
			}
		}
	}

	function CallAjaxDeleteQuestion(question)
	{
		var url = '../lib_include/CallAjax.php';

		var pars =  {
			method: "DeleteQuestion",
			question: question

		} ;

		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionDeleteQuestion
			}
		);

	}

	function CallAjaxFindQuestInId(tbody)
	{
		CallAjaxFindQuest(tbody, arrayBasket);
	}

	/// °Ë»ö 
	/// °Ë»ö°á°ú, ÀÓ½Ã ÀúÀå¸ñ·Ï¿¡ »ç¿ë
	/// °Ë»ö°á°ú´Â findquest
	/// ÀÓ½ÃÀúÀå¸ñ·ÏÀº basket
	/// ·Î div¾ÆÀÌµð¸¦ Àâ¾ÆÁØ´Ù.³»ºÎÀûÀ¸·Î ¾ÆÀÌµð ÀÌ¸§À» °¡Áö°í, ÇüÅÂ¸¦ °áÁ¤ÇÏ±â ¶§¹®¿¡..
	var TBodyID;
	function CallAjaxFindQuest(tbody, whereInId)
	{
		// alert("arrayBaket = "+whereInId);
		TBodyID = tbody;

		var htmlStr = makeHtmlTableString(0);

		document.getElementById(TBodyID).innerHTML = htmlStr;

		var sql_query = "Q.id as id, C.name as class_name, S.name as subject_name";
		sql_query += ", B.name as bunit_name, M.name as munit_name, SS.name as sunit_name, Q.keyword as keyword";
		// sql_query += ", if(Q.level=1,'high', if(Q.level=2, 'middle', if(Q.level=3, 'low', '-'))) as level";
		sql_query += ", Q.level as level, I.ask as ask, count(Q.id) as item_num";

		var i = 0;
		var sql_where = new Array();
		
		var Class, Subject, Textbook, Bunit;
		var term, field, level, Muint, Sunit, form;
		var Sido, Gugun, School, year;
		var strSearch;

		if(document.getElementById("Class"))
		{
			Class = document.getElementById("Class").value;
			
			if( Class > -1 )
				sql_where[i++] = "Q.class = " + Class;
		}
		if(document.getElementById("Subject"))
		{
			Subject = document.getElementById("Subject").value;

			if( Subject > -1 )
				sql_where[i++] = "Q.subject = " + Subject;
		}
		
		var bTreeSelect = false;
		if( document.getElementById("title") && document.getElementById("title").value == "searchquestion" )
		{
			bTreeSelect = true;
			
			if( treeview && treeview.getSelectedItemId() )
			{
				var parameter = treeview.getSelectedItemId().split(", ");
				var process = parameter.length;

				if( process > 1 )
				{
					Textbook = parameter[1];
					sql_where[i++] = "Q.textbook = " + Textbook;
				}
				if( process > 2 )
				{
					Bunit = parameter[2];
					sql_where[i++] = "Q.b_unit = " + Bunit;
				}
				if( process > 3 )
				{
					Munit = parameter[3];
					sql_where[i++] = "Q.m_unit = " + Munit;
				}
				if( process > 4 )
				{
					Sunit = parameter[4];
					sql_where[i++] = "Q.s_unit = " + Sunit;
				}
			}

			if( document.getElementById("SearchString").value != "" )
				bStringInput = true;
		}
		else
		{
			if(document.getElementById("Textbook"))
				Textbook = document.getElementById("Textbook").value;
			if(document.getElementById("Bunit"))
				Bunit = document.getElementById("Bunit").value;
			
			if( Textbook > -1 )
				sql_where[i++] = "Q.textbook = " + Textbook;
			if( Bunit > -1 )
				sql_where[i++] = "Q.b_unit = " + Bunit;

			var bAttributeInput, bContributeInput, bStringInput;
			if( document.getElementById("AttributeInput") )
				bAttributeInput = document.getElementById("AttributeInput").checked;
			if( document.getElementById("ContributeInput") )
				bContributeInput = document.getElementById("ContributeInput").checked;
			if( document.getElementById("StringInput") )
				bStringInput = document.getElementById("StringInput").checked;
			

			if( bAttributeInput )
			{
				term = document.getElementById("term").value;
				field = document.getElementById("field").value;
				level = document.getElementById("level").value;
				Muint = document.getElementById("Munit").value;
				Sunit = document.getElementById("Sunit").value;
				form = document.getElementById("form").value;

				if( term > -1 )
					sql_where[i++] = "Q.term = " + term;			
				if( field > -1 )
					sql_where[i++] = "Q.field = " + field;			
				if( level > -1 )
					sql_where[i++] = "Q.level = " + level;			
				if( Muint > -1 )
					sql_where[i++] = "Q.m_unit = " + Muint;			
				if( Sunit > -1 )
					sql_where[i++] = "Q.s_unit = " + Sunit;			
				if( form > -1 )
					sql_where[i++] = "Q.form = " + form;
			}
			if( bContributeInput )
			{
				Sido = document.getElementById("Sido").value;
				Gugun = document.getElementById("Gugun").value;
				School = document.getElementById("School").value;
				year = document.getElementById("year").value; 
					
				if( Sido > -1 )
					sql_where[i++] = "Q.sido = " + Sido;			
				if( Gugun > -1 )
					sql_where[i++] = "Q.gugun = " + Gugun;			
				if( School > -1 )
					sql_where[i++] = "Q.school = " + School;			
				if( year > -1 )
					sql_where[i++] = "Q.year = " + year;	
			}
		}
		if( bStringInput )
		{
			strSearch = document.getElementById("SearchString").value;

			sql_where[i++] = "Q.keyword like \'%" + strSearch + "%\'" ;
		}

		var query_where_str = String("");
		if( sql_where.length > 0 )
		{
			query_where_str += " where ";
			for( var j = 0; j < sql_where.length; j++)
			{
				if( j == 0 )
					query_where_str += sql_where[j];
				else
					query_where_str += " && " + sql_where[j];
			}
		}	
		if( typeof(whereInId) != "undefined" )
		{
			if( whereInId == "")
				whereInId = "0"
				query_where_str = " where ";
			if( query_where_str.length > 10 )
				query_where_str += " && ";
				query_where_str += " Q.id in ("+ whereInId + ")";
		}

		//document.getElementById(TBodyID).innerHTML = "Now loading ..";
		//var ReferenceValue = ReferenceIndex;//document.getElementById(Combo).selectedIndex;

		// alert( query_where_str);
		var url = '../lib_include/CallAjax.php';

		var pars =  {
			method: "GetListFromQuery",
			sql_query: sql_query,
			sql_where: query_where_str
		} ;
		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionSearchQuestionList
			}
		);
	}
	
	var TPage;
	var pageSize = 7;
	function CallAjaxQuestList(tbody, page)
	{
		TBodyID = tbody;

		var htmlStr = makeHtmlTableString(0);

		document.getElementById(TBodyID).innerHTML = htmlStr;

		var sql_query = "Q.id as id, C.name as class_name, S.name as subject_name";
		sql_query += ", B.name as bunit_name, M.name as munit_name, SS.name as sunit_name, Q.keyword as keyword";
		sql_query += ", Q.level as level, I.ask as ask, count(Q.id) as item_num";

		var query_where_str = " where";

		if( typeof(page) == "undefined" )
			page = 1;
		TPage = page;
		
		// ¿À´Ã µî·ÏµÈ ÀÚ±â ¹®Á¦¸¦ º¸¿©ÁÖ±â... 
		query_where_str += " Q.regdate = curdate()";
		// query_where_str += " Q.regdate = date_sub(curdate(), interval 4 day) ";
		// where Q.regdate = date_sub(curdate(), interval 3 day)


		// alert( query_where_str);
		var url = '../lib_include/CallAjax.php';

		var pars =  {
			method: "GetListFromQuery",
			sql_query: sql_query,
			sql_where: query_where_str
		} ;
		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionQuestionList
			}
		);
	}

	function CallAjaxQuestListToTest(tbody, page)
	{
		TBodyID = tbody;

		var htmlStr = makeHtmlTableString(0);

		document.getElementById(TBodyID).innerHTML = htmlStr;

		var sql_query = "Q.id as id, C.name as class_name, S.name as subject_name";
		sql_query += ", B.name as bunit_name, M.name as munit_name, SS.name as sunit_name, Q.keyword as keyword";
		sql_query += ", Q.level as level, I.ask as ask, count(Q.id) as item_num";

		var query_where_str = " where";

		if( typeof(page) == "undefined" )
			page = 1;
		TPage = page;
				
		if( questionArray == "")
			questionArray = "0"
		query_where_str += " Q.id in ("+ questionArray + ")";


		// alert( query_where_str);
		var url = '../lib_include/CallAjax.php';

		var pars =  {
			method: "GetListFromQuery",
			sql_query: sql_query,
			sql_where: query_where_str
		} ;
		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionQuestionListToTest
			}
		);
	}
	
	function CallGetLatestQuestionList()
	{
		var htmlStr = makeHtmlTableString(0);

		document.getElementById("latestquestionlist").innerHTML = htmlStr;

		var sql_query = "Q.id as id, S.name as subject_name";
		sql_query += ", B.name as bunit_name, M.name as munit_name, SS.name as sunit_name";
		sql_query += ", I.ask as ask, count(Q.id) as item_num";

		var query_where_str = "";
		var query_limit = " limit 7"

		// alert( query_where_str);
		var url = '../lib_include/CallAjax.php';

		var pars =  {
			method: "GetListFromQuery",
			sql_query: sql_query,
			sql_where: query_where_str,
			sql_limit: query_limit
		} ;
		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionLatestQuestionList
			}
		);
	}
	
	function CallGetLatestTestList()
	{
		var htmlStr = makeHtmlTableString(0);

		document.getElementById("latesttestlist").innerHTML = htmlStr;

		var sql_query = "E.id as id, E.part as class_name, E.subject as subject_name, EX.examscore as score, EX.state as state";
		sql_query += ", E.term, E.title, E.cnt, E.time_start, E.time_end";

		var query_where_str = "";
		var query_limit = " limit 7"

		// alert( query_where_str);
		var url = '../lib_include/CallAjax.php';
		
		var pars =  {
			method: "GetTestListFromQuery",
			sql_query: sql_query,
			sql_where: query_where_str,
			sql_limit: query_limit
		} ;
		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionLatestTestList
			}
		);
	}
	
	function CallGetLatestQuestionShortList()
	{
		var htmlStr = makeHtmlTableString(0);

		document.getElementById("latestquestionshortlist").innerHTML = htmlStr;

		var sql_query = "Q.id as id";
		sql_query += ", I.ask as ask, count(Q.id) as item_num";

		var query_where_str = "";
		var query_limit = " limit 4";

		// alert( query_where_str);
		var url = '../lib_include/CallAjax.php';

		var pars =  {
			method: "GetListFromQuery",
			sql_query: sql_query,
			sql_where: query_where_str,
			sql_limit: query_limit
		} ;
		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionLatestQuestionShortList
			}
		);
	}

	function CallGetLatestNewsList()
	{
		var htmlStr = makeHtmlTableString(0);

//		document.getElementById("latestnewslist").innerHTML = htmlStr;
/*
		var sql_query = "bd_num, bd_subject, bd_write_date";

		var query_where_str = " where bbs_db_num = 8";
		var query_limit = " limit 4";

		// alert( query_where_str);
		var url = '../lib_include/CallAjax.php';

		var pars =  {
			method: "GetBoardListFromQuery",
			sql_query: sql_query,
			sql_where: query_where_str,
			sql_limit: query_limit
		} ;
		var ajax = new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: pars,
				onComplete: callbackFunctionLatestNewsList
			}
		);*/
	}

	function firstChildNodeValue( Object, strTag)
	{
		var strValue = "-";
		var nodes = Object.childNodes;
		var i = 0;
		while( nodes[i] )
		{
			if( nodes[i].nodeName == strTag )
				break;

			i++;
		}
		if( i < Object.childNodes.length )
		{
			var node = nodes[i].firstChild;
			if( node )
			{
				// µðÆúÆ® Ã³¸®µÈ °ªµé.. ¾ø¾ÖÀÚ
				if( node.nodeValue != "-1" )
					strValue = node.nodeValue;
				
			}
		}
		
		return strValue;
	}

	String.prototype.cut = function(len) {
    var str = this;
    var l = 0;
    for (var i=0; i<str.length; i++) {
        l += (str.charCodeAt(i) > 128) ? 2 : 1;
        if (l > len) return str.substring(0,i) + "...";
    }
    return str;
	}
	
	String.prototype.cutnalert = function(len) 
	{
		var str = this;
		var l = 0;
		for (var i=0; i<str.length; i++) 
		{
			l += (str.charCodeAt(i) > 128) ? 2 : 1;
			if (l > len)
			{
				
				return "<span title='"+this+"'>"+str.substring(0,i) + "...</span>";
			}
		}
		return str;
	}

	/**
	* bool String::bytes(void)
	* ÇØ´ç½ºÆ®¸µÀÇ ¹ÙÀÌÆ®´ÜÀ§ ±æÀÌ¸¦ ¸®ÅÏÇÕ´Ï´Ù. (±âÁ¸ÀÇ length ¼Ó¼ºÀº 2¹ÙÀÌÆ® ¹®ÀÚ¸¦ ÇÑ±ÛÀÚ·Î °£ÁÖÇÕ´Ï´Ù)
	*/
	String.prototype.bytes = function() {
		var str = this;
		var l = 0;
		for (var i=0; i<str.length; i++) l += (str.charCodeAt(i) > 128) ? 2 : 1;
		return l;
	}

	/// listmode 0, 1Àº findquest, basket¿¡¼­ »ç¿ë, 0Àº °Ë»öÁß, 1Àº °Ë»ö°á°ú.. Ãâ·Â
	/// listmode 2, 3Àº listquestion¿¡¼­ »ç¿ë 2´Â °Ë»öÁß, 3Àº °Ë»ö °á°ú Ãâ·Â
	function makeHtmlTableString(listmode, nodes, page)
	{
		var htmlStr = "";
		var longstring;
		switch( listmode )
		{
			case 0:
			case 1:
			{
				if( listmode == 0 || (nodes.length == 0) )
					htmlStr = "<table align=left cellpadding='0' cellspacing='0' border=0 width=100% height=100% class='txt'>";
				else
					htmlStr = "<table align=left cellpadding='0' cellspacing='0' border=0>";
//				htmlStr += "<tr height='27'>";
//				htmlStr +=	"<td width=28 style='background: url(../img/t_02_search_bg_title.jpg);'>";
//				htmlStr += 	"<input type='checkbox' id='toggle" + TBodyID + "' name='ck' style='margin:0;' onclick='javascript:ToggleAllCheck(\""+TBodyID+"\");'>";
//				htmlStr += 	"</td>";
//				htmlStr += 	"<td width=39 style='background: url(../img/t_02_search_bg_title.jpg);'>ÇÐ³â</td>";
//				htmlStr += 	"<td width=47 style='background: url(../img/t_02_search_bg_title1.jpg);'>°ú¸ñ</td>";
//				htmlStr += 	"<td width=75 style='background: url(../img/t_02_search_bg_title.jpg);'>´ë´Ü¿ø</td>";
//				htmlStr += 	"<td width=78 style='background: url(../img/t_02_search_bg_title2.jpg);'>Áß´Ü¿ø</td>";
//				htmlStr += 	"<td width=74 style='background: url(../img/t_02_search_bg_title.jpg);'>¼Ò´Ü¿ø</td>";
//				htmlStr += 	"<td width=180 style='background: url(../img/t_02_search_bg_title3.jpg);'>¹®Á¦</td>";
//				htmlStr += 	"<td width=60 style='background: url(../img/t_02_search_bg_title.jpg);'>Å°¿öµå</td>";
//				htmlStr += 	"<td width=67 style='background: url(../img/t_02_search_bg_title4.jpg);'>³­ÀÌµµ</td>";
//				htmlStr += "</tr>";

				if( nodes && nodes.length )
				{	
					for(i=0; i < nodes.length; i++) 
					{
//						htmlStr += "<tr><td valign=top OnMouseOver=\"this.className='tdOn'\">"
//						htmlStr += "<table border=0 cellspacing=0 cellpadding=0 class='02table4'>";
/*						TD¿¡ ¸µÅ©¸¦ °É±â À§ÇØ ¼öÁ¤ (2007.08.01)							*/
						htmlStr += "<tr height=26 style='backgroundColor:white;' id=tr_"+i; //JavaScript:ChangeBg(this);";
//						if( TBodyID == "findquest" )
//							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";
						htmlStr += "><td width=24 bgcolor=#cccccc >";
						htmlStr += "<input type='checkbox' id='" + TBodyID + "_" + firstChildNodeValue( nodes[i], "id") + "' style='margin:0;'>";
						htmlStr += "</td><td width=43";
						if( TBodyID == "findquest" )
							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";
						htmlStr += ">" + firstChildNodeValue( nodes[i], "class_name").cutnalert(5);
						htmlStr += "</td><td width=47";
						if( TBodyID == "findquest" )
							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";
						htmlStr += ">" + firstChildNodeValue( nodes[i], "subject_name").cutnalert(5);
						htmlStr += "</td><td width=70";
						if( TBodyID == "findquest" )
							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";
						htmlStr += ">" + firstChildNodeValue( nodes[i], "bunit_name").cutnalert(7);
						htmlStr += "</td><td width=70";
						if( TBodyID == "findquest" )
							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";
						htmlStr += ">" + firstChildNodeValue( nodes[i], "munit_name").cutnalert(7);
						htmlStr += "</td><td width=70";
						if( TBodyID == "findquest" )
							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";
						htmlStr += ">" + firstChildNodeValue( nodes[i], "sunit_name").cutnalert(7);
						htmlStr += "</td><td width=180 style='text-align:left;'";
						if( TBodyID == "findquest" )
							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";
												
						longstring = firstChildNodeValue( nodes[i], "ask");
						if( longstring.bytes() > 25 )
							longstring = longstring.cutnalert(25);
						htmlStr += ">" + longstring;
						htmlStr += "("+ firstChildNodeValue( nodes[i], "item_num") + ")";

						htmlStr += "</td><td width=60";
						if( TBodyID == "findquest" )
							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";
						htmlStr += ">" + firstChildNodeValue( nodes[i], "keyword").cutnalert(7);
						htmlStr += "</td><td width=67 align=center";
						if( TBodyID == "findquest" )
							htmlStr += " onclick='javascript:QuickViewQuestion("+firstChildNodeValue( nodes[i], "id")+");' style='cursor:pointer;'";

						var level = firstChildNodeValue( nodes[i], "level");
						switch (Number(level))
						{
						case 1:
							htmlStr += ">" + "»ó";
							break;
						case 2:
							htmlStr += ">" + "Áß";
							break;
						case 3:
							htmlStr += ">" + "ÇÏ";
							break;
						default:
							htmlStr += "-";
							break;
						}
						htmlStr += "</td></tr>";
						if( TBodyID == "findquest" )
						{
							htmlStr += "<tr><td colspan=9><div id=\'quickview_"+firstChildNodeValue( nodes[i], "id")+"'></div></td></tr>";
						}

//						htmlStr += "</table></td></tr>";
					}
				}
				else if( listmode == 0 )
					htmlStr += "<tr valign=middle><td align=center><img src='../img/loading.gif'></td></tr>";
				else
					htmlStr += "<tr valign=middle><td align=center> °Ë»ö ³»¿ëÀÌ ¾ø½À´Ï´Ù. </td></tr>";
				htmlStr += "</table>";
			}
			break;
			case 2:
			{
				if( nodes.length == 0 )
					htmlStr = "<table align=right cellpadding='0' cellspacing='0' border=0 width=98% height=100% class='txt'>";
				else
					htmlStr = "<table align=right cellpadding='0' cellspacing='0' border=0 width=98% class='txt'>";

				
				if( nodes && nodes.length )
				{	
					// for(i=(pageSize * (page - 1)); (i < nodes.length) && (i < pageSize * page); i++) 
					for(i=0; i < nodes.length; i++) 
					{					
						htmlStr += "<tr height=22 style='background: url(../img/t_01_listbbs_bg_textline2.jpg) bottom;'>";
						htmlStr += "<td  width=28>";
						htmlStr += "<input type='checkbox' id='" + TBodyID + "_" + firstChildNodeValue( nodes[i], "id") + "' style='margin:0;'>";
						htmlStr += "</td><td align=left>";
						htmlStr += "<span title='"+firstChildNodeValue( nodes[i], "ask")+"' style='cursor:pointer;'>";
						////
						//htmlStr += firstChildNodeValue( nodes[i], "bunit_name") + "_" + firstChildNodeValue( nodes[i], "munit_name") + "_" + firstChildNodeValue( nodes[i], "sunit_name");
						longstring = firstChildNodeValue( nodes[i], "keyword") + "_" + firstChildNodeValue( nodes[i], "munit_name") + "_" + firstChildNodeValue( nodes[i], "bunit_name");
						if( longstring.bytes() > 24 )
						{
							longstring = longstring.cut(24);
						}
						htmlStr += longstring;
						htmlStr += "("+ firstChildNodeValue( nodes[i], "item_num") + ")";
						////
						htmlStr += "</span>";
						htmlStr += "</td></tr>";
					}
				}
				else
					htmlStr += "<tr height=50 valign=middle><td colspan=2 align=center> ÀÛ¼ºµÈ ¹®Á¦ ¸ñ·ÏÀÌ ¾ø½À´Ï´Ù. </td></tr>";
				htmlStr += "</table>";
			}
			break;
			case 3:
			{
				if( nodes.length == 0 )
					htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100% class='txt'>";
				else
					htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% class='txt'>";
				
				if( nodes && nodes.length )
				{	
					for(i=0; i < nodes.length; i++) 
					{			
						htmlStr += "<tr>";
						htmlStr += "<td width=20><input type='checkbox' id='latestquestionlist_" + firstChildNodeValue( nodes[i], "id") + "' ></td>";
						htmlStr += "	<td width=100>" + firstChildNodeValue( nodes[i], "subject_name").cutnalert(10) + "</td>";						 
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=100 style='text-align:left; padding-left:5;'>" + firstChildNodeValue( nodes[i], "bunit_name").cutnalert(10) + "</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=100 style='text-align:left; padding-left:5;'>" + firstChildNodeValue( nodes[i], "munit_name").cutnalert(10) + "</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=100 style='text-align:left; padding-left:5;'>" + firstChildNodeValue( nodes[i], "sunit_name").cutnalert(10) + "</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=295 style='text-align:left; padding-left:5;'>" + firstChildNodeValue( nodes[i], "ask").cutnalert(30) + "</td>";
						//htmlStr += "	<td></td>";
						htmlStr += "</tr>";
					}
				}
				else
					htmlStr += "<tr height=150 valign=middle><td align=center> ÃÖ½Å ¸ñ·ÏÀÌ ¾ø½À´Ï´Ù. </td></tr>";
				htmlStr += "</table>";
			}
			break;
			case 4:
			{
				if( nodes.length == 0 )
					htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100% class='txt'>";
				else
					htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% class='txt'>";
				
				if( nodes && nodes.length ) 
				{	
					for(i=0; i < nodes.length; i++) 
					{	
						if (firstChildNodeValue( nodes[i], "state") == 1)
						{
							htmlStr += "<tr onclick=location.href='../student/resultsheet.php?examid=" + firstChildNodeValue( nodes[i], "id") + "' style='cursor:pointer;'>";
						} else {
							htmlStr += "<tr onclick=location.href='../student/viewtest.php?examid=" + firstChildNodeValue( nodes[i], "id") + "' style='cursor:pointer;'>";
						}
						htmlStr += "	<td width=80>" + firstChildNodeValue( nodes[i], "class_name") + "</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=80>" + firstChildNodeValue( nodes[i], "subject_name") + "</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=60>" + firstChildNodeValue( nodes[i], "term") + "ÇÐ±â</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=193>" + firstChildNodeValue( nodes[i], "title") + "</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=60>" + firstChildNodeValue( nodes[i], "cnt") + "</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=120>" + firstChildNodeValue( nodes[i], "time_start") + "ºÎÅÍ<br>"+ firstChildNodeValue( nodes[i], "time_end") + "±îÁö</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=60>" + ((firstChildNodeValue( nodes[i], "state") == 1)?"Á¦Ãâ":"¹ÌÁ¦Ãâ") + "</td>";
						htmlStr += "	<td></td>";
						htmlStr += "	<td width=60>" + firstChildNodeValue( nodes[i], "score") + "</td>";
						htmlStr += "</tr>";						
					}
				}
				else
					htmlStr += "<tr height=150 valign=middle><td align=center> ÃÖ½Å ¸ñ·ÏÀÌ ¾ø½À´Ï´Ù. </td></tr>";
				htmlStr += "</table>";
			}
			break;
			case 5:
			{
				if( nodes.length == 0 )
					htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100%>";
				else
					htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100%>";
				
				if( nodes && nodes.length ) 
				{	
					for(i=0; i < nodes.length; i++) 
					{	
						htmlStr += "<tr height=24 class='board'>";
						htmlStr += "	<td colspan=3 style='background-image:url(../img/t_bg_board_bg_right_line.jpg);' align=left>";
						htmlStr += "		<a href='../teacher/viewquestion.php?questions="+firstChildNodeValue( nodes[i], "id")+"'>"+firstChildNodeValue( nodes[i], "ask").cutnalert(30)+"("+firstChildNodeValue( nodes[i], "item_num")+")</a>";
						htmlStr += "	</td>";
						htmlStr += "</tr>";
					}
				}
				else
					htmlStr += "<tr height=150 valign=middle><td align=center> ÃÖ½Å ¸ñ·ÏÀÌ ¾ø½À´Ï´Ù. </td></tr>";
				htmlStr += "</table>";
			}
			break;
			case 6:
			{/*
				if( nodes.length == 0 )
					htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100% >";
				else
					htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100%>";
				
				if( nodes && nodes.length ) 
				{	
					for(i=0; i < nodes.length; i++) 
					{	
						htmlStr += "<tr class='board'>";
						htmlStr += "	<td height=24 colspan=5 style='background-image: url(../img/t_bg_board_text.jpg);'>";
//						htmlStr += "		<a href='../board/view.php?bbs_code=news&bd_num="+firstChildNodeValue( nodes[i], "id")+"'>"+firstChildNodeValue( nodes[i], "bd_subject")+"</a>";
						htmlStr += "	</td>";
						htmlStr += "	<td align=left colspan=2 style='background-image: url(../img/t_bg_board_text.jpg);'>";
							//[<?=rg_date($rs_list["bd_write_date"],"%Y-%m-%d")?>]
						htmlStr += "	</td>";
						htmlStr += "</tr>";
					}
				}
				else
					htmlStr += "<tr height=150 valign=middle><td align=center> ÃÖ½Å ¸ñ·ÏÀÌ ¾ø½À´Ï´Ù. </td></tr>";
				htmlStr += "</table>";*/
			}
			break;
		}
		return  htmlStr;
	}

	function makeHtmlTableNavi(nodes, callfunction, page)
	{
		var htmlStrNavi = "";

		if( nodes && (nodes.length > pageSize) )
		{
			var totalpage = parseInt(nodes.length / pageSize);
			var remainpage = nodes.length % pageSize;
			if( remainpage > 0 )
				totalpage += 1;

			// htmlStrNavi += totalpage+ " : " + remainpage;
					
			if( page > 1 )
			{
				htmlStrNavi += "[<a href=\'javascript:"+callfunction+"(\""+TBodyID;
				htmlStrNavi += "\", 1);\'>1</a>] ";

				htmlStrNavi += "<a href=\'javascript:"+callfunction+"(\""+TBodyID;
				htmlStrNavi += "\", "+(page-1);
				htmlStrNavi += ");\'><<</a> ";
			}
			else
				htmlStrNavi += "[1] << ";

			var start = 1;
			var last = totalpage;
			var navisize = 7; //È¦¼ö·Î.. ÀÔ·Â

			if( totalpage > navisize )
			{
				if( page > (navisize/2 + 0.9) )
				{
					start = page - parseInt(navisize/2);
					if( start + navisize - 1 > totalpage )
						start = totalpage - navisize + 1;
				}
				
				last = start + navisize - 1;
			}

			for( var i = start; i <= last; i++)
			{
				if( i == page )
					htmlStrNavi += " " + i + " ";
				else
					htmlStrNavi += "<a href=\'javascript:"+callfunction+"(\""+TBodyID+ "\", "+i+");\'>"+i+"</a> ";
			}

			if( page < totalpage )							
			{
				htmlStrNavi += " <a href=\'javascript:"+callfunction+"(\""+TBodyID;
				htmlStrNavi += "\", "+(page+1);
				htmlStrNavi += ");\'>>></a>";
					
				htmlStrNavi += " [<a href=\'javascript:"+callfunction+"(\""+TBodyID;
				htmlStrNavi += "\", "+totalpage;
				htmlStrNavi += ");\'>"+totalpage+"</a>]";
			}
			else
				htmlStrNavi += " >> [" + totalpage + "]";		
			
			// alert(htmlStrNavi);
		}

		return htmlStrNavi;
	}

	function callbackFunctionSearchQuestionList(ajaxResponse)
	{
		//alert(ajaxResponse.responseText);
		var dom = ajaxResponse.responseXML.documentElement;
		// alert(dom);
		var htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100% class='txt'><tr><td align=center> °Ë»ö °á°ú¿¡ ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. </td></tr></table>";
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("tr");
		 
			htmlStr = makeHtmlTableString(1, nodes);
			
		}
		document.getElementById(TBodyID).innerHTML = htmlStr;
	}

	function callbackFunctionQuestionList(ajaxResponse)
	{
		//alert(ajaxResponse.responseText);
		var dom = ajaxResponse.responseXML.documentElement;
		//alert(dom);
		var htmlStr = "<table align=right cellpadding='0' cellspacing='0' border=0 width=98% height=100% class='txt'><tr><td align=center> °Ë»ö °á°ú¿¡ ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. </td></tr></table>";
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("tr");
		 
			htmlStr = makeHtmlTableString(2, nodes, TPage);
			//var htmlStrNavi = makeHtmlTableNavi(nodes, "CallAjaxQuestList", TPage);
			
		}
		document.getElementById(TBodyID).innerHTML = htmlStr;
		//if( document.getElementById(TBodyID+"_navi") )
		//	document.getElementById(TBodyID+"_navi").innerHTML = htmlStrNavi;
	}
	
	function callbackFunctionQuestionListToTest(ajaxResponse)
	{
		//alert(ajaxResponse.responseText);
		var dom = ajaxResponse.responseXML.documentElement;
		//alert(dom);
		var htmlStr = "<table align=right cellpadding='0' cellspacing='0' border=0 width=98% height=100% class='txt'><tr><td align=center> °Ë»ö °á°ú¿¡ ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. </td></tr></table>";
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("tr");
		 
			htmlStr = makeHtmlTableString(2, nodes, TPage);
			//var htmlStrNavi = makeHtmlTableNavi(nodes, "CallAjaxQuestListToTest", TPage);
			
		}
		document.getElementById(TBodyID).innerHTML = htmlStr;
		//if( document.getElementById(TBodyID+"_navi") )
		//	document.getElementById(TBodyID+"_navi").innerHTML = htmlStrNavi;
	}

	function callbackFunctionLatestQuestionList(ajaxResponse)
	{
		//alert(ajaxResponse.responseText);
		var dom = ajaxResponse.responseXML.documentElement;
		// alert(dom);
		var htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100% class='txt'><tr><td align=center> °Ë»ö °á°ú¿¡ ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. </td></tr></table>";
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("tr");
		 
			htmlStr = makeHtmlTableString(3, nodes);
			
		}
		document.getElementById("latestquestionlist").innerHTML = htmlStr;
	}

	function callbackFunctionLatestTestList(ajaxResponse)
	{
		//alert(ajaxResponse.responseText);
		var dom = ajaxResponse.responseXML.documentElement;
		//alert(dom);
		var htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100% class='txt'><tr><td align=center> °Ë»ö °á°ú¿¡ ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. </td></tr></table>";
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("tr");
		 
			htmlStr = makeHtmlTableString(4, nodes);
			
		}
		document.getElementById("latesttestlist").innerHTML = htmlStr;
	}

	function callbackFunctionLatestQuestionShortList(ajaxResponse)
	{
		//alert(ajaxResponse.responseText);
		var dom = ajaxResponse.responseXML.documentElement;
		// alert(dom);
		var htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100% class='txt'><tr><td align=center> °Ë»ö °á°ú¿¡ ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. </td></tr></table>";
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("tr");
		 
			htmlStr = makeHtmlTableString(5, nodes);
			
		}
		document.getElementById("latestquestionshortlist").innerHTML = htmlStr;
	}

	function callbackFunctionLatestNewsList(ajaxResponse)
	{
		//alert(ajaxResponse.responseText);
		var dom = ajaxResponse.responseXML.documentElement;
		// alert(dom);
		var htmlStr = "<table cellpadding='0' cellspacing='0' border=0 width=100% height=100% class='txt'><tr><td align=center> °Ë»ö °á°ú¿¡ ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. </td></tr></table>";
		if( dom )
		{		
			var nodes = dom.getElementsByTagName("tr");
		 
			htmlStr = makeHtmlTableString(6, nodes);
			
		}
		document.getElementById("latestnewslist").innerHTML = htmlStr;
	}
	
	function callbackFunctionDeleteQuestion(ajaxResponse)
	{
		if(ajaxResponse.responseText.search("error") > -1)
		{
			// ERROR_IS_USED_EXAM ERROR_NOT_AUTHORIZED ERROR_NOT_EXIST_QUESTION
			var strError = "[ERROR]";
			if(ajaxResponse.responseText.search("ERROR_IS_USED_EXAM") > -1)
				strError += "\n¼±ÅÃÇÏ½Å ÆÄÀÏÀÇ ÀÏºÎ´Â ÀÌ¹Ì ½ÃÇèÁö¿¡ »ç¿ëÀÌ µÇ°í ÀÖÀ¸¹Ç·Î »èÁ¦ÇÒ ¼ö ¾ø½À´Ï´Ù.";
			if(ajaxResponse.responseText.search("ERROR_NOT_AUTHORIZED") > -1)
				strError += "\n¼±ÅÃÇÏ½Å ÆÄÀÏÀÇ ÀÏºÎ´Â »èÁ¦¸¦ À§ÇÑ ±ÇÇÑÀÌ ¾ø½À´Ï´Ù.";
			if(ajaxResponse.responseText.search("ERROR_NOT_EXIST_QUESTION") > -1)
				strError += "\n¼±ÅÃÇÏ½Å ÆÄÀÏÀÇ ÀÏºÎ´Â Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.";

			alert(strError);
		}
		var page = document.getElementById("title");
		if( page.value == "viewquestion" )
			document.location.href="../teacher/questionlist.php";
		else if( page.value == "regquest" )
			CallAjaxQuestList("questionlist");
	}

}