// Set Global Variables
var theSpaces = / /g;
var theChars = /\D/g;
var theNums = /\d/g;
var newWindow;

// Pre-Load Images
var About_Off = new Image(260,18);
	About_Off.src = "/Images/Button_About_Off.gif";
var About_On = new Image(260,18);
	About_On.src = "/Images/Button_About_On.gif";
var Resume_Off = new Image(260,18);
	Resume_Off.src = "/Images/Button_Resume_Off.gif";
var Resume_On = new Image(260,18);
	Resume_On.src = "/Images/Button_Resume_On.gif";
var Headshots_Off = new Image(260,18);
	Headshots_Off.src = "/Images/Button_Headshots_Off.gif";
var Headshots_On = new Image(260,18);
	Headshots_On.src = "/Images/Button_Headshots_On.gif";
var Demo_Off = new Image(260,18);
	Demo_Off.src = "/Images/Button_Demo_Off.gif";
var Demo_On = new Image(260,18);
	Demo_On.src = "/Images/Button_Demo_On.gif";
var Photos_Off = new Image(260,18);
	Photos_Off.src = "/Images/Button_Photos_Off.gif";
var Photos_On = new Image(260,18);
	Photos_On.src = "/Images/Button_Photos_On.gif";
var Contact_Off = new Image(260,18);
	Contact_Off.src = "/Images/Button_Contact_Off.gif";
var Contact_On = new Image(260,18);
	Contact_On.src = "/Images/Button_Contact_On.gif";
var IMDB_Off = new Image(260,18);
	IMDB_Off.src = "/Images/Button_IMDB_Off.gif";
var IMDB_On = new Image(260,18);
	IMDB_On.src = "/Images/Button_IMDB_On.gif";

// Swap Image
function swapImage(theAction, theImage, theOriginalImage) {
if (theAction == 1) {
	document[theImage].src = eval(theImage + "_On.src");
	}
if (theAction == 0) {
	document[theImage].src = eval(theImage + "_Off.src");
	}
if (theOriginalImage) {
	document[theOriginalImage].src = eval(theOriginalImage + "_On.src");
	}
}

// Give Focus
function giveFocus(theForm, theField) {
	eval("document.forms(" + theForm + ")." + theField + ".focus()");
}

// Write Email
function writeEmail(theUser, theDomain) {
var theAddress = theUser + "@" + theDomain
	document.write("<A HREF=\"mailto:" + theAddress + "\">" + theAddress + "</A>");
}

// Make Remote
function makeRemote(theURL, theWidth, theHeight, theOptions) {
var theCenterWidth = (window.screen.width - theWidth) / 2;
var theCenterHeight = (window.screen.height - theHeight) / 2;
if (newWindow) {
	newWindow.close();
	}
	newWindow = window.open(theURL, "Remote", "Width=" + theWidth + ",Height=" + theHeight + "," + theOptions);
	newWindow.moveTo(theCenterWidth, theCenterHeight - 50);
	newWindow.focus();
}

// Check Phone
function checkPhone(theField) {
	theField.value = theField.value.replace(theChars, "");
if (!isNaN(theField.value) && theField.value.length == 10) {
	var Part1 = theField.value.substr(0,3);
	var Part2 = theField.value.substr(3,3);
	var Part3 = theField.value.substr(6,4);
	theField.value = Part1 + "-" + Part2 + "-" + Part3;
	return true;
	}
}

// Check Email
function checkEmail(theField) {
var theInvalidChars = /[^A-Za-z0-9._@-]/g;
	theField.value = theField.value.replace(theInvalidChars, "");
var theLength = theField.value.length;
var theAt = theField.value.indexOf("@");
var thePeriod = theField.value.lastIndexOf(".");
if (!(theLength < 8 || theAt < 2 || (thePeriod > theLength - 3 || thePeriod < theLength - 5) || theAt > thePeriod - 3)) {
	return true;
	}
}

// Confirm Delete
function confirmDelete(theURL) {
if (confirm("Are you sure you wish to delete this item?\nThis action cannot be undone.")) {
	location.href = theURL;
	}
}