// JavaScript Document
var xmlHttp
function showNames(str){   
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null){
    alert ("Browser does not support HTTP Request");
    return
  }

  var url="/ajax/getnames.php";
  url=url+"?q="+str;
  url=url+"&sid="+Math.random();
  xmlHttp.onreadystatechange=stateChanged ;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}


function stateChanged(){ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    document.getElementById("seltypes").innerHTML=xmlHttp.responseText; 
  }
}
///////////////////////////////////////////////////////////////////////////
function showSizes(str){ 
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null){
    alert ("Browser does not support HTTP Request")
    return
  }
  
  var url="/ajax/getsizes.php"
  url=url+"?q="+str
//  url=url+"&sid="+Math.random()
  xmlHttp.onreadystatechange=stateChangedSize 
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
}


function stateChangedSize(){ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    document.getElementById("selsizes").innerHTML=xmlHttp.responseText 
  }
}


function GetXmlHttpObject(){
  var xmlHttp=null;
  try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }catch (e){
    //Internet Explorer
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }catch (e){
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}






var selectedId=0;
var regions=new Array(
	"",
	"Co. Carlow",
	"Co. Cavan",
	"Co. Clare",
	"Co. Cork",
	"Co. Donegal",
	"Co. Dublin",
	"Co. Galway",
	"Co. Kerry",
	"Co. Kildare",
	"Co. Kilkenny",
	"Co. Laois",
	"Co. Leitrim",
	"Co. Limerick",
	"Co. Longford",
	"Co. Louth",
	"Co. Mayo",
	"Co. Meath",
	"Co. Monaghan",
	"Co. Offaly",
	"Co. Roscommon",
	"Co. Sligo",
	"Co. Tipperary",
	"Co. Waterfard",
	"Co. Westmeath",
	"Co. Wexford",
	"Co. Wicklow",
	"Co. Antrim",
	"Co. Armagh",
	"Co. Down",
	"Co. Fermanagh",
	"Co. Londonderry",
	"Co. Tyrone"
);

function over(obj) {
	document.getElementById('region').style.backgroundPosition='0 '+(parseInt(obj.id)*(-290))+'px';
	document.getElementById('map').getElementsByTagName('span')[0].innerHTML=regions[parseInt(obj.id)];
}
function out() {
	document.getElementById('region').style.backgroundPosition='0 '+(selectedId*(-290))+'px';
	document.getElementById('map').getElementsByTagName('span')[0].innerHTML=regions[selectedId];
}
function imgSelect(obj) {
	selectedId=parseInt(obj.id);
	document.getElementById('region').getElementsByTagName('img')[0].style.backgroundPosition='0 '+(selectedId*(-290))+'px';
	document.getElementById('mapSelect').selectedIndex=parseInt(obj.id);
}
function select(obj) {
	selectedId=parseInt(obj.selectedIndex);
	document.getElementById('region').getElementsByTagName('img')[0].style.backgroundPosition='0 '+(selectedId*(-290))+'px';
	document.getElementById('region').style.backgroundPosition='0 0';
	document.getElementById('map').getElementsByTagName('span')[0].innerHTML=regions[selectedId];
}
