  var menuState = "closed";

  function Gmapload() {
      if (GBrowserIsCompatible()) {

        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(54.5, -4), 5);
        map.removeMapType(G_HYBRID_MAP);
        map.removeMapType(G_SATELLITE_MAP);
        map.removeMapType(G_NORMAL_MAP);

        var mapControl = new GMapTypeControl();
        map.addControl(mapControl);
        map.addControl(new GSmallZoomControl());

        var sites=new Array();
        sites[0]=Array("53.469955","-2.306042","West Yard<br>Trafford Wharf Road<br>Manchester<br>M17 1DJ<br><strong>T: 01618 482 900</strong><br/><strong>F: 0161 848 2901</strong>");
        sites[1]=Array("53.620785","-2.625659","Wigan Lane<br>Duxbury<br>Chorley<br>Lancashire<br>PR7 4BU<br><strong>T: 01257 246 812</strong><br/><strong>F: 01257 272 884</strong>");
        sites[2]=Array("51.877752","0.929262","Haven Road<br>The Hythe<br>Colchester<br>Essex<br>CO2 8HU<br><strong>T: 01206 866 822</strong><br/><strong>F: 01206 878 000</strong>");
        sites[3]=Array("56.017360","-3.730697","Earls Road<br>Grangemouth<br>FK3 8UU<br><strong>T: 01324 666 000</strong><br/><strong>F: 01324 666 111</strong>");
        sites[4]=Array("51.566695","-2.994172","West Way Road<br>Alexandria Dock<br>Newport<br>Gwent<br>NP20 2WD<br><strong>T: 01633 244 496</strong><br/><strong>F: 01633 840 382</strong>");
        sites[5]=Array("51.769296","-2.563393","Parkend<br>Lydney<br>Gloucestershire<br>GL15 4JF<br><strong>T: 01594 566 000</strong><br/><strong>F: 01594 566 001</strong>");
		sites[6]=Array("53.744252","-0.259027","Timber Terminal King George Dock<br>Hull<br>HU9 5QE<br><strong>T: 01482 713 400</strong>");
        /*sites[7]=Array("52.938079","-1.164786","Longwall Avenue<br>Queens Drive Industrial estate<br>Nottingham<br>NG2 1LP<br><strong>T: 0115 986 5252</strong><br><strong>F: 0115 986 2198</strong>");*/
        /*sites[8]=Array("52.385272","-2.251346","Park Lane Sawmills<br>Kidderminster<br>DY11 6TG<br><strong>T: 01562 513800</strong>");*/

        var point0 = new GLatLng(sites[0][0],sites[0][1]);
        var marker0 = new GMarker(point0);
        map.addOverlay(marker0);
        GEvent.addListener(marker0, "click", function(){
           this.openInfoWindowHtml(sites[0][2])
         } );

        var point1 = new GLatLng(sites[1][0],sites[1][1]);
        var marker1 = new GMarker(point1);
        map.addOverlay(marker1);
        GEvent.addListener(marker1, "click", function(){
           this.openInfoWindowHtml(sites[1][2])
         } );

        var point2 = new GLatLng(sites[2][0],sites[2][1]);
        var marker2 = new GMarker(point2);
        map.addOverlay(marker2);
        GEvent.addListener(marker2, "click", function(){
           this.openInfoWindowHtml(sites[2][2])
         } );

        var point3 = new GLatLng(sites[3][0],sites[3][1]);
        var marker3 = new GMarker(point3);
        map.addOverlay(marker3);
        GEvent.addListener(marker3, "click", function(){
           this.openInfoWindowHtml(sites[3][2])
         } );

        var point4 = new GLatLng(sites[4][0],sites[4][1]);
        var marker4 = new GMarker(point4);
        map.addOverlay(marker4);
        GEvent.addListener(marker4, "click", function(){
           this.openInfoWindowHtml(sites[4][2])
         } );

        var point5 = new GLatLng(sites[5][0],sites[5][1]);
        var marker5 = new GMarker(point5);
        map.addOverlay(marker5);
        GEvent.addListener(marker5, "click", function(){
           this.openInfoWindowHtml(sites[5][2])
         } );

        var point6 = new GLatLng(sites[6][0],sites[6][1]);
        var marker6 = new GMarker(point6);
        map.addOverlay(marker6);
        GEvent.addListener(marker6, "click", function(){
           this.openInfoWindowHtml(sites[6][2])
         } );

        var point7 = new GLatLng(sites[7][0],sites[7][1]);
        var marker7 = new GMarker(point7);
        map.addOverlay(marker7);
        GEvent.addListener(marker7, "click", function(){
           this.openInfoWindowHtml(sites[7][2])
         } );
        
      }
    }

/**
* open the industry sectors list on the homepage
*/
function menuSlide() {
  var el=document.getElementById("industry_sectors");
  var ltext='';
 
  if (menuState=="closed") {
    el.style.height="125px";
    el.style.display="block";
    /*ltext="close information";*/
    func='openMenu()';
  } else {
    
    func='closeMenu()';
  }
  
  /*document.getElementById('moreinfolink').innerHTML=ltext;*/
  
  setTimeout(func,15);
  
  return false; 
}

/**
* open the more info box
*/
function openMenu() {
  var el=document.getElementById("industry_sectors");
  var el_l=document.getElementById("view_all");
  var cHeight=parseInt(el.style.height.replace("px",""));
  
  var nHeight=125;
  
  /*el_c.style.display="none";*/
    
  if(cHeight<(212-10)) nHeight=cHeight+10;
  else nHeight=212;
  
  if(cHeight<212) {
    el.style.height=nHeight+"px";  
    setTimeout('openMenu()',15);
  } else {
    el_l.innerHTML="close -";
    menuState = "open";
  }
  
}

/**
* close the more info box
*/
function closeMenu() {
  
  var el=document.getElementById("industry_sectors");
  var el_l=document.getElementById("view_all");
  /*var el_c=document.getElementById('more_info_content');*/
  var cHeight=parseInt(el.style.height.replace("px",""));
  var nHeight=125;
  
  /*el_c.style.display="none";*/
      
  if(cHeight>135) nHeight=cHeight-10;
  else nHeight=125;
  
  if(cHeight>125) {
    el.style.height=nHeight+"px";  
    setTimeout('closeMenu()',15);
    
  } else {
    el_l.innerHTML="view all +";
    menuState = "closed";
  }
  
}


/*
* ajax call to retrieve and possible execute code on response from server
*
*/
function doTask(params) {
  if (document.implementation && window.document.implementation.createDocument)
  {
    xmlDoc = document.implementation.createDocument("", "", null);
    xmlDoc.onload = doResponse;
  }
  else if (window.ActiveXObject)
  {
    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.onreadystatechange = function () {
      if (xmlDoc.readyState == 4) doResponse()
    };
  }
  else
  {
    return false;
  }
  d = new Date; // Generic - use to create unique url requests
  var rand = d.getTime();
  var url=document.location.protocol+'//'+document.location.host+'/alt/doTask.xml?rand='+rand+'&'+params;
  try{
    xmlDoc.load(url); // this is what we like to do
  } catch(e) { // if failed try using httprequest as a fallback - (e.g. Safari)
    try {
      req = new XMLHttpRequest();
    } catch(e) {
      req = false;
    }
    if(req) {
      req.onreadystatechange = processHttpRequest;
      req.open("GET", url, true);
      req.send("");
    }

  }

  return false;
}

/*
* some browsers require this extra step to catch the http reponse
*
*/
function processHttpRequest() {
  if (req.readyState == 4) {
        if (req.status == 200) {
      xmlDoc=req.responseXML;
      doResponse();
        }
    }
}

/*
* process the response from server to the doTask function,
*
*/
function doResponse() {
  var tasks = xmlDoc.getElementsByTagName('task');
  var cmd=null;

  for(var i=0;i<tasks.length;i++) {
    cmd=tasks[i].getElementsByTagName('cmd')[0];

    if (cmd.childNodes[0]) {
      switch(cmd.childNodes[0].nodeValue) {
        case 'replace': // replace the innerHTML of an element
          var id=tasks[i].getElementsByTagName('id')[0].childNodes[0].nodeValue;
          if (tasks[i].getElementsByTagName('content')[0].textContent) var content=tasks[i].getElementsByTagName('content')[0].textContent; //avoid FF 4096 char limit
          else var content=tasks[i].getElementsByTagName('content')[0].childNodes[0].nodeValue;
          if (id.length>0 && document.getElementById(id)) document.getElementById(id).innerHTML=content;
          break;
        case 'execute': // run some js
          var script=tasks[i].getElementsByTagName('script')[0].childNodes[0].nodeValue;
          eval(script);
          break;

      }
    }
  }
}

/*
* use JS to hide controls which are only required when JS is not enabled
* - do this by adding hideJS as a class to the css
*/
function hideElements() {
  if (document.styleSheets) {
    if (document.styleSheets[0].addRule) {    // IE
      document.styleSheets[0].addRule('.hideJS','display: none',0);
    } else {    // !IE
      document.styleSheets[0].insertRule('.hideJS {display: none}', 0);
    }
  }

}

/*
* Add the onload function to any other onload function
*/
function addLoadEvent(func) {
  var oldonload = window.onload;

  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(hideElements);

// show the form wait box
function showWait(id) {
  if (document.getElementById(id)) {
    var el=document.getElementById(id);

    el.style.position='absolute';
    el.style.left='50%';
    el.style.top='50%';
    el.style.display='block';
    el.style.marginLeft="-" + parseInt(el.offsetWidth  / 2)+'px';
    el.style.marginTop ="-" + parseInt(el.offsetHeight / 2)+'px';
    // IE has a quirk which means we need to reload the animated gif to make it animate
    if (document.getElementById(id+'wImg')) setTimeout("document.getElementById('"+id+"wImg').src=document.getElementById('"+id+"wImg').src",20);
  }
}
