function checkEmail(strng) {
	var error = "";

	var emailFilter=/^.+@.+\..{2,6}$/;

	if (!(emailFilter.test(strng))) {
		return false;
	}

	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\] ']/

	if (strng.match(illegalChars)) {
		return false;
	}

	return true;
}

function form_validator(theForm)
{

	if(!checkEmail(theForm.SignupEmail.value)) {
		 alert("Please enter a valid Email Address");
		theForm.SignupEmail.focus();
		 return false;
	}

	return (true);
}

function toggleDiv(thediv) {
	if (document.getElementById(thediv)) {
		if (document.getElementById(thediv).style.display=='block') {
			document.getElementById(thediv).style.display='none';
		}else{
			document.getElementById(thediv).style.display='block';
		}
	}
}

// ADD AN EVENT TO RUN ONLOAD
function addLoadEvent(func) {
	var oldonload = window.onload;

	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function externalLinks() { 
	if (!document.getElementsByTagName) return; 
	
	var anchors = document.getElementsByTagName("a"); 
	
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank"; 
		}
	}
}

addLoadEvent(function() {
	externalLinks();
	
	if (document.getElementById("financelink")) {
		document.getElementById("financelink").onclick = function() {
			url    = this.getAttribute("href");
  			finWin = window.open(url,'finWin','toolbar=no,status=no,resizable=no,menubar=no,scrollbar=no,width=440,height=540,left=10,top=10');
  			finWin.focus();
  			return false;
		}
	}
});