// JavaScript Document
function getAjax()
	{
	
	var xmlhttp;
	
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 
	  return  xmlhttp;
	
}//end of getAjax
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
//Testing ajax functins responce
function parseScript(strcode)
	{
		  var scripts = new Array();         // Array which will store the script's code
		  
		  // Strip out tags
		  while(strcode.indexOf("<script") > -1 || strcode.indexOf("</script") > -1) {
			var s = strcode.indexOf("<script");
			var s_e = strcode.indexOf(">", s);
			var e = strcode.indexOf("</script", s);
			var e_e = strcode.indexOf(">", e);
			
			// Add to scripts array
			scripts.push(strcode.substring(s_e+1, e));
			// Strip from strcode
			strcode = strcode.substring(0, s) + strcode.substring(e_e+1);
		  }
		  
		  // Loop through every script collected and eval it
		  for(var i=0; i<scripts.length; i++) {
			try {
			  eval(scripts[i]);
			}
			catch(ex) {
			  // do what you want here when a script fails
			}
		  }
	}//End of parsescripts
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
function addanswer(name,email,answer,isfb)
{
		var xmlhttp;
		xmlhttp =getAjax();
		
		var isfb_string = "";
		
		if(isfb=='1')
		isfb_string = "../";
		
		
	
		xmlhttp.onreadystatechange=function()
		{
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			  {
					 var resp = xmlhttp.responseText;
					//document.getElementById("data_list_div").innerHTML=resp;
					$("#load_message").hide().html(resp).fadeIn("slow");
					$(".ajax_load").fadeOut("slow");
				 	parseScript(resp);				
			  }
			  else
			  {
				  $(".ajax_load").show().fadeIn("slow");
			  }
			
		}//End of onreadystate change
		
		xmlhttp.open("GET",isfb_string+"ajax/add_answer.php?name="+name+"&email="+email+"&answer="+answer,true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");// Test ajax functions responce
		xmlhttp.send();
	}// End of loadMainTable
//=========================================================================================

