//Aj Calls
var xmlhttp;

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("displayHere").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

var openD="1";
var openD2="1";
var CP;

function buttonOver(thisId,thisIm){
var oversrc = "/graphics/" + thisIm + "On.jpg";
document.getElementById(thisId).src=oversrc;	
}

function buttonOut(thisId,thisIm){
var oversrc = "/graphics/" + thisIm + "Off.jpg";
document.getElementById(thisId).src=oversrc;	
}

function openDiv(){
	if(openD=="1"){
		openD="2";
		CollapsiblePanel100.open(); 
	}
	else
	{
		openD="1";
		CollapsiblePanel100.close();
	}
}

function openDiv2(){
	if(openD2=="1"){
		openD2="2";
		CollapsiblePanel101.open(); 
	}
	else
	{
		openD2="1";		
CollapsiblePanel101.close();

	}
}

function menuClick(thisId) {
document.location.href=thisId;
}

function menuOver(thisId) {
var selected 
selected = document.getElementById(thisId);
selected.className = "menuOn";
}

function menuOut(thisId) {
var selected 
selected = document.getElementById(thisId);
selected.className = "menuOff";
}

function tryLogon(){

var thisLot;
thisLot =  "userName=" + encodeURIComponent(document.forms[0].username.value);
thisLot = thisLot + "&passWord=" + encodeURIComponent(document.forms[0].password.value);
//alert(thisLot);

var result = "&nbspRequired&nbsp";
document.getElementById('alertUser').innerHTML = "";
document.getElementById('alertPass').innerHTML = "";

if(document.forms[0].username.value==""){
document.getElementById('alertUser').innerHTML = result;
return;
}

if(document.forms[0].password.value==""){
document.getElementById('alertPass').innerHTML = result;
return;
}

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="/logIn.asp";
//document.location.href= url + "?" + thisLot;
xmlHttp.onreadystatechange = alertContentsUser;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function alertContentsUser() {
      if (xmlHttp.readyState == 4) {
         if (xmlHttp.status == 200) {
		 result = "&nbsp;Not Recognised&nbsp;"
            if(xmlHttp.responseText=="1"){
            document.getElementById('alertUser').innerHTML = result;
			}
			if(xmlHttp.responseText=="2"){
            document.getElementById('alertPass').innerHTML = result;
			} 
			if(xmlHttp.responseText=="3"){
            document.location.href="/default.asp";
			}           
         } else {
            alert('There was a problem with the request.');
         }
      }     
   }
   
   function openGallery(obj){
   document.location.href="/galleries-private.asp?gal=" + obj; 
   }
   
function sendMyMail(){ 

var thisLot;
thisLot = "inam=" + encodeURIComponent(document.forms[0].inam.value);
thisLot = thisLot + "&itel=" + encodeURIComponent(document.forms[0].itel.value);
thisLot = thisLot + "&iema=" + encodeURIComponent(document.forms[0].iema.value);
thisLot = thisLot + "&imes=" + encodeURIComponent(document.forms[0].imes.value);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
//alert(thisLot);
var url="/working/sendMail.asp";
//document.location.href=url+"?"+thisLot;
xmlHttp.onreadystatechange = mailSent;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}


function mailSent() {
      if (xmlHttp.readyState == 4) {
         if (xmlHttp.status == 200) {
            //alert(xmlHttp.responseText);
            document.location.href="/message-thanks.asp";
            //document.getElementById('baskethere').innerHTML = result;         
         } else {
            alert('There was a problem with the request.');
         }
      }     
   }