/* functions.js */

function confirmPurchase() {
	var answer = confirm("Please confirm you wish to make these purchases,\nand that you understand the Terms and Conditions as specified.")
	if (answer){
		window.location = "viewPurchases.cfm";
	} else {
		return false;
	}
}

function openWindow(url,w,h,tb,stb,l,mb,sb,rs,x,y){
	if(!x){x = ((window.screen.availWidth/2)-(w/2));}
	if(!y){y = ((window.screen.availHeight/2)-(h/2));}
	var t=(document.layers)? ',screenX='+x+',screenY='+y: ',left='+x+',top='+y; //A LITTLE CROSS-BROWSER CODE FOR WINDOW POSITIONING
	tb=(tb)?'yes':'no'; stb=(stb)?'yes':'no'; l=(l)?'yes':'no'; mb=(mb)?'yes':'no'; sb=(sb)?'yes':'no'; rs=(rs)?'yes':'no';
	var x=window.open(url, 'newWin'+new Date().getTime(), 'scrollbars='+sb+',width='+w+',height='+h+',toolbar='+tb+',status='+stb+',menubar='+mb+',links='+l+',resizable='+rs+t);
	x.focus();
}

function showMap(thisProperty)
{
	szOpen = "popupMap.cfm?id="+thisProperty;
	winMap = window.open(szOpen, 'MapWindow', 'directories=0,copyhistory=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0,width=640,height=480');
	winMap.focus();
}

function updateHistoricCounties()
{

var szCoreCountyIDs = "";
var frmCountyIDs = document.updateCounties;

for (var i = 0; i < frmCountyIDs.elements.length; i++)
	{
	var strName=frmCountyIDs.elements[i].name;
	if (frmCountyIDs.elements[i].checked)
		{
		if (szCoreCountyIDs == "")
			szCoreCountyIDs = frmCountyIDs.elements[i].id;
		else
			szCoreCountyIDs = szCoreCountyIDs + "," + frmCountyIDs.elements[i].id;
		}
	}

for (i=0 ; i<document.updateCounties.Mode.length ; i++)
	{
	if(document.updateCounties.Mode[i].checked)
		{
		var Mode=document.updateCounties.Mode[i].value;
		}
	}

if (szCoreCountyIDs.length == 0)
	{
	alert("You must select at least one county.\n\nIf you wish to cancel your subscription please contact us via telephone or email.")
	return
	}
if (Mode > 1)
	{
	var conf = confirm("These priveleges are enabled instantly\nand as such cannot be undone this month.\n\nDo you want to continue?")
		if (!conf)
			return;
	}
document.frmCounties.Mode.value=Mode;
document.frmCounties.CountyIDs.value=szCoreCountyIDs;
document.frmCounties.submit();
}

function deleteUser(userID, userName)
{
var conf = confirm("Delete user "+userName+"\n\nAre you sure?")
	if (conf)
		self.location = "users.cfm?action=delete&UserID="+userID+"&delete=1&AccountName="+userName+"";
}

function updateUsers()
{
var szUsername = document.updateUsers.Username;
var szPassword = document.updateUsers.Password;
if ("" == szUsername.value)
	{ 
	alert("Please enter a valid username");
	return;
	}
else if ("" == szPassword.value)
	{
	alert("Please enter a valid Password");
	return;
	}
document.updateUsers.submit();
}

