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";
 }
}
window.onload = externalLinks;

function launchFlashHome() {
	var x = (screen.availWidth - 760) / 2;
	var y = (screen.availHeight - 550) / 2;
	var flash = window.open("home_nodetect.html", "flash", "left=" + x + ",top=" + y + ",width=760,height=550,scrollbars=no");
	flash.focus();
}

function launchFlash() {
	var x = (screen.availWidth - 760) / 2;
	var y = (screen.availHeight - 550) / 2;
	var flash = window.open("home.html", "flash", "left=" + x + ",top=" + y + ",width=760,height=550,scrollbars=no");
	flash.focus();
}

function enlarge(id, w, h, oversize) {
	var x,y;
	x = (screen.availWidth - w) / 2;
	y = (screen.availHeight - h) / 2;
	var large = window.open("", "large", "left=" + x + ",top=" + y + ",width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes");
	large.document.open();
	large.document.write('<body>');

//  ---- Comment out to work with IE PC ----
	var agt=navigator.userAgent.toLowerCase();
	if ( (document.all) && (agt.indexOf("win")!=-1) ){
		w += 10;
		h += 36;
		large.document.writeln('<script type="text/javascript">w = ' + w + '; h = ' + h);
		large.document.writeln('self.resizeTo(w, h);</script>');
	} 
	else {
		large.document.write('<script type="text/javascript">w = ' + w + '; h = ' + h + '; if (window.innerWidth) { w = ' + w + ' + window.outerWidth - window.innerWidth; h = ' + h + ' + window.outerHeight - window.innerHeight; } self.resizeTo(w, h);</script>');
	}
	large.document.write('<script type="text/javascript">self.moveTo((screen.availWidth - w)/2, (screen.availHeight - h)/2);</script>');
	if (oversize)
		large.document.write('<style type="text/css">body { background-color: #ffffff; margin: 0; overflow: scroll; }</style>');
	else
		large.document.write('<style type="text/css">body { background-color: #ffffff; margin: 0; overflow: hidden; }</style>');
	large.document.write('<img src="large/' + id + '_lrg.jpg">');
	large.document.write('</body>');
	large.document.close();
	large.focus();
}




function goHTML(page) {
	var pagename = "";
	switch(page) {
		case 0: pagename = 'intro.html'; break;
		case 1: pagename = 'patchwork.html'; break;
		case 2: pagename = 'paperballots.html'; break;
		case 3: pagename = 'reform.html'; break;
		case 4: pagename = 'votingmachine.html'; break;
		case 5: pagename = 'punchcard.html'; break;
		case 6: pagename = 'florida.html'; break;
		case 7: pagename = 'design.html'; break;
		case 8: pagename = 'future.html'; break;
		default: pagename = 'index.html'; break;
	}
	if (window.opener) {
		window.opener.window.focus();
		window.opener.window.location.href = pagename;
	} else {
		var altpop = window.open(pagename, "altpop");
		altpop.focus();
	}
}

function goCredits() {
	if (window.opener) {
		window.opener.window.focus();
		window.opener.window.location.href = 'credits.html';
	} else {
		var altpop = window.open("credits.html", "altpop");
		altpop.focus();
	}
}

function goBibliography() {
	if (window.opener) {
		window.opener.window.focus();
		window.opener.window.location.href = 'resources.html';
	} else {
		var altpop = window.open("resources.html", "altpop");
		altpop.focus();
	}
}

function goPress() {
	if (window.opener) {
		window.opener.window.focus();
		window.opener.window.location.href = 'press.html';
	} else {
		var altpop = window.open("press.html", "altpop");
		altpop.focus();
	}
}

function showTip(div) {
	num = document.getElementById(div);
	tip = document.getElementById('tooltip');
	pag = document.getElementById('page');
	if (pag.offsetTop == 0)
		tip.style.top = (130) + "px";
	else
		tip.style.top = (135) + "px";
	tip.style.left = (110 + pag.offsetLeft) + "px";
}

