/* ------- Page Navigation ---- */
if(document.pageid) {
	docpageid=document.pageid;
	if(docpageid.indexOf(".")!=-1) {
		docpageid=docpageid.split(".");
	} else {
		docpageid=new Array(docpageid)
	}			
}
	
function checkNav(){
}

function expandNav() {
	for(i=0;i<docpageid.length;i++) {
		if(document.getElementById(docpageid[i])) {
			document.getElementById(docpageid[i]).style.color="#5FD200";
			
			if (docpageid.length > 1) {
				document.getElementById(docpageid[1]).style.color="#FFFFFF";
			}
			
			if(document.getElementById((docpageid[i]+"sub"))) {
			document.getElementById((docpageid[i]+"sub")).style.display="";
			}
				
		}
	}
}
/* ------- yoursay form comments counter ---- */
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) 
	field.value = field.value.substring(0, maxlimit);
	else 
	countfield.value = maxlimit - field.value.length;
	}	

/* ------- Validation for Comments Form ---- */
function test(args) {
	alert(args);
}

function validate (f) {
	errors="";
	f.referrerUrl.value=document.location;

	for(i=0;i<f.length;i++) {
		
		if (f[i].type == "hidden") {
			//ignore these fields
			
		} else {
		
			if ((f[i].type=="text")||(f[i].type=="textarea")) {
			 str=f[i].value.length;
			 str2=0;
				while(str!=0) {
				//test(f[i].value.charCodeAt(str-1));
					if(f[i].value.charCodeAt(str-1)<=32) {
						str2+=1;
					}
					str-=1;
				}
				if(str2>=f[i].value.length-str2) {
				///
						errors+=f[i].name+" ?\n";

				
				} else {
					//specific matches only now
					if(f[i].name=="email") {
						chk2 = 0;
						str=f[i].value.length;
						while(str!=0) {
							if(f[i].value.charAt(str)==('@') || f[i].value.charAt(str)==('.')) {
							chk2+=1;
							}
						str-=1;			
						}
						if(chk2<2) {
						errors+="Email address is invalid\n";
						}
					}
				}
			}
		}	
	}
	if(errors!="") {
	test(("Sorry there appears to be a problem with details you supplied.\n\nPlease correct the following questions and try again. \n\n" +errors))
	return false;
	}

}

// used by the Send Comments form
// not all fields require validation
// hardcode the ones that don't
function partialValidate (f) {
	errors="";
	f.referrerUrl.value=document.location;

	for(i=0;i<f.length;i++) {
		
		if (f[i].type == "hidden" || f[i].name == "tel" || f[i].name == "town") {
			//ignore these fields
			
		} else {
		
			if ((f[i].type=="text")||(f[i].type=="textarea")) {
			 str=f[i].value.length;
			 str2=0;
				while(str!=0) {
				//test(f[i].value.charCodeAt(str-1));
					if(f[i].value.charCodeAt(str-1)<=32) {
						str2+=1;
					}
					str-=1;
				}
				if(str2>=f[i].value.length-str2) {
				///
						errors+=f[i].name+" ?\n";

				
				} else {
					//specific matches only now
					if(f[i].name=="email") {
						chk2 = 0;
						str=f[i].value.length;
						while(str!=0) {
							if(f[i].value.charAt(str)==('@') || f[i].value.charAt(str)==('.')) {
							chk2+=1;
							}
						str-=1;			
						}
						if(chk2<2) {
						errors+="Email address is invalid\n";
						}
					}
				}
			}
		}	
	}
	if(errors!="") {
	test(("Sorry there appears to be a problem with details you supplied.\n\nPlease correct the following questions and try again. \n\n" +errors))
	return false;
	}

}