//<!--
 
// email popup

function email_page(data) {
	emailWindow = window.open('/common/emailarticle.php?' + data, 'email_window', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=512,height=400');
}

// printer-friendly version popup

function print_page(url) {
	if ( url.substring(0, 10) == '/articles/' ) {
		printWindow = window.open(url + '?printbtn=Print+This+Window', 'print_window', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=536,height=500');		
	}
	else {
		printWindow = window.open('/print' + url, 'print_window', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=536,height=500');
	}
}

function print_adhoc(url) {	
		var p = url + "?div=1";
		printWindow = window.open(p + '&printbtn=Print+This+Window',  'print_window', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=536,height=500');
}

function checkEmailForm(theForm) {
	var TO		= theForm.TO.value;
	var FROM	= theForm.FROM.value;
	var BCC		= theForm.BCC.value;
	var regExp	= /[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})/; // email validator
	
	toValid =	TO.search(regExp);
	fromValid =	FROM.search(regExp);
	bccValid =	BCC.search(regExp);
	
	if (TO == "") {
		theForm.TO.focus();
		alert("You must first enter the email address of the person \rto whom you would like to send this article.");
		return false;
	} else if (toValid == -1) {
		theForm.TO.focus();
		alert("You must first enter a valid email address in the \"To\" field.");
		return false;
	} else if (FROM == "") {
		theForm.FROM.focus();
		alert("You must first enter your email address in the \"Your Email Address\" field.");
		return false;
	} else if (fromValid == -1) {
		theForm.FROM.focus();
		alert("You must first enter a valid email address in the \"Your Email Address\" field.");
		return false;
	} else if (BCC != "" && bccValid == -1) {
		theForm.BCC.focus();
		alert("You must first enter a valid email address in the \"Bcc\" field.");
		return false;
	}
}

// Other functions

function toggleWorldMap() {
	var mapObj = document.getElementById('mapwindow');
	state = mapObj.style.display;
	if (state == 'none')
		mapObj.style.display = 'block';
	else if (state == 'block')
		mapObj.style.display = 'none';
}

function checkMiniReg(theForm) {
	alert('This form doesn\t do anything yet, but you get the general idea...');
	return false;
}
//-->
