function newWindow(URL, target, size)
{
	var xSize;
	var ySize;
	var props;
	
	if (size == "0.75" )
	{
		xSize = 700;
		ySize = 600;	
		props = "width="+xSize + ",height="+ySize + ",toolbar,location,directories,resizable,status,menubar,scrollbars";
	}
	else
	{
		xSize = screen.width * size;
		ySize = screen.height * size;
		props = "width="+xSize + ",height="+ySize + ",toolbar,location,directories,resizable,status,menubar,scrollbars";
	}	
	newwindow=window.open(URL, target, props);
	if (window.focus) {newwindow.focus()}
}

function showPopup(URL,title)
{
	newwindow=window.open(URL,title,"toolbar=no,location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=yes,width=660,height=520");
	if (window.focus) {newwindow.focus()}
}

function hideRelatedNoteTitle(noteID) {
	var relatedNotePopupDiv = document.getElementById('relatednote');
	relatedNotePopupDiv.style.display = "none";
}

function popupRelatedNoteTitle(noteID) {
	var relatedNoteImage = document.getElementById('note' + noteID);
	var relatedNoteImageFromTopStyle = relatedNoteImage.style.top; // includes the 'px' suffix
	var relatedNoteImageFromTop = parseInt(relatedNoteImageFromTopStyle);
	var relatedNotePopupDiv = document.getElementById('relatednote');
	var featureNoteTitle = featureNoteTitles[noteID];
	var textNode = relatedNotePopupDiv.firstChild;
	textNode.data = featureNoteTitle;
	var fromTopCoord = relatedNoteImageFromTop;
	// the name should be 10 pixels below the dot, or 25 pixels (15 + 10) below the top of the dot
	//var adjustedTopCoord = fromTopCoord + 15 + 10;
	var adjustedTopCoord = fromTopCoord + 10;
	relatedNotePopupDiv.style.top = adjustedTopCoord + "px";
	relatedNotePopupDiv.style.display = "";
}





var protocol = window.location.protocol;
var ajax = new sack();
var ajax2 = new sack();
var ajax3 = new sack();
var county;
var baron;
var onion;
//var la='<?php echo $la ?>';

function clearCounty()
	{
		//alert('clearcounty');
		if (window.searchform) 
			{
				//alert('searchform exists');
				document.searchform.reset();
			}	
	}

function getAllList(sel)
	{
		var countryCode = sel.options[sel.selectedIndex].value;
		county = countryCode;
		//alert('allist'+county);	
		//alert(window.location.protocol)
		getBaronyList(county);
		getUnionList(county);
		getParishList(county);
	}

function getBaronyList(county)
{
	document.getElementById('baronyname').options.length = 0;	// Empty barony select box
	//alert('domain='+domain+'  path='+path);
	//alert(county);	
	ajax.requestFile = protocol + '//' + domain + '/' + path + '/php/getPlacesFlat.php?level=county&countryCode='+county;	// Specifying which file to get
	ajax.onCompletion = createBaronies;	// Specify function that will be executed after file has been found
	ajax.runAJAX();		// Execute AJAX function	
}


function getUnionList(county)
{
	//var baronyName = sel.options[sel.selectedIndex].value;
	//baron = baronyName;
	//alert("in getUnionList countryCode is "+county);
	//alert("in getUnionList barony is "+baronyName);
	
	document.getElementById('unionname').options.length = 0;	// Empty union select box
	
		ajax3.requestFile = protocol + '//' + domain + '/' + path + '/php/getPlacesFlat.php?level=barony&countryCode='+county;	// Specifying which file to get
		ajax3.onCompletion = createUnion;	// Specify function that will be executed after file has been found
		ajax3.runAJAX();		// Execute AJAX function	
	
}


function getParishList(county)
{
	//var baronyName = sel.options[sel.selectedIndex].value;
	//baron = baronyName;
	//alert("in getParishList countryCode is "+county);
	//alert("in getUnionList barony is "+baronyName);
	
	document.getElementById('parishname').options.length = 0;	// Empty union select box
	
		ajax2.requestFile = protocol + '//' + domain + '/' + path + '/php/getPlacesFlat.php?level=union&countryCode='+county;	// Specifying which file to get		
//alert(ajax2.requestFile);		
		ajax2.onCompletion = createParish;	// Specify function that will be executed after file has been found
		ajax2.runAJAX();		// Execute AJAX function	
	
}


function createBaronies() 
{
	var obj = document.getElementById('baronyname');
        //var response = ajax.response.substring(ajax.response.lastIndexOf("</metadata>") + 11);
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function createUnion()
{
	var obj = document.getElementById('unionname');
        //var response = ajax3.response.substring(ajax3.response.lastIndexOf("</metadata>") + 11);
	eval(ajax3.response);	// Executing the response from Ajax as Javascript code	
}

function createParish()
{
	//alert("in createParish";);
	
	var obj = document.getElementById('parishname');
        //var response = ajax2.response.substring(ajax2.response.lastIndexOf("</metadata>") + 11);
	eval(ajax2.response);	// Executing the response from Ajax as Javascript code	
}



function clearField (f, v)
{
   if (f.value == v) f.value = "";
}
	
