/////////////////////////////////////////////////////////////////////
// Subscribe form //
/////////////////////////////////////////////////////////////////////

function popUp(URL) {
	var day = new Date();
	var id = day.getTime();
	var w = 600;
	var h = 315;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + ",left=0,top=0');");
}

function validate(nForm){
	msg = "" ;
	fieldFocus = "" ;
	if (inValid(nForm.from_name.value)) {
		msg += "\n-- Full name";
		fieldFocus = nForm.from_name;
	}
	if (invalidEmail(nForm.from_email.value) || inValid(nForm.from_email.value)) {
		msg += "\n-- Email address";
		if (fieldFocus == "") {
			fieldFocus = nForm.from_email;
		}
	}
	if (msg == ""){
		if (confirm("Please confirm your details are correct: \n\n-- Full name: " + nForm.from_name.value + "\n-- Email address: " + nForm.from_email.value)) {
			return true;
		} else {
			nForm.from_name.focus();
			return false;
		}
	} else {	
		alert("Please correctly enter your: \n" + msg);
		if (fieldFocus && fieldFocus.focus()) {
			fieldFocus.focus();
		}
		return false;
	}
}

function inValid(str){
	return (!str || str == "") ;
}

function invalidEmail(str){
	atPos  = str.indexOf('@') ;
	dotPos = str.indexOf('.') ;
	return ( inValid(str) || atPos < 1 || atPos > (str.length - 5) || dotPos < 1 || dotPos > (str.length - 2) ) ;
}