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 + "&iema=" + encodeURIComponent(document.forms[0].iema.value);

//alert(thisLot);

var result = "&nbsp<b>Required</b>&nbsp";
document.getElementById('snam').innerHTML = "";
document.getElementById('sema').innerHTML = "";


if(document.forms[0].inam.value==""){
document.getElementById('snam').innerHTML = result;
return;
}
if(document.forms[0].iema.value==""){
document.getElementById('sema').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 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');
}
}