
//-----------------------------------------------------------------------------------------------
var xmlHttp
//fill id with contents of url-------------------------------------------------------------------
function showHint(id, url)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
 	} 

	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById(id).innerHTML=xmlHttp.responseText;
			//alert('response(xmlHttp.responseText, \'' + id + '\')');
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 
//--------------------------------------------------------------------------------------------
function response(text, responseid) 
{ 
	document.getElementById(responseid).innerHTML=text;
}

/*function stateChanged() 
{ 
	alert(id);
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById('txthint').innerHTML=xmlHttp.responseText;
	}
}*/
//Ajax basic-----------------------------------------------------------------------------------
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  	{
	  	// Firefox, Opera 8.0+, Safari
	  	xmlHttp=new XMLHttpRequest();
	  	}
	catch (e)
	  	{
	  	// Internet Explorer
	  	try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  	catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
//send data held in (formname) using GET to (theurl), retrieve (theurl) in (id)
//----------------------------------------------------------------------------------------------

function senddata(formname, theurl, id)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url=theurl;
url=url+buildurl(formname)
xmlHttp.onreadystatechange=function(){
     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
            document.getElementById(id).innerHTML=xmlHttp.responseText;
        }
     };
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
//build url from input in (form)------------------------------------------------------------------
function buildurl(formname)
{ 
var inputfields=new Array() //which type of input should the function include
inputfields[0]="input"
inputfields[1]="select"
inputfields[2]="textarea"
var inputurl='?';//start string with ?
for (l=0;l<4;l++)//loop through types of input
	{
	y=inputfields[l]
	var x=document.getElementById(formname).getElementsByTagName(y);
		for (i=0;i<x.length;i++)//loop through input of this type found in form
		  {
		  inputurl =inputurl + (x[i].name); //append name to string
		  inputurl =inputurl + '=' + (x[i].value) + '&'; //append value to string
		  }
	}
inputurl=inputurl+"sid="+Math.random(); // add random number to avoid caching
//inputurl=escape(inputurl); //encode url
return inputurl
}

//send which radiobutton is selected in (formname) using GET to (theurl), retrieve (theurl) in (id)
//----------------------------------------------------------------------------------------------

function senddataradio(formname, theurl, id)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url=theurl;
url=url+buildradiourl(formname)
xmlHttp.onreadystatechange=function(){
     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
            document.getElementById(id).innerHTML=xmlHttp.responseText;
        }
     };
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
//build url from input from radio buttons in (form)------------------------------------------------------------------
function buildradiourl(formname)
{ 
var inputurl='?';//start string with ?
var x=document.getElementById(formname).getElementsByTagName("input");
	for (i=0;i<x.length;i++)//loop through input of this type found in form
	{
	if (x[i].checked) {
		inputurl =inputurl + (x[i].name); //append name to string
		inputurl =inputurl + '=' + (x[i].value) + '&'; //append value to string
		}
	}
inputurl=inputurl+"sid="+Math.random(); // add random number to avoid caching
//inputurl=escape(inputurl); //encode url
return inputurl
}
//Show Tabs--------------------------------------------------------------------------------------------
function showtabs(id, url, targetobj) 
{
showHint(id, url)
var ullist=targetobj.parentNode.parentNode.getElementsByTagName("li")
for (var i=0; i<ullist.length; i++)
	ullist[i].className=""  //deselect all tabs
	targetobj.parentNode.className="selected"  //highlight currently clicked on tab
return
}
//Show help--------------------------------------------------------------------------------------------
function showhelp(id, url, target) 
{
showHint(id, url)
alert(target)
document.getElementById(target).style.backgroundColor = "#000000";  //highlight currently clicked on tab


}

