function addLoadListener( func ) { 
if (typeof window.addEventListener != 'undefined') { //Check for window.addEventListener (FireFox)
window.addEventListener('load', func, false); // Set for FF
}
else if (typeof document.addEventListener != 'undefined') { // Check for document.addEventListener (FireFox)
document.addEventListener('load', func, false);
}
else if (typeof window.attachEvent != 'undefined') { // Check for window.attachEvent (IE)
window.attachEvent('onload', func);
}
else {
var oldfn = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}
else {
window.onload = function() {
oldfn();
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";
}
}
addLoadListener ( externalLinks );
var validation = {
empty: function ( field ) {
var re = /^\s*$/;
return re.test( field.value );
},
email: function ( field ) {
var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
return re.test( field.value );
}
}
String.prototype.trim = function() {
return this.replace(/^\s*|\s*$/g, '');
}
var fullname 	= true,
email 		= true,
comments	= true;
var error = [];
error[0] = " - Please enter your first name.\n";
error[1] = " - Please enter your email address.\n";
error[2] = " - Your email address is incorrectly formated.\n";
error[3] = " - Please enter a comment for the publisher.\n";
function validate( e ){
var focus_el = null, 
msg = '', 
prefix = "Your contact form has had some errors:\n";
e.fullname.value = e.fullname.value.trim();
e.email.value = e.email.value.trim();
e.comments.value = e.comments.value.trim();
if ( fullname && validation.empty ( e.fullname ) ) {
msg += error[0];
focus_el = focus_el || e.fullname;
}
if ( email && validation.empty ( e.email ) ) {
msg += error[1];
focus_el = focus_el || e.email;
}
if ( email && !validation.empty ( e.email ) ) {
if ( !validation.email ( e.email ) ) {
msg += error[2];
focus_el = focus_el || e.email;
}
}
if ( comments && validation.empty ( e.comments ) ) {
msg += error[3];
focus_el = focus_el || e.comments;
}
if ( msg != '' ) {
alert(prefix+msg);
if ( focus_el.focus ) {
focus_el.focus();
}
return false;
}
else {	
return true;
}

}