/* --- open all external links in a new window */

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; //run function upon page load

/* --- toggle the pages */

//define Arrays
var pgs = new Array(3);
pgs[0] = 'news';
pgs[1] = 'story';
pgs[2] = 'cast-crew';
pgs[3] = 'press';
pgs[4] = 'screenings';

function pageload(hash) {
	if(hash) {
		if($.browser.msie) {
			hash = encodeURIComponent(hash);
		}
		toggleThis(hash);
	} else {
		// start page
		toggleThis('news');
	}
}
	

		

function toggleThis(what) {
	//switch unclicked pages to "out" and hide their boxes
	//or else switch clicked pages to "current" and show
	for (i = 0; i < pgs.length; i++) {
		//var linkName = pgs[i] + '-link';
		var boxName = 'copy-' + pgs[i];
		if (pgs[i] != what) {
			document.getElementById(boxName).style.display = 'none';
		} else {
			document.getElementById(boxName).style.display = '';
		}
	}
}

		
var prev = 12;
var curr = 1;
var next = 2;
var tot = 12;
		
function bioNext(past,future,total) {
			$(document).ready(function() {
				$('#bio-' + past).toggle();
				$('#bio-' + future).toggle();
			});
			curr = future;
			if(curr == total) {
				next = 1;
			} else {
				next = curr+1;
			}
			tot = total;
};
		
function arrowNext(totes) {
			tot = totes;
			if(curr == totes) {
				next = 1;
			} else {
				next = curr+1;
			}
			$(document).ready(function() {
				$('#bio-' + curr).toggle();
				$('#bio-' + next).toggle();
			});
			curr = next;
			if(curr == totes) {
				next = 1;
			} else {
				next = curr+1;
			}
}

function bioPrev(past,future,total) {
			$(document).ready(function() {
				$('#bio-' + past).toggle();
				$('#bio-' + future).toggle();
			});
			curr = future;
			if(curr == 1) {
				prev = total;
			} else {
				prev = curr-1;
			}
			tot = total;
};
		
function arrowPrev(totes) {
			tot = totes;
			if(curr == 1) {
				prev = totes;
			} else {
				prev = curr-1;
			}
			$(document).ready(function() {
				$('#bio-' + curr).toggle();
				$('#bio-' + prev).toggle();
			});
			curr = prev;
			if(curr == 1) {
				prev = totes;
			} else {
				prev = curr-1;
			}
}
