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)
  {
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
function openDiv(thisId) {
	if(document.getElementById(thisId).style.display==""){
SlideClosed(thisId);
	}
	else{
document.getElementById(thisId).style.display="none";
SlideOpen(thisId);
}
}


function selectColour(obj){
xmlHttp=GetXmlHttpObject();
var url="/resource/working/setColour.asp";
url=url+"?col="+obj;
document.location.href=url;
}

function setSize(obj){
xmlHttp=GetXmlHttpObject();
var url="/resource/working/setSize.asp";
url=url+"?sz="+obj;
document.location.href=url;
}

function setFont(obj){
//xmlHttp=GetXmlHttpObject();
//var url="/resource/working/setFont.asp";
//url=url+"?ft="+obj;
//document.location.href=url;
alert("The set font function has been disabled for the MCL website");
}

function refresh(){
document.location.href="/template.asp"
}

function getWidth(){
var x,y;
if (self.innerHeight) // all except Explorer
{
	x = self.innerWidth;
	y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
	x = document.body.clientWidth;
	y = document.body.clientHeight;
}
return x;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function sendContactForm(){

var thisLot;
thisLot =  "inam=" + encodeURIComponent(document.forms[0].inam.value);
thisLot = thisLot + "&iadd=" + encodeURIComponent(document.forms[0].iadd.value);
thisLot = thisLot + "&itow=" + encodeURIComponent(document.forms[0].itow.value);
thisLot = thisLot + "&icou=" + encodeURIComponent(document.forms[0].icou.value);
thisLot = thisLot + "&ipos=" + encodeURIComponent(document.forms[0].ipos.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);
//alert(thisLot);

var result = "&nbsp<b>Required</b>&nbsp";
document.getElementById('snam').innerHTML = "";
document.getElementById('stow').innerHTML = "";
document.getElementById('stel').innerHTML = "";
document.getElementById('sema').innerHTML = "";
document.getElementById('smes').innerHTML = "";

if(document.forms[0].inam.value==""){
document.getElementById('snam').innerHTML = result;
return;
}
if(document.forms[0].itow.value==""){
document.getElementById('stow').innerHTML = result;
return;
}
if(document.forms[0].itel.value==""){
document.getElementById('stel').innerHTML = result;
return;
}
if(document.forms[0].iema.value==""){
document.getElementById('sema').innerHTML = result;
return;
}
if(document.forms[0].imes.value==""){
document.getElementById('smes').innerHTML = result;
return;
}

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="/resource/working/sendMessage.asp";
xmlHttp.onreadystatechange = messageResponse;
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 messageResponse() {
      if (xmlHttp.readyState == 4) {
         if (xmlHttp.status == 200) {
            document.getElementById('thanksHere').innerHTML = xmlHttp.responseText;         
         } else {
            alert('There was a problem with the request.');
         }
      }     
   }
   
   function sendQuote(){

var thisLot;
thisLot =  "dateoftravel=" + encodeURIComponent(document.forms[0].dateoftravel.value);
thisLot = thisLot + "&departuretime=" + encodeURIComponent(document.forms[0].departuretime.value);
thisLot = thisLot + "&coachsize=" + encodeURIComponent(document.forms[0].coachsize.value);
thisLot = thisLot + "&departfrom=" + encodeURIComponent(document.forms[0].departfrom.value);
thisLot = thisLot + "&destination=" + encodeURIComponent(document.forms[0].destination.value);
thisLot = thisLot + "&additionalpickups=" + encodeURIComponent(document.forms[0].additionalpickups.value);
thisLot = thisLot + "&dateofreturn=" + encodeURIComponent(document.forms[0].dateofreturn.value);
thisLot = thisLot + "&yourname=" + encodeURIComponent(document.forms[0].yourname.value);
thisLot = thisLot + "&companyname=" + encodeURIComponent(document.forms[0].companyname.value);
thisLot = thisLot + "&address=" + encodeURIComponent(document.forms[0].address.value);
thisLot = thisLot + "&postcode=" + encodeURIComponent(document.forms[0].postcode.value);
thisLot = thisLot + "&telephone=" + encodeURIComponent(document.forms[0].telephone.value);
thisLot = thisLot + "&emailaddress=" + encodeURIComponent(document.forms[0].emailaddress.value);
thisLot = thisLot + "&furtherinformation=" + encodeURIComponent(document.forms[0].furtherinformation.value);
thisLot = thisLot + "&returntime=" + encodeURIComponent(document.forms[0].returntime.value);
//alert(thisLot);

var result = "&nbsp<b>Required</b>&nbsp";
document.getElementById('dateoftravelalert').innerHTML = "";
document.getElementById('departuretimealert').innerHTML = "";
document.getElementById('coachsizealert').innerHTML = "";
document.getElementById('destinationalert').innerHTML = "";
document.getElementById('dateofreturnalert').innerHTML = "";
document.getElementById('returntimealert').innerHTML = "";
document.getElementById('yournamealert').innerHTML = "";
document.getElementById('telephonealert').innerHTML = "";
document.getElementById('emailaddressalert').innerHTML = "";

if(document.forms[0].dateoftravel.value==""){
document.getElementById('dateoftravelalert').innerHTML = result;
return;
}
if(document.forms[0].departuretime.value==""){
document.getElementById('departuretimealert').innerHTML = result;
return;
}
if(document.forms[0].coachsize.value==""){
document.getElementById('coachsizealert').innerHTML = result;
return;
}
if(document.forms[0].destination.value==""){
document.getElementById('destinationalert').innerHTML = result;
return;
}
if(document.forms[0].dateofreturn.value==""){
document.getElementById('dateofreturnalert').innerHTML = result;
return;
}
if(document.forms[0].returntime.value==""){
document.getElementById('returntimealert').innerHTML = result;
return;
}
if(document.forms[0].yourname.value==""){
document.getElementById('yournamealert').innerHTML = result;
return;
}
if(document.forms[0].telephone.value==""){
document.getElementById('telephonealert').innerHTML = result;
return;
}
if(document.forms[0].emailaddress.value==""){
document.getElementById('emailaddressalert').innerHTML = result;
return;
}

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="/resource/working/sendQuote.asp";
xmlHttp.onreadystatechange = messageResponse;
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 goNow(){
var sX = findPosX(document.getElementById('stickHere'));
var sY = findPosY(document.getElementById('stickHere')); 
var obj = document.getElementById('shadowHere');
obj.style.position="absolute";
//obj.style.zindex=1;
sX+=282;
obj.style.left=sX + "px";
obj.style.top=sY + "px";

}

function searchLocation(obj){
document.location.href="/string-gallery-dealers.asp?idn=" + obj;
}


function openDivOnlyNews(thisId) {
	if(document.getElementById(thisId).style.display==""){
//nothing
	}
	else{
document.getElementById(thisId).style.display="none";
SlideOpen(thisId);
document.getElementById('newsScroller').style.height="130px";
}
}

function closeDivOnly(thisId) {
	if(document.getElementById(thisId).style.display==""){
SlideClosed(thisId);
	}
	else{
//nothing
}
}

function getVidLib(obj){
var thisLot="imgLib=" + encodeURIComponent(obj);
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/inc/furniture/videoArchive.asp";
xmlHttp.onreadystatechange = vidLibHere;
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 vidLibHere() {
      if (xmlHttp.readyState == 4) {
         if (xmlHttp.status == 200) {
            document.getElementById('vidLibHere').innerHTML = xmlHttp.responseText;         
         } else {
            alert('There was a problem with the request.');
         }
      }     
   }


function popVideo(obj){
if(getCookie('interact'))
{
document.getElementById('divThis2').style.display='';
document.getElementById('apDiv12').style.display='';
document.body.scroll="no";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/resource/working/popVideo.asp";
url=url+"?youTubeRef="+obj + "&$=" +new Date().getTime();
//document.location.href=url;
xmlHttp.onreadystatechange=displayAlert2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} else {
openAlert('View Videos','To view video content, you must be a registered member of this website. If you are not a registered user, please do so using [ Register ] from the menu at the top of this page.<br><br>If you are already registered and have activated your account, please log-in using [ log-in ] from the menu at the top of this page. <br><br>If you are both a registered user with an activated account and are logged in, please enable your computer to accept cookies. <br><br>Each time you log-in, we place a cookie on your computer that expires within 24 hours or if you log-out');
}
}

//-----------------------------------------------------------

function returnCal(mon)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  if(mon==13){
  returnCalAll();
  }
  else {
var url="/events-diary.asp";
url=url+"?mon="+mon;
document.location.href=url;
}
}

function returnCalAll()
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/events-diary.asp";
url=url+"?mon=13";
document.location.href=url;
}



function getYearAll()
{ 
var obj=document.forms[0].selectYear.value;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/events-diary.asp";
url=url+"?mon=13&yr=" + obj;
document.location.href=url;
}

function displayCal() 
{ 
document.getElementById("loadHere").innerHTML="<img src=/resource/graphics/loader.gif>";
if (xmlHttp.readyState==4)
{ 
document.getElementById("calHere").innerHTML=xmlHttp.responseText;
document.getElementById("loadHere").innerHTML="";
}
else {
document.getElementById("loadHere").innerHTML="<img src=/resource/graphics/loader.gif>";
}
}

function ebMeClose(id){
document.getElementById('divThis').style.display='none';
document.getElementById('apDiv1').style.display='none';
document.body.scroll="yes";
}

function ebMe(id){
//document.body.scroll="no";
//document.getElementById('divThis').style.display='';
//document.getElementById('apDiv1').style.display='';
returnEvent(id);
}

function returnEvent(id) { 
var url="/eaaa-event.asp";
url=url+"?id="+id;
document.location.href=url;
}


function addOutlook(obj) {
alert("If asked if you want to 'Save' or 'Open', please click [ Open ]\n\nThis event will automatically add to your electronic calendar");
document.location.href="/ics/" + obj + ".ics";

}

function displayNews() { 
	document.getElementById("apDiv1").innerHTML="<img src=/resource/graphics/loader.gif>";

if (xmlHttp.readyState==4){
         if (xmlHttp.status == 200) {    
            document.getElementById('apDiv1').innerHTML= xmlHttp.responseText;         
         } else {
            alert('There was a problem with the request.');
         }
}
}

function sendFriend(){
	
var thisLot="toemail=" + encodeURIComponent(document.forms[0].toemail.value);
thisLot = thisLot + "&tosubject=" + encodeURIComponent(document.forms[0].tosubject.value);
thisLot = thisLot + "&toname=" + encodeURIComponent(document.forms[0].toname.value);
thisLot = thisLot + "&fname=" + encodeURIComponent(document.forms[0].fname.value);
thisLot = thisLot + "&femail=" + encodeURIComponent(document.forms[0].femail.value);
thisLot = thisLot + "&eid=" + encodeURIComponent(document.forms[0].eid.value);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 

var url="/resource/working/sendFriend.asp";
xmlHttp.onreadystatechange = showSent;
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 showSent() {
      if (xmlHttp.readyState == 4) {
         if (xmlHttp.status == 200) {
            alert("Your email has been sent\n\nThank you for recommending the East Anglian Air Ambulance");
			document.location.href="/events-diary.asp";         
         } else {
            alert('There was a problem with the request.');
         }
      }     
   }
   
   function doSearch()
{ 
var k=document.forms[0].keyword.value;
var url="/event-search-results.asp";
url=url+"?k=" + k;;
document.location.href=url;
}


  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function makeDonationNow(){
	var thisAmount=document.forms[0].donation.value;
	document.location.href="http://ww6.aitsafe.com/cf/add.cfm?userid=81122333&product=Cash Donation&amp;price="+thisAmount+"&return=www.ijf.org.uk";
}

function CommerceSearch(){
var searchterm = document.forms[0].searchMe.value;
document.location.href="/commerce-search.asp?kw="+searchterm;
}

function CommerceSearch2(){
var searchterm = document.forms[0].searchMe.value;
document.location.href="/commerce-search.asp?kw=";
}

function siteSearch(){
	var kw=document.forms[0].searchMe.value;
	document.location.href="/search-results.asp?kw="+kw;
}

function submitenter(sfunction,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   if(sfunction=='siteSearch'){
	 siteSearch();  
   }
      if(sfunction=='productSearch'){
	 CommerceSearch();  
   }
      if(sfunction=='productSearch2'){
	 CommerceSearch2();  
   }
   return false;
   }
else
   return true;
}

function swapPics(obj){
document.getElementById('tImage').src="/imagesMCL/" + obj;
}
