function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

sfHover = function() {
	if (document.getElementById && document.getElementsByTagName) {
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent){
	window.attachEvent("onload",sfHover);
}

function menu() {
	if (document.getElementById) {
		var leftColumn = document.getElementById('leftColumn');
		var leftColumnContent = document.getElementById('leftColumnContent');
		var centerTools = document.getElementById('centerTools');
		var htmlCenter = centerTools.innerHTML;
		var htmlNavBar = document.getElementById('nav').innerHTML;
		if (leftColumn.style.display == 'block') {
			leftColumn.style.display = 'none';
			centerTools.innerHTML = htmlCenter.replace('Hide','Show');
		} else {
			leftColumn.style.display = 'block';
			leftColumn.style.width = '140px';
			centerTools.innerHTML = htmlCenter.replace('Show','Hide');
			leftColumnContent.innerHTML = '<ul id="menu">' + htmlNavBar + '</ul>';
		}
	}
}

function printpage() {
	var options = "scrollbars,resizable"; 
	var text = '<table cellpadding="10" cellspacing="0" border="0" width="100%"><tr><td valign="top"><em>Web address:</em> <strong>' + this.location.href.replace(/#/,'') + '</strong></td><td valign="top" align="right"><input type=button value="Print this page" onClick="window.print()"></td></tr></table>';
		text += '<table cellpadding="10" cellspacing="0" border="0" width="100%"><tr><td valign="top"><img src="/images/logo.gif"></td><td valign="top">';
		text += '</td></tr></table>';
		text += '<div id="centerColumn"><div id="centerColumnContent">';
		text += document.getElementById('centerColumnContent').innerHTML;
		text += '</div></div>';
		text += '<div class="clear"></div>';
		text += '<div id="footer" style="background-color: #fff;">';
		text += document.getElementById('footer').innerHTML;
		text += '</div>';
		text += "<br>";
		text = text.replace(/<scr\ipt[^>]*?>[.\s\S]*?<\/scr\ipt>/gi,'');
		text = text.replace(/<div id="first_ad_unit">[.\s\S]*?<hr><\/div>/gi,'');
		text = text.replace(/<div id="second_ad_unit">[.\s\S]*?<hr><\/div>/gi,'');
		text = text.replace(/<iframe[^>]*?>[.\s\S]*?<\/iframe>/gi,'');
	var winprint = window.open("","",options);
		winprint.document.open();
		winprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
		winprint.document.write('<html>');
		winprint.document.write('<head><scr'+'ipt>function stopError() { return true; }');
		winprint.document.write('window.onerror = stopError;');
		winprint.document.write('</scr'+'ipt></head>');
		winprint.document.write('<link href="/styles/general.css" type="text/css" rel="stylesheet" /><body>'); 
		winprint.document.write(text);
		winprint.document.write('</body></html>'); 
		winprint.document.close();
}

function emailpage() {
	var recipient = prompt("Recipient's email address:","");
	if (recipient == null) {
		alert("You must enter an email address.")
	} else {
		var subject = document.title;
		var url = document.location.href;
		var body = "Please see the following page ...\n\n" + "Title:   " + subject + "\n" + "Link:    " + url + "\n";
		var message = "mailto:" + recipient + "?subject=" + escape(subject) + "&body=" + escape(body);
		window.location = message;
		window.focus();
	}
}

function bookmark() {
	if (document.all)
		window.external.AddFavorite(this.location.href, document.title);
	else if (window.sidebar)
		window.sidebar.addPanel(document.title, this.location.href, "")
}

function size(arg) {
	var center = document.getElementById('centerColumnContent');
	var mid = document.getElementById('midColumnContent');
	if (arg == 'minus') {
		center.style.fontSize = '0.6em';
		mid.style.fontSize = '0.6em';
	} else if (arg == 'reset') {
		center.style.fontSize = '0.8em';
		mid.style.fontSize = '0.8em';
	} else if (arg == 'plus') {
		center.style.fontSize = '1em';
		mid.style.fontSize = '1em';
	}
}

function redirect(arg) {
	url = arg.replace(/^http[^?]*?\?url=/,'');
//	alert(url);
	location = url;
}

addLoadEvent(function() {
	var excludedomains=["localhost", "127.0.0.1", "local.sciencedaily", "www.sciencedaily.com", "www.sciencedaily.net", "www.sciencedaily.org", "sciencedaily.com", "sciencedaily.net", "sciencedaily.org", "healthology.sciencedaily.com", "sciencedaily.healthology.com", "mediwire.sciencedaily.com", "sciencedaily.mediwire.com", "healthcare.careerbuilder.com", "sciencebiotech.careerbuilder.com", "engineering.careerbuilder.com", "informationtechnology.careerbuilder.com", "www.careerbuilder.com"];
	var excludedomains = excludedomains.join("|");
	rexcludedomains = new RegExp(excludedomains, "i");
	for (i=0; i<=(document.links.length-1); i++) {
		if (document.links[i].hostname.search(rexcludedomains)==-1 && document.links[i].href.indexOf("http:")!=-1) {
			document.links[i].target="_blank";
		}
		if (document.links[i].href.indexOf("/goto.php")!=-1) {
			document.links[i].onclick=new Function("redirect(this.href); return false;");
		}
	}
});

