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 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 showList(obj){
//document.getElementById('divThis').style.display='';
//document.getElementById('apDiv1').style.display='';
//document.body.scroll="no";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/resource/working/popBox.asp";
url=url+"?id="+obj+"&$=" +new Date().getTime();;
xmlHttp.onreadystatechange=displayPop;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function displayPop() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("displayDescHere").innerHTML=xmlHttp.responseText;
//resetAll();
}
else {
document.getElementById("displayDescHere").innerHTML="<br/><br/><br/><br/><center><img src=/resource/graphics/loader.gif></center>";
}
}

function closePop(){
document.getElementById('divThis').style.display='none';
document.getElementById('apDiv1').style.display='none';
document.body.scroll="yes";
}


function getFocus(obj,obj2){
x=obj;
y=obj2;
document.getElementById(x).value=y;
}

function loseFocus(obj,obj2){
x=obj;
y=obj2;
document.getElementById(x).value=y;
}