function showFaqDiv(){
	$("question").value = "";
	$("answer").value = "";
	var faqdiv = $("faqdiv");
	faqdiv.style.display = 'block'

	faqdiv.style.left = "200px";

}

function showFileDiv(){

	var filediv = $("filediv")

	filediv.style.display = 'block'
	filediv.style.left = "160px";
}


function deleteFile(fileid, categoryId){

	var url = '../dao/clientsupport_dao.asp';
	var pars = 'ajxaction=deletefile&fileid='+fileid+"&categoryid="+categoryId;
	var target = 'file' + categoryId;
	var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars});

}


function editFaq(faqid){
	
	_faqid = faqid;
	document.getElementById('faqdiv').style.display = 'block'
	new Ajax.Request('../dao/clientsupport_dao.asp', 
		{parameters:'ajxaction=getQuestion&faqid='+faqid,
		 onSuccess:handlerQuestion, onFailure:errFunc});


	

	new Ajax.Request('../dao/clientsupport_dao.asp', 
		{parameters:'ajxaction=getAnswer&faqid='+faqid,
		 onSuccess:handlerAnswer, onFailure:errFunc});


}

var _faqid = null;
var sleep;

function cancle(){
	document.getElementById('faqdiv').style.display = 'none'
	document.getElementById('filediv').style.display = 'none'
	$("question").value = "";
	$("answer").value = "";
	_faqid = null;
	//sleep.currentlyExecuting = true;
}

function saveFaq(){
	new Ajax.Request('../dao/clientsupport_dao.asp', 
		{parameters:'ajxaction=updatefaq&faqid='+_faqid+"&question=" + encodeMyHtml($("question").value)+"&answer="+encodeMyHtml($("answer").value),
		 onSuccess:sleeper, onFailure:errFunc});



	cancle();
	
//	document.getElementById('faqdiv').style.display = 'none'
}



function deleteFaq1(faqid){

	new Ajax.Request('../dao/clientsupport_dao.asp', 
		{parameters:'ajxaction=deletefaq&faqid='+faqid,
		 onSuccess:sleeper, onFailure:errFunc});
}


function displayFaqs(){

	var url = '../dao/clientsupport_dao.asp';
	var pars = 'ajxaction=getFaqs';
	var target = 'faqsdiv';
	var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars});

	//sleep.currentlyExecuting = true;
}

var sleeper = function(t) {

	//alert(t.responseText);

	sleep = new PeriodicalExecuter (displayFaqs,3);


}


  function encodeMyHtml(text) {
	 text.replace(/\'/g,"%92")
	 encodedHtml = escape(text);
     //encodedHtml = encodedHtml.replace(/\'/g,"%92");
     encodedHtml = encodedHtml.replace(/\//g,"%2F");
     encodedHtml = encodedHtml.replace(/\?/g,"%3F");
     encodedHtml = encodedHtml.replace(/=/g,"%3D");
     encodedHtml = encodedHtml.replace(/&/g,"%26");
     encodedHtml = encodedHtml.replace(/@/g,"%40");

	 return encodedHtml;
     
   } 

var handlerQuestion = function(t) {
	response = t.responseText;
	$("question").value = response;

}

var handlerAnswer = function(t) {
	response = t.responseText;
	$("answer").value = response;
}


var errFunc = function(t) {
    //alert('Error ' + t.status + ' -- ' + t.statusText);
}


var nullop = function(t) {
	//alert(t.responseText);
}

