/*
	Website scripts
	(c) BDesigned Studios
*/

function openWindow(address,winurl,winwidth,winheight) {
	var new_window = window.open(address,winurl,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=' + winwidth + ',height=' + winheight);
}

function popup_centre(popupwidth,popupheight) {
	/* When calling this function supply the width and height of the popup */
	var horizontal = ((screen.availWidth / 2) - (popupwidth / 2));
	var vertical = ((screen.availHeight / 2) - (popupheight / 2));
	window.moveTo(horizontal,vertical);
}

function validateContact() {
	var errormessage = 'Please ensure that you have completed the following:\n';
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if(
	   (document.contact_form.myname.value != '') &&
	   (document.contact_form.myname.value != 'enter your name...') &&
	   (document.contact_form.myemail.value != '') &&
	   (document.contact_form.myemail.value != 'enter your email address...') &&
	   (filter.test(document.contact_form.myemail.value)) &&
	   (document.contact_form.mycomment.value != '') &&
	   (document.contact_form.mycomment.value != 'enter your message...')
	  ) {
		document.contact_form.submit();
	} else {
		if((document.contact_form.myname.value == '') || (document.contact_form.myname.value == 'enter your name...')) {
			errormessage += "  > Your name\n";
		}
		if((document.contact_form.myemail.value == '') || (document.contact_form.myemail.value == 'enter your email address...')) {
			errormessage += "  > Your email\n";
		} else {
			if((filter.test(document.contact_form.myemail.value)) == false) {
				errormessage += "  > You must enter a valid email address\n";
			}
		}
		if((document.contact_form.mycomment.value == '') || (document.contact_form.mycomment.value == 'enter your message...')) {
			errormessage += "  > Your comment\n";
		}
		alert(errormessage);
	}
}