/* SET COPYRIGHT INFO */
var theDate = new Date();
var theYear = theDate.getFullYear();
var theCopyright = "&copy 2005&#8211;" + theYear + " ARF! ARF! RECORDS";

function setCopyright(){
	document.getElementById('copyright').innerHTML = theCopyright;
	}


/* FIX PAGE HEIGHT */

function setHeight() {
	var contentHeight = document.getElementById('main').offsetHeight;		// the main div's height

	if (navigator.appName.indexOf("Microsoft")!=-1) {
		var windowHeight = document.documentElement.clientHeight;  // the browser window height for IE
		} else {
		var windowHeight = window.innerHeight;		// the browser window height
		}


	if (contentHeight < windowHeight) {
		document.getElementById('main').style.height = windowHeight + "px";
		}
	}







////////// IMAGE SWAPPING SCRIPT //////////

//SIDE HEADS
var bands = "works";
var contact = "discography";
var dist = "productions";
var excl = "purchase";

// TOP SUBLINKS
var gh = "gh";
var newrel = "newrel";
var news = "news";
var store = "store";
var tour = "tour";
var r45 = "45";
var a45 = "a45";
var ep = "ep";
var lp = "lp";
var alp = "alp";
var tshirt = "tshirt";
var misc = "misc";

// necesary

if (document.images) {
	relPath = "../sfz/resources/gifs/interface/"


	imag = new Array();

	imag[0] = relPath + "works.gif";
	imag[1] = relPath + "works-o.gif";
	imag[2] = relPath + "discography.gif";
	imag[3] = relPath + "discography-o.gif";
	imag[4] = relPath + "productions.gif";
	imag[5] = relPath + "productions-o.gif";
	imag[6] = relPath + "purchase.gif";
	imag[7] = relPath + "purchase-o.gif";



	imag[8] = relPath + "biography.gif";
	imag[9] = relPath + "biography-o.gif";
	imag[10] = relPath + "resume.gif";
	imag[11] = relPath + "resume-o.gif";
	imag[12] = relPath + "news.gif";
	imag[13] = relPath + "news-o.gif";
	imag[14] = relPath + "photos.gif";
	imag[15] = relPath + "photos-o.gif";
	imag[16] = relPath + "press.gif";
	imag[17] = relPath + "press-o.gif";
	imag[18] = relPath + "contact.gif";
	imag[19] = relPath + "contact-o.gif";




	im = new Array();
	for (var i = 0; i < imag.length; i++) {
		im[i] = new Image; im[i].src = imag[i];
		}
	}

function swapImage(imgName, num) {
	if (document.images && imgName) {

		document.getElementById(imgName).src = im[num].src;
//		imgName.src = im[num].src;
		}
	return;
	}




////////////////////////////////////////
/* LINK TO OTHER PAGES IN NEW WINDOW */
//////////////////////////////////////

function outlink(theURL) {
	var theURL = theURL;
	window.open(theURL);
	}





/* SHOW SELECTED FIELD */
function selectField(theField, status) {
	var theField = theField;
	var theStatus = status;
	var theID = theField.id;
	var theMessage = theField.value;

	var origMess = new Array();
	origMess = {"email" : "Enter your email address", "subject" : "The Subject", "themessage" : "The Message"};


	if (theStatus == "focus") {
		if (theField.value == origMess[theID]) {
			theField.value = "";
			}
		theField.className = "selected";
		} else {
		if (theField.value == "") {  // if the field is empty
			theField.value = origMess[theID];
			}
		theField.className = "";
		}

	}


/* CHECK THE FORM */
function checkkey() {
	var emailVal = document.getElementById('email').value;
	var subVal = document.getElementById('subject').value;
	var msgVal = document.getElementById('themessage').value;
	var theFlag = true;

	// CHECK FOR EMAIL FIELD
	if (emailVal == "" || emailVal == "Enter your email address") {
		alert("Please enter an email address");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		theFlag = false;
		return;
		}

	// DEFINE A VALID EMAIL REGEX
	var valEmail = /^[a-z0-9\._\-+]*@[a-z]*\.[a-z]{2,3}$/i;

	// TEST TO SEE IF EMAIL IS VALID
	if (!valEmail.test(emailVal)) {
		alert("Please enter a valid email address.");

		document.getElementById('email').focus();
		document.getElementById('email').select();
		theFlag = false;
		return;
		}



	if (subVal == "" || subVal == "The Subject") {
		alert("Please enter a subject for this email");
		document.getElementById('subject').focus();
		document.getElementById('subject').select();
		theFlag = false;
		return;
		}

	if (msgVal == "" || msgVal == "The Message") {
		alert("Please type your message.");
		document.getElementById('themessage').focus();
		document.getElementById('themessage').select();
		theFlag = false;
		return;
		}

	// IF IT PASSES MUSTER, SEND THE EMAIL
	if (theFlag == true) {
		var theArgs = "?email=" + emailVal + "&subject=" + subVal + "&themessage=" + msgVal;
		location.href = "http://www.arfarfrecords.com/cgi-bin/sfzMyFlash.cgi" + theArgs;
		}


	}



/* SHOW/HIDE TABS FOR RESUME */

function showTab (theTab) {
	var theTab = theTab;

	var allTabs = new Array ("professional", "personal", "teaching", "birdsongs");
	var resTabs = new Array ();
	resTabs = {"professional" : "profBut", "personal" : "persBut", "teaching" : "teacBut", "birdsongs" : "birdBut"};


	/* MAKE SURE ALL TABS ARE CLOSED */
	for (i = 0; i < 4; i++) {
		var curTab = allTabs[i];

		document.getElementById(allTabs[i]).style.display = "none";
		document.getElementById(resTabs[curTab]).className = "";
		}

	// SHOW THE CORRECT TAB
	document.getElementById(theTab).style.display = "block";

	// LIGHT UP THE CORRECT BUTTON AS WELL
	document.getElementById(resTabs[theTab]).className = "selected";


	// COMPENSATE FOR LESS INFO -- professional is the only one that doesn't need extra space
	if (theTab == "professional") {
		document.getElementById('pdres').style.marginBottom = 0 + "px";
		} else {
		document.getElementById('pdres').style.marginBottom = 500 + "px";
		}


	}


/* SHOW NEWS STORY IN OVERLAY */
function show(theStory) {
	var theStory = theStory;
	var storyData = document.getElementById(theStory).innerHTML;

	document.getElementById('news-story').style.display = "block";
	document.getElementById('story-content').innerHTML = storyData;

	return false;

	}

/* HIDE NEWS STORY AND OVERLAY */
function hide() {
	document.getElementById('news-story').style.display = "none";
	document.getElementById('story-content').innerHTML = "";

	return false;
	}


/* SHOW DIFF SECTIONS OF DETAIL PAGE */
function showDiv(theID) {
	var theID = theID;

	// HIDE ALL DIVS
	document.getElementById('info').style.display = "none";
	document.getElementById('recording').style.display = "none";

	// SHOW CORRECT DIV
	document.getElementById(theID).style.display = "block";


	// DESELECT ALL TABS
	document.getElementById('l0').className = "";
	document.getElementById('l1').className = "";

	// SELECT CORRECT TAB
	if (theID == "info") {
		document.getElementById('l0').className = "selected";
		} else {
		document.getElementById('l1').className = "selected";
		}


	}





/* DISPLAY PHOTO IN OVERLAY */
function viewPic (thePic) {
	var thePic = thePic;
	var theImg = "<img src='content/photos/EL-" + thePic + ".jpg' alt='Photo of Erik Lindgren' />";

	document.getElementById('theImg').innerHTML = theImg;
	document.getElementById('photo-overlay').style.display = "block";


	}


/* HIDE PHOTO OVERLAY */
function hidePic(){
	document.getElementById('photo-overlay').style.display = "none";
	document.getElementById('theImg').innerHTML = "";
	}

