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"; 
		}
	}
}

if (window.addEventListener) {
	window.addEventListener('load', externalLinks, false); 
} else if (window.attachEvent) { 
	window.attachEvent('onload', externalLinks);
}

String.prototype.trim = function () {
    return this.replace(/^\s*/,'').replace(/\s*$/,'');
};

String.prototype.isEmailAddress = function() {
	var emailTestRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	return this.match(emailTestRegex);
}

/* Interviews Home */

$(document).ready(function() {
	$('.personDetails').hide();
	$('.personDetails').filter('.first').show();
		
	$('.thumbnailPerson').each(function() {
		this.srcOut = this.src;
		this.srcOver = this.src.substring(0, this.src.lastIndexOf('.jpg')) + '_over' + '.jpg';
	})
		
	$('.thumbnailPerson').filter('.first').each(function() {
		this.src = this.srcOver;
	});

	$('.thumbnailPerson').mouseover(function() {
		$('.thumbnailPerson', this.parentNode.parentNode.parentNode).each(function() {
			this.src = this.srcOut;
		});
		
		$('.personDetails', this.parentNode.parentNode.parentNode.parentNode).hide();

		this.src = this.srcOver;
		$('#person' + this.id.substr(15)).show();
	});
});

/* DropDown */

$(document).ready(function() {
	$("a#menuInterviews").mouseover(function () {
		if ($('div#dropDownInterviews').is(":hidden")) {
			$('div#dropDownInterviews').show();
		} 
	}).click(function() { return false; });

	$("a#menuThemes").mouseover(function () {
		if ($('div#dropDownThemes').is(":hidden")) {
			$('div#dropDownThemes').show();
		} 
	}).click(function() { return false; });
	
	$("div#dropDownInterviews").bind('mouseleave', function () {
		$(this).hide();
	});
	
	$("div#dropDownThemes").bind('mouseleave', function () {
		$(this).hide();
	});
	
	$("div#menu a").mouseover(function () {
		if (this.id != 'menuThemes') $('div#dropDownThemes').hide();
		if (this.id != 'menuInterviews') $('div#dropDownInterviews').hide();
	});
});
