// JavaScript Document

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";
		}
	}
}

function closebigimg() {
	document.getElementById("bigimgdiv").style.display = "none";
}

function enlargeImage(which) {
	function width_window(){
		if(window.innerWidth) {
			return window.innerWidth;
		}
		if(document.body.clientWidth) {
			return document.body.clientWidth;
		}
	}
	function height_window(){
		if(window.innerHeight) {
			return window.innerHeight;
		}
		if(document.body.clientHeight) {
			return document.body.clientHeight;
		}
	}
	document.getElementById("bigimg").src="images/" + which;
	document.getElementById("bigimg").onload = function() {
		document.getElementById("bigimgdiv").style.left = (width_window()/2 - document.bigimg.width/2) - 20 + "px";
		document.getElementById("bigimgdiv").style.top = (height_window()/2 - document.bigimg.height/2) - 20 + "px";
	};
	document.getElementById("bigimgdiv").style.display = "block";
}

var hairorbald = "hair";
function headerRollOver() {
	function findNewSrc() {
		var temp = new Array();
		temp = document.getElementById('headerphoto').src.split('/');
		var temp2 = temp[7].split('.');
		return temp2[0];
	}
	if(hairorbald=="hair") {
		document.getElementById('headerphoto').src = "http://www.yourhairx.com/images/headerphotos/" + findNewSrc() + "_over.jpg";
		hairorbald = "bald";
	} else {
		temp = findNewSrc().split('_');
		document.getElementById('headerphoto').src = "http://www.yourhairx.com/images/headerphotos/" + temp[0] + ".jpg";
		hairorbald = "hair";
	}
}

window.onload = function() {externalLinks();}