function deletephoto(photo_id) {
	var URL = '/sitebuilder/admin/deletephoto.asp?photo_id=' + photo_id;
	var textstring = 'Are you sure you wish to delete this photo?';
	if (window.confirm(textstring) == true)
	{
		window.open(URL, 'Popup', 'width=100,height=100,top')
//		window.location.href = URL;
	}	
}

function deleteboundary(boundary_id) {
	var URL = '/sitebuilder/admin/deleteboundary.asp?boundary_id=' + boundary_id;
	var textstring = 'Are you sure you wish to delete this boundary file?';
	if (window.confirm(textstring) == true)
	{
		window.open(URL, 'Popup', 'width=100,height=100,top')
//		window.location.href = URL;
	}	
}


function deletelogo(parish_id) {
	var URL = '../admin/delete_toplogo.asp?parish_id=' + parish_id;
	var textstring = 'Are you sure you wish to delete this logo?';
	if (window.confirm(textstring) == true)
	{
		window.open(URL, 'Popup', 'width=100,height=100,top')
//		window.location.href = URL;
	}	
}


function popUpWin (url, win, width, height, options) {
	var leftPos = (screen.availWidth - width) / 2;
	var topPos = (screen.availHeight - height) / 2;
	options += 'width=' + width + ',height=' + height + ',left=' + leftPos + ',top=' + topPos;
	return window.open(url, win, options);
}


function pickColour(val) {
document.frmadmin.main_colour.value = val;
}


//contact us check
function formContactUsCheck(formobj){

	var fieldRequired = Array("full_name","organisation","contact_telephone","contact_email","enquiry");
	var fieldDescription = Array("Full Name","Organisation","Contact Telephone","Contact E-mail","Enquiry");
	
	var alertMsg = "Please complete the following fields: \n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}
	if (alertMsg.length == l_Msg){
		return true;
	}
	else {
		alert(alertMsg);
		document.contactForm.btnSend.disabled=false
		return false;
	}
}


function formCheckSiteLogo(formobj){

	var fieldRequired = Array("file1");
	var fieldDescription = Array("Logo");
	
	var alertMsg = "Please complete the following fields: \n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}
	if (alertMsg.length == l_Msg){
		return true;
	}
	else {
		alert(alertMsg);
		document.frmsignposts.btnSearch.disabled=false
		return false;
	}
}

//ensures user only submits form once
function submitonce(theform){
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById){
		//screen thru every element in the form, and hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++){
		var tempobj=theform.elements[i]
		if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset"||tempobj.type.toLowerCase()=="image")
			//disable em
			tempobj.disabled=true
		}
	}
}

function formCheckSitePics(formobj){

	var fieldRequired = Array("file1");
	var fieldDescription = Array("Picture");
	
	var alertMsg = "Please complete the following fields: \n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}
	if (alertMsg.length == l_Msg){
		return true;
	}
	else {
		alert(alertMsg);
		document.frmsignposts.btnSearch.disabled=false
		return false;
	}
}


function formCheckSiteBoundary(formobj){

	var fieldRequired = Array("title","file1");
	var fieldDescription = Array("Title","Picture");
	
	var alertMsg = "Please complete the following fields: \n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}
	if (alertMsg.length == l_Msg){
		return true;
	}
	else {
		alert(alertMsg);
		document.frmsignposts.btnSearch.disabled=false
		return false;
	}
}

