var xmlHttp

function postcodeSearch()
{
	document.getElementById("codeView").innerHTML="<center><img src='interface/waiting.gif' width='16' height='16' />&nbsp;Loading...</center>"
	var url="postcodeSearch.asp?postcode=" + escape(document.frmPostcode.Postcode.value)
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url, true)
	xmlHttp.send(null)
	return false;
}
function moveFAQ(faqID, order)
{ 
	var url="ajax/movefaq.asp?faqID=" + faqID + "&order=" + order
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
} 
function deleteFAQ(faqID)
{ 
	if (confirm("Are you sure you wish to delete this FAQ?"))
	{
		var url="ajax/deletefaq.asp?faqID=" + faqID
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
} 

function deleteLink(linkID)
{ 
	if (confirm("Are you sure you wish to delete this link?"))
	{
		var url="ajax/deletelink.asp?linkID=" + linkID
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
} 

function deleteServingInfo(servingID)
{ 
	if (confirm("Are you sure you wish to delete this serving suggestion?"))
	{
		var url="ajax/deleteserving.asp?servingID=" + servingID
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
} 

function moveInfoTitle(titleID, order)
{ 
	var url="ajax/moveinfotitle.asp?titleID=" + titleID + "&order=" + order
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
} 
function deleteInfoTitle(titleID)
{ 
	if (confirm("Are you sure you wish to delete this information title?"))
	{
		var url="ajax/deleteinfotitle.asp?titleID=" + titleID
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
} 
function deletNewsInfo(newsID)
{ 
	if (confirm("Are you sure you wish to delete this news item?"))
	{
		var url="ajax/deletenewsinfo.asp?newsID=" + newsID
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
} 
function addInformationTitle()
{ 
	if ((document.frmAddTitle.txtTitle.value.length==0) ||  (document.frmAddTitle.txtTitle.value==null)) {
		alert("You must enter an information title to continue");
		return false;
	}
	var url="ajax/addinfotitle.asp?infoTitle="+escape(document.frmAddTitle.txtTitle.value)
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	document.frmAddTitle.txtTitle.value=''
	return false;
} 
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("codeView").innerHTML=xmlHttp.responseText 
	} 
} 


function processInfoForm() {
	if ((document.frmAddInfo.txtName.value.length==0) ||  (document.frmAddInfo.txtName.value==null)) {
		alert("You must enter an information name to continue");
		return false;
	}
	if ((document.frmAddInfo.file.value.length==0) ||  (document.frmAddInfo.file.value==null)) {
		alert("You must select a PDF file to upload");
		return false;
	}
	//document.wrapper.mainBodyHolder.mainBody.progressbar.visible = true;
	document.getElementById("progressbar").style.visibility = "visible";
	document.getElementById("submitButton").disabled = true;
	
	//document.getElementById("progressbar").visible = true;
	document.frmAddInfo.action = "addinfo.asp?Submit=True&infoTitleID=" + document.frmAddInfo.selTitle.value + "&infoName=" + document.frmAddInfo.txtName.value;
	return false;
}


function processLogin() {
	if ((document.frmLogin.txtUser.value.length==0) ||  (document.frmLogin.txtUser.value==null)) {
		alert("You must enter a username to continue");
		return false;
	}
	if ((document.frmLogin.txtPassword.value.length==0) ||  (document.frmLogin.txtPassword.value==null)) {
		alert("You must enter a password to continue");
		return false;
	}
	
	document.getElementById("loginButton").disabled = true;
		var url="ajax/checklogin.asp?txtUser="+escape(document.frmLogin.txtUser.value)+"&txtPass="+escape(document.frmLogin.txtPassword.value)
		xmlHttp=GetXmlHttpObject(checkLoginDetails)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		document.frmLogin.txtUser.value=''
		document.frmLogin.txtPassword.value=''
		//alert(xmlHttp.responseText);
	return false;
}
function checkLoginDetails() 
{ 
	//alert("Checking login details");
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//alert("verifiying");
		if(xmlHttp.responseText=="true"){
			//alert("YOU ARE LOGGED IN")
			window.location = "index.asp";
		}
		else {
			document.getElementById("codeView").innerHTML="Incorrect login details!"
			document.getElementById("loginButton").disabled = false;
		}
	}
} 


function processRemoveInfo() {	
	if (document.frmDeleteInfo.chkDelete.checked==false) {
		alert("You must check the tick box to agree to remove this piece of information");
		return false;
	}
	document.getElementById("Submit").disabled = true;
	document.frmDeleteInfo.action = "removeinfo.asp?Submit=True&infoID=" + document.frmDeleteInfo.hidInfoID.value;
	return true;
}



function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesn't work in Opera") 
return; 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
} 