// New Js function for all North Wales
function submapnorthwales(mapname){

	var testvar = true;
	//var chk = new Array();
	//chk = frm.types;
	
	//for(a=0;a<chk.length;a++);
	/*if(theform=="")
	{
		theform = 'frm';
	}*/
		if(testvar == false){
		alert("Please select a type");
	}else if(mapname=='All of North Wales'){  
	 document.frm.region.value = 'all';
	 document.frm.submit();
	}
	else
	{	
		document.frm.region.value = mapname
		document.frm.submit();
	}
}



//mapsarray = preloadmaps();

function submap(mapname,theform){
	//alert(mapname);
	var testvar = true;
	//var chk = new Array();
	//chk = frm.types;
	
	//for(a=0;a<chk.length;a++);
	
	if(testvar == false){
		alert("Please select a type");
	}else{	
		document.frm.region.value = mapname
		document.frm.submit();
	}
}

function submapanglesey(mapname,theform){

	var testvar = true;
	//var chk = new Array();
	//chk = frm.types;
	
	//for(a=0;a<chk.length;a++);
	if(theform=="")
	{
		theform = 'frm';
	}
	
	if(testvar == false){
		alert("Please select a type");
	}else if(mapname=='All of Anglesey'){  
	 document.theform.region.value = 'all';
	 document.theform.submit();
	}
	else
	{	
		document.theform.models.value = mapname
		document.theform.submit();
	}
}

function smmap(mapname){
	var testvar = true;
	//var chk = new Array();
	//chk = frm.types;
	
	//for(a=0;a<chk.length;a++);
	
	if(testvar == false){
		alert("Please select a type");
	}else{	
		document.theform.region.value = mapname
		document.theform.submit();
	}
}

function preloadmaps(){
   	mapsarray = new Array();
	
	mapsarray["anmap"] = new Image();
	mapsarray["anmap"].src = "/images/html/anmap.gif";
	
	mapsarray["bomap"] = new Image();
	mapsarray["bomap"].src = "/images/html/bomap.gif";
	
	mapsarray["crmap"] = new Image();
	mapsarray["crmap"].src = "/images/html/crmap.gif";
	
	mapsarray["smcmap"] = new Image();
	mapsarray["smcmap"].src = "/images/html/smcmap.gif";

	mapsarray["main"] = new Image();
	mapsarray["main"].src = "/images/html/map1.gif";
	
	return mapsarray;
}

function shortlistadd(id)
{
	var nWidth	= 300;
	var nHeight	= 20;
	var nX		= (window.screen.width/2)-(nWidth/2);
	var nY		= (window.screen.height/2)-(nHeight/2);
	var sFormat	= "width="+nWidth+",height="+nHeight+",left="+nX+",top="+nY+",resizable=yes,scrollbars=yes";

	window.open("/shortlist/add.php?id=" + id, "Style", sFormat);
}

function shortlistremove(id)
{
	var nWidth	= 300;
	var nHeight	= 20;
	var nX		= (window.screen.width/2)-(nWidth/2);
	var nY		= (window.screen.height/2)-(nHeight/2);
	var sFormat	= "width="+nWidth+",height="+nHeight+",left="+nX+",top="+nY+",resizable=yes,scrollbars=yes";

	window.open("/shortlist/remove.php?id=" + id, "Style", sFormat);
}

function printpage(url)
{
	var nWidth	= 700;
	var nHeight	= 500;
	var nX		= (window.screen.width/2)-(nWidth/2);
	var nY		= (window.screen.height/2)-(nHeight/2);
	var sFormat	= "width="+nWidth+",height="+nHeight+",left="+nX+",top="+nY+",resizable=yes,scrollbars=yes";

	window.open(url, "Style", sFormat);
}

function checksubmit(form){
	var msg = ""
	var msg_start = "Please press ok to return back to the form, please fill the following in:\n"
	var conf = ""
	msg_start = msg_start+"-----------------------------------------------------------------------------------\n"
	
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	if(form.email.value == ""){ msg = "Please enter your email address\n" }
		else{
			if(re.test(form.email.value) == false) msg = msg+"Please enter a valid email address\n"
	}
	if((form.pass.value == "") || (form.pass2.value == "")){ msg = msg + "Please fill in both passwords\n"}
	else{
		if(!(form.pass.value == form.pass2.value)) msg = msg + "Your passwords do not match\n";
	}
	if(form.firstname.value == "") msg = msg+"Please enter your first name\n"
	if(form.lastname.value == "") msg = msg+"Please enter your last name\n"
	if(form.companyname.value == "") msg = msg+"Please enter your company name\n"
	if(form.streetaddress1.value == "") msg = msg+"Please enter your street address\n"
	if(form.city.value == "") msg = msg+"Please enter the name of your city\n"
	if(form.postzip.value == "") msg = msg+"Please enter your postcode/zip\n"
	if(form.phone.value == "") msg = msg+"Please enter your phone number\n"
	if(form.conf.checked == false) msg = msg+"\nPlease agree to the TOC, otherwise access to the site is void\n"
	if(msg == "") {
		return true
	}else{
		alert(msg_start+msg+"-----------------------------------------------------------------------------------")
		return false //return FALSE !!!!
	}
}


function checkemailform(form){
	var msg = ""
	var msg_start = "Please press ok to return back to the form, please fill the following in:\n"
	var conf = ""
	msg_start = msg_start+"-----------------------------------------------------------------------------------\n"
	
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	if(form.email.value == ""){ msg = "Please enter your email address\n" }
		else{
			if(re.test(form.email.value) == false) msg = msg+"Please enter a valid email address\n"
	}
	if(form.name.value == "") msg = msg+"Please enter your name\n"
	if(form.phonenumber.value == "") msg = msg+"Please enter your phone number\n"
	if(form.message.value == "") msg = msg+"Please enter your message\n"

	if(msg == "") {
		return true
	}else{
		alert(msg_start+msg+"-----------------------------------------------------------------------------------")
		return false //return FALSE !!!!
	}
}