
	/////////////////////////////////////////////////////////////
	// David Smith - 10 JANUARY 2006
	/////////////////////////////////////////////////////////////

	var oDIV;

	function ShowTownList(code, radius)
	{
		oDIV = document.getElementById('TownList');

		if(oDIV == null)
		{
			oDIV = document.createElement('div');

			oDIV.id = "TownList";
	
			document.body.appendChild(oDIV);
		}

		oDIV.style.left = 100;
		oDIV.style.top = 100;
		oDIV.style.width = 600;
		oDIV.style.height = 400;
		oDIV.style.border = '1';
		oDIV.style.borderColor = 'black';
		oDIV.style.borderStyle = 'solid';
		oDIV.style.position = 'absolute';
		oDIV.style.backgroundColor = 'white';
		oDIV.style.padding = '2';

		oDIV.style.left = (document.body.clientWidth - parseInt(oDIV.currentStyle.width)) / 2 + 15;

		oDIV.style.top = (document.body.offsetHeight - parseInt(oDIV.currentStyle.height)) / 2;

		try
		{
			req=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				req=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(oc)
			{
				req=null;
			}
		}

		if(!req&&typeof XMLHttpRequest!="undefined")
		{
			req=new XMLHttpRequest();
		}

		var url="http://businessdirectory.clients/TownHelper.aspx?code=" + code + "&radius=" + radius;

		if(req!=null)
		{
			req.onreadystatechange = ShowTownList_Callback;
			req.open("GET", url, true);
        		req.send(null);
		}
	}

	/////////////////////////////////////////////////////////////

	function ShowTownList_Callback()
	{

		if (req.readyState == 4)
        	{
			if (req.status == 200)
			{
				oDIV.style.visibility = 'visible';
				oDIV.innerHTML = req.responseText;
			}
			else
			{
				alert('The post code helper is unavailable ' + req.status);
			}
		}
	}
	
	function ClosePostCodeHelper(){
		oDIV.style.visibility = 'hidden';
	}

	function setPostCode(code)
	{
			alert(code);
			ClosePostCodeHelper()
			
	}

// --------------------------------------------------------------

setskin()

function setskin()
{	
	var styles = GetCookie('style');

	if(styles != null)
	{
		document.getElementById('skin').href = styles;
	}
}

// ------------------------------------------------------------------------

function GetCookie(name) {

var cookies = document.cookie;
var startIndex = 0;

while(cookies.length > 0) {

  startIndex = cookies.indexOf(name + "=");
  if (startIndex == -1)
   return null;

  if (startIndex == 0)
   break;
  if ((cookies.charAt(startIndex-1) == ' ') || (cookies.charAt(startIndex-1) == ';'))
   break;
  cookies = cookies.substring(startIndex + name.length + 1);
}
if (cookies.length == 0)
  return null;

var endIndex = cookies.indexOf(";", startIndex);
if (endIndex == -1)
  endIndex = cookies.length;
return unescape(cookies.substring(startIndex+name.length+1, endIndex));
}

function PopUpWindow(url, width, height){
				win = window.open(url,'popup','width=' + width + ',height=' + height + ',menubar=no,scrollbars=yes');
				win.Focus
}

// ------------------------------------------------------------------------

function TogglePostCodeHelper(e){
	
		var pch = document.getElementById('PostCodeHelper').style;
		
		if (pch.display == "block") {
			pch.display = "none";
		}else{
			//pch.left = e.clientX - 100;
			pch.left = 50;
			//pch.top = e.clientY + 15;
			pch.top = 10;
			
			pch.display = "block";
			GrowPostCodeHelper(0);
		}
	}
	
// ------------------------------------------------------------------------

function GrowPostCodeHelper(nChunk) {

  document.getElementById('PostCodeHelper').style.clip = "rect(auto auto " + nChunk + "% " + (100 - nChunk) + "%)";
  
  nChunk +=5
  
  if (nChunk <= 100) {
    window.setTimeout('GrowPostCodeHelper(' + nChunk + ')',10);
  }
}

// ------------------------------------------------------------------------

function openWindow(URL){
			sURL = URL;
			sName = 'Win';
			sFeatures = 'width=620,height=550,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no';
			window.open(sURL , sName, sFeatures);
}





