/* Copyright (c) 2009 Smileweb co., Ltd.  All rights reserved.  www.smileweb.co.kr */

var tbtype = "faq";
var pastage = "1" ;
var Url = location.href;
var listType;

if ( Url.indexOf("main") >= 0 )
{
	listType = "main";
}

if ( window.addEventListener ){	
	window.addEventListener( "load", Search, false )	
} else{	
	window.attachEvent( "onload", Search )	
}

function SetPageType(type, stage)
{
	tbtype = type;
	pastage = stage;
	
	if ( type == "faq" && listType=="main" )
	{
		for (var i=1;i<=5;i++)
		{	
			( i==stage )? eval($("faq"+i)).className = "menu_on" : eval($("faq"+i)).className = "menu_off";
		}
	}
	
	$("searchText").value = "";
	Search();
}

function Search()
{		
	new ajax.xhr.Request("/callcenter/callcenter_transaction/callcenter_transaction.php", "tbl=swc_"+tbtype+"&searchStage="+pastage+"&listType="+listType+"&searchText="+encodeURIComponent($("searchText").value), SetList, 'POST');
}

function SetList(xmlDoc)
{	
	var code = getNodeValue( xmlDoc.getElementsByTagName( 'code' ) );

	if (code == 'success') 
	{
		ChildNodesDel("faq_list");		
		
		loaddata = eval( "(" + getNodeValue( xmlDoc.getElementsByTagName ( 'data' ) ) + ")" );				
		
		for(var i = 0; i <= loaddata.length-1; i++)
		{	
			if ( listType == "main" )
			{
				var ulObj = document.getElementById("faq_list");	
				ulObj.innerHTML += "<li><a href='/callcenter/faq_read.php?num="+loaddata[i].num+"'>" + loaddata[i].title + "</a></li>"	 						
			}
		}			
	}
}