﻿window.onload = init;
function init()
{
	// Set up top search box
	var searchTextInput = $(ctrlPfx + 'SearchText');
	var defaultSearchText = searchTextInput.value;
	searchTextInput.onfocus = function() {
		if (searchTextInput.value == defaultSearchText) searchTextInput.value = '';
		else searchTextInput.select();
	};
	
	// If the region script is included, call the init
	if (window.InitLoadRegions)
	{
		InitLoadRegions();
	}
	
	// If the town script is included, call the init
	if (window.InitLoadTowns)
	{
		InitLoadTowns();
	}
	
	
}


var xmlRequest;
function GetXml(url, handler)
{
	xmlRequest = null;
	
	// Branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		try
		{
			xmlRequest = new XMLHttpRequest();
		}
		catch(e)
		{
			xmlRequest = null;
		}
    // branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject)
	{
		try
		{
			xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				xmlRequest = null;
			}
		}
	}
	if (xmlRequest != null)
	{
		xmlRequest.onreadystatechange = handler;
		xmlRequest.open("GET", url, true);
		xmlRequest.send(null);
	}
}

function SetSelectedValue(ddl, value)
{
    for (var i = 0; i < ddl.options.length; i++)
        if (ddl.options[i].value == value)
        {
            ddl.selectedIndex = i;
            return;
        }
}
