//var PayMethod = "cc";
document.onmousemove = CaptureMousePosition;
//document.onmousedown = CaptureMouseDown;
if (document.all) // for IE
	document.onmousedown = CaptureClick;
else // for FF
	document.onclick = CaptureClick;

xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

var bMouseOnArtwork = false;
var arrArtWorks;
var arrArtWorkHeights;
var arrArtWorkWidths;
var arrArtWorkSeriesNums;
var sOnDeckImages;
var FadeOutCount = 0;
var FadeInCount = 0;
var FadeMode = "both";
var iOnDeckImage0 = 0;
var iOnDeckImage1 = 0;
var iOnDeckImage2 = 0;
var iOnDeckImage3 = 0;
var iOnDeckImage4 = 0;

var arrRingerTshirtColorName;
var arrRingerTshirtColorRgb;
var sWhiteRgb = "FDFDFD";

function BodyLoad()
{
	//alert("navigator.appName=" + navigator.appName);

	if (document.theForm.ArtWorks)
	{
		arrArtWorks = document.theForm.ArtWorks.value.split("~");
		if ( arrArtWorks.length > 1 )	// artwork is on this page
		{
			arrArtWorkHeights = document.theForm.ArtWorkHeights.value.split("~");
			arrArtWorkWidths = document.theForm.ArtWorkWidths.value.split("~");
			arrArtWorkSeriesNums = document.theForm.ArtWorkSeriesNums.value.split("~");
			ChangeArtWorkLoop(true);
		}
	}

	//if ( sPosterTitleFocus == "y" )
	//	document.theForm.PosterTitle.focus();

	var TshirtLeft = 0;
	var TshirtTop = 0;
	if (document.getElementById("TshirtPos"))
	{
		TshirtLeft = document.getElementById("TshirtPos").offsetLeft;
		TshirtTop = document.getElementById("TshirtPos").offsetTop;
	}
	//alert("TshirtLeft=" + TshirtLeft);
	//alert("TshirtTop=" + TshirtTop);

	//if ( navigator.appName.indexOf("Netscape") != -1 )

	//var ffleft = document.defaultView.getComputedStyle(document.getElementById("TshirtPosTop"), null).getPropertyValue("left");

	if (document.getElementById("TshirtPosLeft"))
		document.getElementById("TshirtPosLeft").value = TshirtLeft;
	if (document.getElementById("TshirtPosTop"))
		document.getElementById("TshirtPosTop").value = TshirtTop;

//	document.getElementById("TshirtArtworkImg").style.left = TshirtLeft;
//	document.getElementById("TshirtArtworkImg").style.right = TshirtRight;

	arrRingerTshirtColorName = sRingerTshirtColorNames.split(",");
	arrRingerTshirtColorRgb = sRingerTshirtColorRgbs.split(",");

//	document.getElementById("jsVer").value = "yes";	// doesn't work unless form is submitted
}

function Blink(id, blinksLeft)
{
	if (blinksLeft < 1)
	{
		if (document.getElementById(id))
			document.getElementById(id).style.visibility = "visible";
		return;
	}
	var blinkLength = 1200;
	if (document.getElementById(id))
	{
		if (document.getElementById(id).style.visibility == "visible")
		{
			document.getElementById(id).style.visibility = "hidden";
			blinkLength = 400;
		}
		else
		{
			document.getElementById(id).style.visibility = "visible";
			blinkLength = 1200;
		}
	}
	//blinksLeft--;	// commented to blink forever
	setTimeout("Blink(\"" + id + "\", " + blinksLeft + ")", blinkLength);
}

function ChangeArtWorkLoop(FirstTime)
{ 
	if ( !FirstTime )
	{
		if ( sUseFilterCss == "n")
		{
			FadeOutCount = 0;
			FadeInCount = 0;
			FadeOutImages();
			if ( FadeMode == "both" )
				FadeMode = "height";
			else if ( FadeMode == "height" )
				FadeMode = "width";
			else if ( FadeMode == "width" )
				FadeMode = "both";
		}
		else
			ChangeArtWork();
	}
	setTimeout('ChangeArtWorkLoop(false)', 10000);
}

// fade out displayed images
function FadeOutImages()
{
	var foi;
	var iWidth;
	var iHeight;
	var iMaxCount = 30;
	FadeOutCount++;

	if ( FadeOutCount > iMaxCount )
	{
		// done fading out, change images, then fade in
		if ( FadeInCount == 0 )
			ChangeArtWork();
		FadeInCount++;
		if ( FadeInCount > iMaxCount )
			return;
	}
	var iWidthIncrement = iArtWorkWidthMax / iMaxCount;	// 145 is max width
	var iHeightIncrement = iArtWorkHeightMax / iMaxCount;	// 166 is max height

	if ( FadeInCount == 0 )
	{
		// fading out
		for ( foi=0; foi<5; foi++ )
		{	
			iWidth = document.getElementById("ArtWorkImage"+foi).width;
			iHeight = document.getElementById("ArtWorkImage"+foi).height;
			if ( FadeMode == "width" )
			{
				document.getElementById("ArtWorkImage"+foi).width = iWidth - iWidthIncrement;
				document.getElementById("ArtWorkImage"+foi).height = iHeight;
			}
			else if ( FadeMode == "height" )
			{
				document.getElementById("ArtWorkImage"+foi).height = iHeight - iHeightIncrement;
				document.getElementById("ArtWorkImage"+foi).width = iWidth;
			}
			else if ( FadeMode == "both" )
			{
				document.getElementById("ArtWorkImage"+foi).height = iHeight - iHeightIncrement;
				document.getElementById("ArtWorkImage"+foi).width = iWidth - iWidthIncrement;
			}
		}
	}
	else
	{
		// fading in
		for ( foi=0; foi<5; foi++ )
		{	
			if ( foi == 0 )
			{
				iFullWidth = arrArtWorkWidths[iOnDeckImage0];
				iFullHeight = arrArtWorkHeights[iOnDeckImage0];
			}
			else if ( foi == 1 )
			{
				iFullWidth = arrArtWorkWidths[iOnDeckImage1];
				iFullHeight = arrArtWorkHeights[iOnDeckImage1];
			}
			else if (foi == 2)
			{
				iFullWidth = arrArtWorkWidths[iOnDeckImage2];
				iFullHeight = arrArtWorkHeights[iOnDeckImage2];
			}
			else if (foi == 3)
			{
				iFullWidth = arrArtWorkWidths[iOnDeckImage3];
				iFullHeight = arrArtWorkHeights[iOnDeckImage3];
			}
			else
			{
				iFullWidth = arrArtWorkWidths[iOnDeckImage4];
				iFullHeight = arrArtWorkHeights[iOnDeckImage4];
			}
			iWidth = document.getElementById("ArtWorkImage"+foi).width;
			iHeight = document.getElementById("ArtWorkImage"+foi).height;
			if ( FadeMode == "width" )
			{
				if ( iWidth + iWidthIncrement > iFullWidth || FadeInCount == iMaxCount )
					document.getElementById("ArtWorkImage"+foi).width = iFullWidth;
				else
					document.getElementById("ArtWorkImage"+foi).width = iWidth + iWidthIncrement;
				document.getElementById("ArtWorkImage"+foi).height = iFullHeight;
			}
			else if ( FadeMode == "height" )
			{
				if ( iHeight + iHeightIncrement > iFullHeight || FadeInCount == iMaxCount )
					document.getElementById("ArtWorkImage"+foi).height = iFullHeight;
				else
					document.getElementById("ArtWorkImage"+foi).height = iHeight + iHeightIncrement;
				document.getElementById("ArtWorkImage"+foi).width = iFullWidth;
			}
			else if ( FadeMode == "both" )
			{
				if ( iHeight + iHeightIncrement > iFullHeight || FadeInCount == iMaxCount )
					document.getElementById("ArtWorkImage"+foi).height = iFullHeight;
				else
					document.getElementById("ArtWorkImage"+foi).height = iHeight + iHeightIncrement;
				if ( iWidth + iWidthIncrement > iFullWidth || FadeInCount == iMaxCount )
					document.getElementById("ArtWorkImage"+foi).width = iFullWidth;
				else
					document.getElementById("ArtWorkImage"+foi).width = iWidth + iWidthIncrement;
			}
		}
	}

	setTimeout("FadeOutImages()", 25);
}

function ChangeArtWork()
{
	var iNewImage = 0;

	// find ondeck image positions in arrArtWorks array
	iOnDeckImage0 = FindArrayPosition(unescape(document.getElementById("ArtWorkImageNext0").src));
	iOnDeckImage1 = FindArrayPosition(unescape(document.getElementById("ArtWorkImageNext1").src));
	iOnDeckImage2 = FindArrayPosition(unescape(document.getElementById("ArtWorkImageNext2").src));
	iOnDeckImage3 = FindArrayPosition(unescape(document.getElementById("ArtWorkImageNext3").src));
	iOnDeckImage4 = FindArrayPosition(unescape(document.getElementById("ArtWorkImageNext4").src));
		
	// move ondeck invisible images bar to displayed bar
	if ( sUseFilterCss == "y" )
	{
		ArtWork0.filters[0].apply();
		ArtWork1.filters[0].apply();
		ArtWork2.filters[0].apply();
		ArtWork3.filters[0].apply();
		ArtWork4.filters[0].apply();
	}
	UpdateDisplayedImage(0);
	UpdateDisplayedImage(1);
	UpdateDisplayedImage(2);
	UpdateDisplayedImage(3);
	UpdateDisplayedImage(4);
	if (sUseFilterCss == "y")
	{
		ArtWork0.filters[0].play();
		ArtWork1.filters[0].play();
		ArtWork2.filters[0].play();
		ArtWork3.filters[0].play();
		ArtWork4.filters[0].play();
	}

	///// update on deck bar
	var iRandomIncrement = Math.round(((Math.random()*3.2)+3));	// increment 3,4,5 or 6, atleast 3 each time to avoid another version of the same play
	//alert(iRandomIncrement);
	
	// build str containing 5 artwork images currently on deck - used to make sure an image is not displayed on next iteration
	sOnDeckImages = "";
	pos = document.getElementById("ArtWorkImageNext0").src.lastIndexOf("/");
	if ( pos != -1 )
		sOnDeckImages += unescape(document.getElementById("ArtWorkImageNext0").src.substr(pos));
	pos = document.getElementById("ArtWorkImageNext1").src.lastIndexOf("/");
	if ( pos != -1 )
		sOnDeckImages += unescape(document.getElementById("ArtWorkImageNext1").src.substr(pos));
	pos = document.getElementById("ArtWorkImageNext2").src.lastIndexOf("/");
	if ( pos != -1 )
		sOnDeckImages += unescape(document.getElementById("ArtWorkImageNext2").src.substr(pos));
	pos = document.getElementById("ArtWorkImageNext3").src.lastIndexOf("/");
	if (pos != -1)
		sOnDeckImages += unescape(document.getElementById("ArtWorkImageNext3").src.substr(pos));
	pos = document.getElementById("ArtWorkImageNext4").src.lastIndexOf("/");
	if (pos != -1)
		sOnDeckImages += unescape(document.getElementById("ArtWorkImageNext4").src.substr(pos));
	
	// 1st image
	iNewImage = iOnDeckImage3 + iRandomIncrement;
	UpdateOnDeckImage(iNewImage, "0");
	
	// 2nd image
	iNewImage += iRandomIncrement;
	UpdateOnDeckImage(iNewImage, "1");

	// 3rd image
	iNewImage += iRandomIncrement;
	UpdateOnDeckImage(iNewImage, "2");

	// 4th image
	iNewImage += iRandomIncrement;
	UpdateOnDeckImage(iNewImage, "3");

	// 5th image
	iNewImage += iRandomIncrement;
	UpdateOnDeckImage(iNewImage, "4");
}

function FindArrayPosition(str)
{
	var iFoundPos = 0;

	for ( i=0; i<arrArtWorks.length; i++ )
	{
		if ( str.indexOf(arrArtWorks[i]) != -1 )
		{
			//alert("found ondeck " + i);
			iFoundPos = i;
			i = arrArtWorks.length;
		}
	}
	
	return iFoundPos;
}

// copy on deck images to displayed bar
function UpdateDisplayedImage(iImagePos)
{
	var iArrPos;
	var sSeriesNum;
	var str;
	
	// src
	str = document.getElementById("ArtWorkImageNext" + iImagePos).src;
	//str = str.replace("localhost/Hitplays", "www.hitplays.com");	// testing only!!!!!!
	document.getElementById("ArtWorkImage" + iImagePos).src = str;
	
	pos = document.getElementById("ArtWorkImageNext" + iImagePos).src.lastIndexOf("/");
	if ( pos != -1 )
	{
		str = unescape(document.getElementById("ArtWorkImageNext" + iImagePos).src.substr(pos+1));
	
		// alt
		str = str.replace(".jpg", "");
		str = str.replace("amp", "&");
		document.getElementById("ArtWorkImage" + iImagePos).alt = str;
	
		// href
		iArrPos = FindArrayPosition(str  + ".jpg");
		sSeriesNum = "";
		if (iArrPos > 0)
			sSeriesNum = arrArtWorkSeriesNums[iArrPos];
		if (sSeriesNum != "")
			// link to series instead of show
			document.getElementById("ArtWorkLink" + iImagePos).href = "default.aspx?pg=sersl&serc=" + sSeriesNum;
		else
			document.getElementById("ArtWorkLink" + iImagePos).href = "default.aspx?pg=sd&st=" + escape(str);
	}
	else
	{
		document.getElementById("ArtWorkImage" + iImagePos).alt = "";
		document.getElementById("ArtWorkLink" + iImagePos).href = "";
	}
}

function UpdateOnDeckImage(iNewImage, iImagePos)
{
	var str;

	if ( iNewImage > arrArtWorks.length-1 )
		iNewImage = iNewImage - arrArtWorks.length;
	while ( sOnDeckImages.indexOf(arrArtWorks[iNewImage]) != -1 )	// while new image was on deck last time
	{
		iNewImage++;
		if ( iNewImage > arrArtWorks.length-1 )
			iNewImage = iNewImage - arrArtWorks.length;
	}

	// src
	pos = document.getElementById("ArtWorkImageNext" + iImagePos).src.indexOf("/ArtWork/");
	str = document.getElementById("ArtWorkImageNext" + iImagePos).src.substr(0, pos) + "/ArtWork/" + escape(arrArtWorks[iNewImage]);
	//str = str.replace("localhost/Hitplays", "www.hitplays.com");	// testing only!!!!!!
	document.getElementById("ArtWorkImageNext" + iImagePos).src = str;
	
	// alt
	//str = arrArtWorks[iNewImage].replace(".jpg", "");
	//str = str.replace("amp", "&");
	//document.getElementById("ArtWorkImage" + iImagePos).alt = str;
	
	// href
	//document.getElementById("ArtWorkLink" + iImagePos).href = "default.aspx?pg=sd&st=" + escape(str);
}

function LeftLinkMouseOver(obj)
{
	//obj.style.backgroundColor = "#336699";
	//obj.style.borderColor = "#003366";
	//obj.style.backgroundColor = "#99ccff";
	if (siteName == "brookpub")
	{
		obj.style.backgroundColor = "#dcdcdc";
		obj.style.color = "#0000ff";
		//obj.style.borderColor = "#663300";
	}
	else
	{
		obj.style.backgroundColor = "#777763";
		obj.style.borderColor = "#777763";
	}
}

function LeftLinkMouseOut(obj)
{
	//obj.style.backgroundColor = "#669999";
	//obj.style.borderColor = "#669999";
	if (siteName == "brookpub")
	{
		obj.style.backgroundColor = "#b9b9b9";
		obj.style.color = "#C1161C";
		//obj.style.borderColor = "#663300";
	}
	else
	{
		obj.style.backgroundColor = "#35352c";
		obj.style.borderColor = "#35352c";
	}
}

function TopLinkMouseOver(idCell, idLink)
{
	//alert(id);
	//var objCell = document.getElementById(idCell);
	var objLink = document.getElementById(idLink);
	//objCell.style.backgroundColor = "#5DAFA9";
	//objCell.style.borderColor = "#CCCCCC";

	////objCell.style.backgroundColor = "#5DAFA9";
	//objCell.style.backgroundColor = "#599480";
	//objCell.style.borderColor = "#333333";
	//objLink.style.color = "#ffffff";

	//objCell.style.backgroundColor = "#5DAFA9";
	//objCell.style.backgroundColor = "#599480";
	//objCell.style.borderColor = "#333333";

	objLink.style.color = "#ffffff";
	//objLink.style.color = "#5DAFA9";
}

function TopLinkMouseOut(idCell, idLink)
{
	//var objCell = document.getElementById(idCell);
	var objLink = document.getElementById(idLink);
	//objCell.style.backgroundColor = "#397470";
	//objCell.style.borderColor = "#397470";
	objLink.style.color = "#d8c550";
}

function BodyLinkMouseOver(obj)
{
	obj.style.textDecoration = "underline";
}

function BodyLinkMouseOut(obj)
{
	obj.style.textDecoration = "none";
}

function mOvr(obj)
{
	obj.style.textDecoration = "underline";
}

function mOut(obj)
{
	obj.style.textDecoration = "none";
}

function AuthorNavBarMouseOver(obj)
{
	obj.style.backgroundColor = "#35352c";
	obj.style.color = "#FFFFFF";
}

function AuthorNavBarMouseOut(obj)
{
	obj.style.backgroundColor = "#FFFFFF";
	if (siteName == "brookpub")
		obj.style.color = "#021F57";
	else
		obj.style.color = "#000000";
}

function ButtonMouseOver(obj)
{
	obj.style.cursor="hand";
}

function ButtonMouseOut(obj)
{
	obj.style.cursor="default";
}

function TitleFindClick()
{
	//alert(document.theForm.FindTitle.value);
	document.theForm.FindTitle.value = TrimString(document.theForm.FindTitle.value);
	
	if (document.theForm.FindTitle.value.length > 4)
		if (document.theForm.FindTitle.value.substr(0, 4).toLowerCase() == "the ")
			document.theForm.FindTitle.value = document.theForm.FindTitle.value.substr(4);
	if (document.theForm.FindTitle.value.length > 2)
		if (document.theForm.FindTitle.value.substr(0, 2).toLowerCase() == "a ")
			document.theForm.FindTitle.value = document.theForm.FindTitle.value.substr(2);
	
	if ( document.theForm.FindTitle.value.length < 3 )
	{
		alert("Please enter a show title of at least 3 characters");
		//document.theForm.FindTitle.value = "";
		document.theForm.FindTitle.focus();
		return;
	}
	if (!ValidChars(document.theForm.FindTitle))
		return;
	//document.theForm.action = "?pg=fr";
	document.theForm.action = "default.aspx?pg=fr-t";
	document.theForm.submit();
}

function SearchBoxTitle()
{
	//alert("*" + document.theForm.SearchBoxTitle.value + "*");
	document.theForm.SearchBoxTitle.value = TrimString(document.theForm.SearchBoxTitle.value);
	if (document.theForm.SearchBoxTitle.value.length > 4)
		if (document.theForm.SearchBoxTitle.value.substr(0, 4).toLowerCase() == "the ")
			document.theForm.SearchBoxTitle.value = document.theForm.SearchBoxTitle.value.substr(4);
	if (document.theForm.SearchBoxTitle.value.length > 2)
		if (document.theForm.SearchBoxTitle.value.substr(0, 2).toLowerCase() == "a ")
			document.theForm.SearchBoxTitle.value = document.theForm.SearchBoxTitle.value.substr(2);
	//alert("*" + document.theForm.SearchBoxTitle.value + "*");

	if (!ValidChars(document.theForm.SearchBoxTitle))
		return;
	
	if ( document.theForm.SearchBoxTitle.value.length < 3 )
	{
		alert("Please enter a show title of at least 3 characters");
		document.theForm.SearchBoxTitle.focus();
		//return;
	}
	else
	{
		document.theForm.action = "default.aspx?pg=fr-t";
		document.theForm.submit();
	}
}

function AuthorFindClick()
{
	if ( document.theForm.FindAuthor.value.length < 2 )
	{
		alert("Please enter an author name of at least 2 characters");
		document.theForm.FindAuthor.focus();
		return;
	}

	if (!ValidChars(document.theForm.FindAuthor))
		return;

	document.theForm.action = "default.aspx?pg=fr-a";
	document.theForm.submit();
}

function MultipleFieldsFindClick(obj)
{
	//alert("FindGenre=" + document.theForm.FindGenre.value);
	//alert("FindFemaleMin=" + document.theForm.FindFemaleMin.value);
	//alert("FindFemaleMax=" + document.theForm.FindFemaleMax.value);
	//alert("FindMaleMin=" + document.theForm.FindMaleMin.value);
	//alert("FindMaleMax=" + document.theForm.FindMaleMax.value);
	//alert("FindTotalMin=" + document.theForm.FindTotalMin.value);
	//alert("FindTotalMax=" + document.theForm.FindTotalMax.value);

	document.theForm.FindFemaleMin.value = document.theForm.FindFemaleMin.value.replace(" ", "");
	document.theForm.FindFemaleMax.value = document.theForm.FindFemaleMax.value.replace(" ", "");
	document.theForm.FindMaleMin.value = document.theForm.FindMaleMin.value.replace(" ", "");
	document.theForm.FindMaleMax.value = document.theForm.FindMaleMax.value.replace(" ", "");
	document.theForm.FindTotalMin.value = document.theForm.FindTotalMin.value.replace(" ", "");
	document.theForm.FindTotalMax.value = document.theForm.FindTotalMax.value.replace(" ", "");
	
	if ( !ValidNumber(document.theForm.FindFemaleMin) )
		return;
	if ( !ValidNumber(document.theForm.FindFemaleMax) )
		return;
	if ( !ValidNumber(document.theForm.FindMaleMin) )
		return;
	if ( !ValidNumber(document.theForm.FindMaleMax) )
		return;
	if ( !ValidNumber(document.theForm.FindTotalMin) )
		return;
	if ( !ValidNumber(document.theForm.FindTotalMax) )
		return;
	
	if ( document.theForm.FindGenre.value == "" &&
			document.theForm.FindShowType.value == "" &&
			document.theForm.FindTheme.value == "" &&
			document.theForm.FindRunningTime.value == "" &&
			document.theForm.FindFemaleMin.value.length == 0 &&
			document.theForm.FindFemaleMax.value.length == 0 &&
			document.theForm.FindMaleMin.value.length == 0 &&
			document.theForm.FindMaleMax.value.length == 0 &&
			document.theForm.FindTotalMin.value.length == 0 &&
			document.theForm.FindTotalMax.value.length == 0 )
	{
		alert("Please enter search criteria.");
		return;
	}

	var intMin;
	var intMin2;
	var intMax;
	var intMax2;
	if ( document.theForm.FindFemaleMin.value.length > 0 && document.theForm.FindFemaleMax.value.length > 0 )
	{
		intMin = parseInt(document.theForm.FindFemaleMin.value);
		intMax = parseInt(document.theForm.FindFemaleMax.value);
		if ( intMin > intMax )
		{
			alert("The female minimum must not be greater than the female maximum.");
			return;
		}
	}
	if ( document.theForm.FindMaleMin.value.length > 0 && document.theForm.FindMaleMax.value.length > 0 )
	{
		intMin = parseInt(document.theForm.FindMaleMin.value);
		intMax = parseInt(document.theForm.FindMaleMax.value);
		if ( intMin > intMax )
		{
			alert("The male minimum must not be greater than the male maximum.");
			return;
		}
	}
	if ( document.theForm.FindTotalMin.value.length > 0 && document.theForm.FindTotalMax.value.length > 0 )
	{
		intMin = parseInt(document.theForm.FindTotalMin.value);
		intMax = parseInt(document.theForm.FindTotalMax.value);
		if ( intMin > intMax )
		{
			alert("The total minimum must not be greater than the total maximum.");
			return;
		}
	}

	intMaleFemaleMin = 0;
	intMaleFemaleMax = 0;
	intTotalMin = 0;
	intTotalMax = 0;
	if ( document.theForm.FindFemaleMin.value.length > 0 )
		intMaleFemaleMin += parseInt(document.theForm.FindFemaleMin.value);
	if ( document.theForm.FindMaleMin.value.length > 0 )
		intMaleFemaleMin += parseInt(document.theForm.FindMaleMin.value);
	//alert("intMaleFemaleMin=" + intMaleFemaleMin);
	if ( document.theForm.FindFemaleMax.value.length > 0 )
		intMaleFemaleMax += parseInt(document.theForm.FindFemaleMax.value);
	if ( document.theForm.FindMaleMax.value.length > 0 )
		intMaleFemaleMax += parseInt(document.theForm.FindMaleMax.value);
	//alert("intMaleFemaleMax=" + intMaleFemaleMax);
	if ( document.theForm.FindTotalMin.value.length > 0 )
		intTotalMin = parseInt(document.theForm.FindTotalMin.value);
	//alert("intTotalMin=" + intTotalMin);
	if ( document.theForm.FindTotalMax.value.length > 0 )
		intTotalMax = parseInt(document.theForm.FindTotalMax.value);
	//alert("intTotalMax=" + intTotalMax);
	
	document.theForm.action = "default.aspx?pg=fr-m";
	document.theForm.submit();
}

function ValidNumber(obj)
{
	if (obj.value.length > 0)
		if (isNaN(obj.value))
		{
			alert("Invalid entry: " + obj.value + " , only numbers allowed, please correct.");
			obj.focus();
			return false;
		}
	return true;
}

function ValidChars(obj)
{
	return ValidCharsPlus(obj, "");
}

function ValidAuthorChars(obj)
{
	var validChars = ValidCharsPlus(obj, "<>/\";");
	if (!validChars)
		return false;

	// check for invalid HTML
	var str = obj.value.toLowerCase();
	str = str.replace("<i>", "");
	str = str.replace("</i>", "");
	str = str.replace("<b>", "");
	str = str.replace("</b>", "");
	str = str.replace("<p>", "");
	str = str.replace("</p>", "");
	str = str.replace("<br>", "");
	str = str.replace("<br/>", "");
	str = str.replace("<br />", "");
	
	var badChar = "";
	if (str.indexOf("<") != -1)
		badChar = "<";
	else if (str.indexOf(">") != -1)
		badChar = ">";
	else if (str.indexOf("/") != -1)
		badChar = "/";

	if (badChar == "")
		return true;

	alert("Please remove the " + badChar + " character from your entry. This character is only allowed when used with the supported text formatting.");
	obj.focus();
	return false;
}

function ValidCharsPlus(obj, extraChars)
{
	if (obj.value.length == 0)
		return true;

	var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '-!$%,.?@#():_";
	validChars += extraChars;
	var c, ix;

	for (ix = 0; ix < obj.value.length; ix++)
	{
		c = obj.value.charAt(ix);
		if (validChars.indexOf(c) == -1)
		{
			if (c == "\n" || c == "\r" || c == "\t")
			//	alert("Please do not press the ENTER or TAB keys when entering your text.");
			//else
				continue;
			alert("Please remove the following character from your entry: " + c);
			obj.focus();
			return false;
		}
	}

	return true;
}

function CommissionedWorkCategoryClick(showTypeCode)
{
	document.theForm.action = "default.aspx?pg=a-cwo&stc=" + showTypeCode;
	document.theForm.submit();
}

function cwCategoryClickLogin(showTypeCode)
{
	document.theForm.action = "default.aspx?pg=a-cwli&stc=" + showTypeCode;
	document.theForm.submit();
}

function CommissionedWorkRegisterInterest(showId)
{
	document.theForm.action = "default.aspx?pg=a-cwri&p=" + showId;
	document.theForm.submit();
}

function RegisterIdeaDesc()
{
	if ( document.theForm.RegisterIdeaDesc.value.length < 10 )
	{
		alert("Please enter your description of interest");
		document.theForm.RegisterIdeaDesc.focus();
		return;
	}

	if (!ValidChars(document.theForm.RegisterIdeaDesc))
		return;

	document.theForm.action = "default.aspx?pg=a-cwris";
	document.theForm.submit();
}

function AuthorSignIn()
{
	if ( document.theForm.AuthorEmail.value.length < 1 )
	{
		alert("Please enter your email address");
		document.theForm.AuthorEmail.focus();
		return;
	}
	if ( document.theForm.AuthorPassword.value.length == 0 )
	{
		alert("Please enter your password");
		document.theForm.AuthorPassword.focus();
		return;
	}

	if (!ValidCharsPlus(document.theForm.AuthorEmail, "_"))
		return;
	if (!ValidChars(document.theForm.AuthorPassword))
		return;
	
	//alert("LinkPath=" + LinkPath);
	//document.theForm.action = LinkPath + "?pg=au";
	document.theForm.action = "default.aspx?pg=a-v";
	document.theForm.submit();
}

function AuthorForgotPassword()
{
	if ( document.theForm.AuthorEmail.value.length < 1 )
	{
		alert("Please enter your email address");
		document.theForm.AuthorEmail.focus();
		return;
	}
	if (!ValidCharsPlus(document.theForm.AuthorEmail, "_"))
		return;
	
	document.theForm.action = "default.aspx?pg=a-fp";
	document.theForm.submit();
}

function NewAuthor(obj)
{
	document.theForm.NewAuthor.value = "y";
	document.theForm.action = "default.aspx?pg=a-ci";
	document.theForm.submit();
}

function AuthorContactInfoUpdate(NewAuthor)
{
	if ( NewAuthor == "y" )
	{
		if ( document.theForm.AuthorFirstName.value.length < 1 )
		{
			alert("Please enter your first name");
			document.theForm.AuthorFirstName.focus();
			return;
		}
		if ( document.theForm.AuthorLastName.value.length < 1 )
		{
			alert("Please enter your last name");
			document.theForm.AuthorLastName.focus();
			return;
		}
		if (!ValidChars(document.theForm.AuthorFirstName))
			return;
		if (!ValidChars(document.theForm.AuthorLastName))
			return;
	}
	
	if ( document.theForm.AuthorEmail.value.length < 1 )
	{
		alert("Please enter your email address");
		document.theForm.AuthorEmail.focus();
		return;
	}
	if (!ValidCharsPlus(document.theForm.AuthorEmail, "_"))
		return;
	if (document.theForm.AuthorPassword.value.length == 0)
	{
		alert("Please enter your password");
		document.theForm.AuthorPassword.focus();
		return;
	}
	if (!ValidChars(document.theForm.AuthorPassword))
		return;
	if (document.theForm.AuthorAddress.value.length == 0)
	{
		alert("Please enter your address");
		document.theForm.AuthorAddress.focus();
		return;
	}
	if (!ValidChars(document.theForm.AuthorAddress))
		return;
	if (document.theForm.AuthorCity.value.length == 0)
	{
		alert("Please enter your city");
		document.theForm.AuthorCity.focus();
		return;
	}
	if (!ValidChars(document.theForm.AuthorCity))
		return;
	if (document.theForm.AuthorCountry.value == "United States" || document.theForm.AuthorCountry.value == "Canada")
	{
		if ( document.theForm.AuthorState.value.length == 0 )
		{
			alert("Please select a state/province.");
			document.theForm.AuthorState.focus();
			return;
		}
	}
	else
	{
		if ( document.theForm.AuthorState.value.length != 0 )
		{
			alert("Conflicting state/province and country selection made.\nPlease select 'None' for state/province if outside USA and Canada.");
			document.theForm.AuthorState.focus();
			return;
		}
	}
	if ( document.theForm.AuthorZip.value.length == 0 )
	{
		alert("Please enter your zip/postal code");
		document.theForm.AuthorZip.focus();
		return;
	}
	if (!ValidChars(document.theForm.AuthorZip))
		return;

	document.theForm.AuthorHomePhone.value = document.theForm.AuthorHomePhone.value.replace(" ", "");
	document.theForm.AuthorWorkPhone.value = document.theForm.AuthorWorkPhone.value.replace(" ", "");
	document.theForm.AuthorCellPhone.value = document.theForm.AuthorCellPhone.value.replace(" ", "");
	if (document.theForm.AuthorHomePhone.value.length == 0)
	{
		if (document.theForm.AuthorWorkPhone.value.length == 0)
		{
			if (document.theForm.AuthorCellPhone.value.length == 0)
			{
				alert("Please enter at least 1 phone number");
				return;
			}
		}
	}
	if (!ValidChars(document.theForm.AuthorHomePhone))
		return;
	if (!ValidChars(document.theForm.AuthorWorkPhone))
		return;
	if (!ValidChars(document.theForm.AuthorCellPhone))
		return;

	// validate ssn
	//var ssn = document.theForm.AuthorSsn1.value + document.theForm.AuthorSsn2.value + document.theForm.AuthorSsn3.value;
	var ssn = "";
	if (ssn.length != 0 && ssn.length != 9)
	{
		alert("Please enter 9 numbers for your social security number");
		document.theForm.AuthorSsn1.focus();
		return;
	}
	if ( ssn.length == 9 )
	{
		if ( isNaN(ssn) )
		{
			alert("Invalid social security number, only numbers allowed, please correct.");
			document.theForm.AuthorSsn1.focus();
			return;
		}
	}

	// validate tax id
	//var taxid = document.theForm.AuthorTaxId1.value + document.theForm.AuthorTaxId2.value;
	var taxid = "";
	if (taxid.length != 0 && taxid.length != 9)
	{
		alert("Please enter 9 numbers for your Federal Tax ID");
		document.theForm.AuthorTaxId1.focus();
		return;
	}
	if ( taxid.length == 9 )
	{
		if ( isNaN(taxid) )
		{
			alert("Invalid Federal Tax ID, only numbers allowed, please correct.");
			document.theForm.AuthorTaxId1.focus();
			return;
		}
	}

	document.theForm.action = "default.aspx?pg=a-ciu";
	document.theForm.submit();
	return false;
}

function AuthorBioSave(obj)
{
	if ( document.theForm.AuthorBio.value.length < 1 )
	{
		alert("Please enter your biography");
		document.theForm.AuthorBio.focus();
		return;
	}
	if (document.theForm.AuthorBio.value.length > 100000)
	{
		alert("Biography too long");
		document.theForm.AuthorBio.focus();
		return;
	}
	//if (!ValidAuthorChars(document.theForm.AuthorBio))
	//	return;
	//if (!ValidCharsPlus(document.theForm.AuthorBioHomePage, "/"))
	//	return;
	document.theForm.action = "default.aspx?pg=a-bu";
	document.theForm.submit();
}

function AuthorBioPreview(obj)
{
	if (document.theForm.AuthorBio.value.length < 1)
	{
		alert("Please enter your biography");
		document.theForm.AuthorBio.focus();
		return;
	}
	if (document.theForm.AuthorBio.value.length > 100000)
	{
		alert("Biography too long");
		document.theForm.AuthorBio.focus();
		return;
	}
	//if (!ValidAuthorChars(document.theForm.AuthorBio))
	//	return;
	//document.theForm.AuthorBio.value = escape(document.theForm.AuthorBio.value);
	document.theForm.action = "default.aspx?pg=a-bp";
	document.theForm.submit();
}

function AuthorBioPreviewHide(obj)
{
	if (document.theForm.AuthorBio.value.length > 100000)
	{
		alert("Biography too long");
		document.theForm.AuthorBio.focus();
		return;
	}
	//if (!ValidAuthorChars(document.theForm.AuthorBio))
	//	return;
	document.theForm.action = "default.aspx?pg=a-b";
	document.theForm.submit();
}

function UploadAuthorPic()
{
	if ( document.theForm.AuthorPic.value.length == 0 )
	{
		alert("Please enter an image file name to upload.");
		return;
	}
	// prevent auto population of control after submit
	//document.theForm.PdfFile2.value = document.theForm.PdfFile.value;
	//document.theForm.PdfFile.value = "";
	document.theForm.action = "default.aspx?pg=a-pu";
	document.theForm.submit();
}

function AuthorSubmitShowUpdate(obj)
{
	var title;

	if ( document.theForm.AuthorSubmitTitle.value.length < 1 )
	{
		alert("Please enter the show title.");
		document.theForm.AuthorSubmitTitle.focus();
		return;
	}
	if (!ValidChars(document.theForm.AuthorSubmitTitle))
		return;

	title = document.theForm.AuthorSubmitTitle.value;
	if ( title.indexOf("/") != -1 ||
		title.indexOf("\\") != -1 ||
		title.indexOf(":") != -1 ||
		//title.indexOf(".") != -1 ||
		title.indexOf("*") != -1 ||
		//title.indexOf("?") != -1 ||
		title.indexOf("&") != -1 ||
		title.indexOf("\"") != -1 ||
		title.indexOf("<") != -1 ||
		title.indexOf(">") != -1 ||
		title.indexOf("|") != -1 )
	{
		alert("The following characters are not allowed in show titles:\n     &  /  \\  :  *  \"  <  >  |");
		document.theForm.AuthorSubmitTitle.focus();
		return;
	}

	//if ( document.theForm.AuthorSubmitRunningTime.value.length < 1 )
	//{
	//	alert("Please enter the running time.");
	//	document.theForm.AuthorSubmitRunningTime.focus();
	//	return;
	//}
	if ( !ValidNumber(document.theForm.AuthorSubmitRunningTime) )
	{
		document.theForm.AuthorSubmitRunningTime.focus();
		return;
	}

	//if ( document.theForm.AuthorSubmitFemales.value.length < 1 )
	//{
	//	alert("Please enter the number of females in the show.");
	//	document.theForm.AuthorSubmitFemales.focus();
	//	return;
	//}
	if ( !ValidNumber(document.theForm.AuthorSubmitFemales) )
	{
		document.theForm.AuthorSubmitFemales.focus();
		return;
	}

	//if ( document.theForm.AuthorSubmitMales.value.length < 1 )
	//{
	//	alert("Please enter the number of males in the show.");
	//	document.theForm.AuthorSubmitMales.focus();
	//	return;
	//}
	if ( !ValidNumber(document.theForm.AuthorSubmitMales) )
	{
		document.theForm.AuthorSubmitMales.focus();
		return;
	}
	if ( !ValidNumber(document.theForm.AuthorSubmitMales) )
	{
		document.theForm.AuthorSubmitMales.focus();
		return;
	}
	if ( !ValidNumber(document.theForm.AuthorSubmitExtrasNum) )
	{
		document.theForm.AuthorSubmitExtrasNum.focus();
		return;
	}
	if (document.theForm.AuthorSubmitSynopsis.value.length < 1)
	{
		alert("Please enter the synopsis.");
		document.theForm.AuthorSubmitSynopsis.focus();
		return;
	}
	if (document.theForm.AuthorSubmitSynopsis.value.length > 100000)
	{
		alert("Synopsis too long");
		document.theForm.AuthorSubmitSynopsis.focus();
		return;
	}
	//if (!ValidAuthorChars(document.theForm.AuthorSubmitSynopsis))
	//	return;

	if ( document.theForm.AuthorSubmitGenre1.value == "none" )
	{
		alert("Please select a first genre");
		document.theForm.AuthorSubmitGenre1.focus();
		return;
	}

	//if (!ValidChars(document.theForm.AuthorSubmitProductionHistory))
	//	return;

	document.theForm.action = "default.aspx?pg=a-ssu";
	//document.theForm.target = "";
	document.theForm.submit();
}

function AuthorSubmitSynopsisPreview(obj)
{
	if ( document.theForm.AuthorSubmitSynopsis.value.length < 1 )
	{
		alert("Please enter the synopsis.");
		document.theForm.AuthorSubmitSynopsis.focus();
		return;
	}
	if (document.theForm.AuthorSubmitSynopsis.value.length > 100000)
	{
		alert("Synopsis too long");
		document.theForm.AuthorSubmitSynopsis.focus();
		return;
	}
	//if (!ValidChars(document.theForm.AuthorSubmitSynopsis))
	//	return;

	//document.theForm.action = "preview.asp?m=syn";
	//document.theForm.target = "_blank";
	document.theForm.action = "default.aspx?pg=a-ssp#preview";
	document.theForm.submit();
}

function AuthorSubmitSynopsisPreviewHide(obj)
{
	if (document.theForm.AuthorSubmitSynopsis.value.length > 100000)
	{
		alert("Synopsis too long");
		document.theForm.AuthorSubmitSynopsis.focus();
		return;
	}
	document.theForm.action = "default.aspx?pg=a-ss#preview";
	document.theForm.submit();
}

function AuthorComment(sTitle)
{
	if (document.theForm.AuthorComment.value.length > 100000)
	{
		alert("Author notes too long");
		document.theForm.AuthorComment.focus();
		return;
	}
	document.theForm.AuthorCommentTitle.value = sTitle;
	document.theForm.AuthorComment.value = "";
	document.theForm.action = "default.aspx?pg=a-c";
	document.theForm.submit();
}

function AuthorCommentPreview(obj)
{
	if ( document.theForm.AuthorComment.value.length < 1 )
	{
		alert("Please enter the author comment text.");
		document.theForm.AuthorComment.focus();
		return;
	}
	if ( document.theForm.AuthorComment.value.length > 100000 )
	{
		alert("Author notes too long");
		document.theForm.AuthorComment.focus();
		return;
	}
	//if (!ValidAuthorChars(document.theForm.AuthorComment))
	//	return;
	document.theForm.action = "default.aspx?pg=a-cp";
	document.theForm.submit();
}

function AuthorCommentPreviewHide(obj)
{
	if (document.theForm.AuthorComment.value.length > 100000)
	{
		alert("Author notes too long");
		document.theForm.AuthorComment.focus();
		return;
	}
	document.theForm.action = "default.aspx?pg=a-c";
	document.theForm.submit();
}

function AuthorCommentUpdate(obj)
{
	if ( document.theForm.AuthorComment.value.length < 1 )
	{
		alert("Please enter the author comment text.");
		document.theForm.AuthorComment.focus();
		return;
	}
	if (document.theForm.AuthorComment.value.length > 100000)
	{
		alert("Author notes too long");
		document.theForm.AuthorComment.focus();
		return;
	}
	//if (!ValidAuthorChars(document.theForm.AuthorComment))
	//	return;

	document.theForm.action = "default.aspx?pg=a-cu";
	document.theForm.submit();
}

function AuthorArtWork(sTitle)
{
	document.theForm.ArtWorkTitle.value = sTitle;
	document.theForm.action = "default.aspx?pg=a-aw";
	document.theForm.submit();
}

function UploadArtWork()
{
	if ( document.theForm.AuthorSubmitArtWork.value.length == 0 )
	{
		alert("Please enter an image file name to upload.");
		return;
	}
	// prevent auto population of control after submit
	//document.theForm.PdfFile2.value = document.theForm.PdfFile.value;
	//document.theForm.PdfFile.value = "";
	document.theForm.action = "default.aspx?pg=a-awu";
	document.theForm.submit();
}

function AuthorPlayPhoto(sTitle)
{
	document.theForm.PhotoPlayTitle.value = sTitle;
	document.theForm.action = "default.aspx?pg=a-pp";
	document.theForm.submit();
}

function UploadPlayPhoto()
{
	if (document.theForm.AuthorSubmitPlayPhoto.value.length == 0)
	{
		alert("Please enter an image file name to upload.");
		return;
	}
	// prevent auto population of control after submit
	//document.theForm.PdfFile2.value = document.theForm.PdfFile.value;
	//document.theForm.PdfFile.value = "";
	document.theForm.action = "default.aspx?pg=a-ppu";
	document.theForm.submit();
}

function AuthorRoyaltyYearChange(obj)
{
	document.theForm.action = "default.aspx?pg=a-rr";
	document.theForm.submit();
}

function AuthorShowPerformancesYearChange(obj)
{
	document.theForm.action = "default.aspx?pg=a-spr";
	document.theForm.submit();
}

function SubmitPlayComment()
{
	if ( document.theForm.CommentTitle.value == 0 )
	{
		alert("Please select the title.");
		document.theForm.CommentTitle.focus();
		return;
	}
	if (!ValidChars(document.theForm.CommentTitle))
		return;

	if (document.theForm.CommentText.value.length < 15)
	{
		alert("Please enter your comments.");
		document.theForm.CommentText.focus();
		return;
	}
	if (!ValidChars(document.theForm.CommentText))
		return;

	if (document.theForm.CommentName.value.length < 5)
	{
		alert("Please enter your first and last name.");
		document.theForm.CommentName.focus();
		return;
	}
	if (!ValidChars(document.theForm.CommentName))
		return;

	if (document.theForm.CommentCity.value.length < 3)
	{
		alert("Please enter your city.");
		document.theForm.CommentCity.focus();
		return;
	}
	if (!ValidChars(document.theForm.CommentCity))
		return;

	// what if user is international? - if required, need to add an international option
	//if (document.theForm.CommentState.value.length < 2)
	//{
	//	alert("Please enter your state.");
	//	document.theForm.CommentState.focus();
	//	return;
	//}
	//if (!ValidChars(document.theForm.CommentState))
	//	return;

	if (document.theForm.CommentEmail.value.length < 8)
	{
		alert("Please enter your email address.");
		document.theForm.CommentEmail.focus();
		return;
	}
	if (!ValidChars(document.theForm.CommentEmail))
		return;

	if (document.theForm.CommentText.value.length > 5000)
	{
		alert("Please limit your comment to 5000 characters. Your comments are currently " + document.theForm.CommentText.value.length + " characters.");
		document.theForm.CommentText.focus();
		return;
	}

	document.theForm.action = "default.aspx?pg=pcu";
	document.theForm.submit();
}

function SubmitPlayPhoto()
{
	if (document.theForm.UploadPhotoTitle.value == 0)
	{
		alert("Please select a play.");
		document.theForm.UploadPhotoTitle.focus();
		return;
	}
	if (!ValidChars(document.theForm.UploadPhotoTitle))
		return;

	//if (document.theForm.UploadPhotoEmail.value.length < 8)
	//{
	//	alert("Please enter your email address.");
	//	document.theForm.UploadPhotoEmail.focus();
	//	return;
	//}
	//if (!ValidChars(document.theForm.UploadPhotoEmail))
	//	return;
	//if (!ValidEmail(document.theForm.UploadPhotoEmail.value))
	//{
	//	alert("Invalid email address.");
	//	return;
	//}

	if (document.theForm.UploadPhotoOrg.value.length == 0)
	{
		alert("Please enter your organization/school name.");
		document.theForm.UploadPhotoOrg.focus();
		return;
	}
	if (!ValidChars(document.theForm.UploadPhotoOrg))
		return;

	//if (document.theForm.UploadPhotoCaption.value.length < 6)
	//{
	//	alert("Please enter a play caption.");
	//	document.theForm.UploadPhotoCaption.focus();
	//	return;
	//}
	if (!ValidChars(document.theForm.UploadPhotoCaption))
		return;
	if (document.theForm.UploadPhotoCaption.value.length > 200)
	{
		alert("Please limit your photo description to 200 characters. Your description is currently " + document.theForm.UploadPhotoCaption.value.length + " characters.");
		document.theForm.UploadPhotoCaption.focus();
		return;
	}

	document.theForm.action = "default.aspx?pg=phupu";
	document.theForm.submit();
}

function ShoppingCartDelete(ShowTitle)
{
	var OK = confirm("Are you sure you want to remove this show from your shopping cart?");
	if ( !OK )
		return;
	SubmitTheForm("default.aspx?pg=sc-d&st=" + ShowTitle);
}

function ShoppingCartUpdate(CartCount, sAction)
{
	var sc;
	var qty;
	var Perform1 = 0;
	
	for ( sc=1; sc<=CartCount; sc++ )
	{
		qty = "qty_" + sc;
		if ( document.theForm[qty] != null )
		{
			//alert(document.theForm[qty].value);
			if ( document.theForm[qty].value.length < 1 )
				document.theForm[qty].value = 0;
			if ( !ValidNumber(document.theForm[qty]) )
				return;
		}
		qty = "qty_p1_" + sc;
		if ( document.theForm[qty] != null )
		{
			if ( document.theForm[qty].value.length < 1 )
				document.theForm[qty].value = 0;
			if ( !ValidNumber(document.theForm[qty]) )
				return;
			// Perform1 product: only valid entry is 0 or 1
			if ( document.theForm[qty].value != 0 && document.theForm[qty].value != 1 )
			{
				//alert("Please do not enter more than 1 for the First Performance Royalty quantity.\nFor more than 1 performance, enter a value in the Each Additional Performance quantity.\n\nFor example, if you will have 4 performances, enter 1 in the First Performance Royalty quantity\nand enter 3 in the Each Additional Performance quantity.");
				alert("Please do not enter more than 1 for the First Performance Royalty quantity.\n\nFor more than 1 performance, enter the number of additional performances\nin the Each Additional Performance quantity.");
				document.theForm[qty].focus();
				return;
			}
			if ( document.theForm[qty].value == 1 )
			{
				if ( document.theForm["p1_month_" + sc].value == "00" )
				{
					alert("Please select the first performance date's month.");
					document.theForm["p1_month_" + sc].focus();
					return;
				}
				if ( document.theForm["p1_day_" + sc].value == "00" )
				{
					alert("Please select the first performance date's day.");
					document.theForm["p1_day_" + sc].focus();
					return;
				}
				if ( !VerifyDay(document.theForm["p1_month_" + sc].value, document.theForm["p1_day_" + sc].value, document.theForm["p1_year_" + sc].value) )
				{
					alert("Invalid performance day selected, please correct.");
					document.theForm["p1_day_" + sc].focus();
					return;
				}
			}
			Perform1 = document.theForm[qty].value;
		}
		qty = "qty_pa_" + sc;
		if ( document.theForm[qty] != null )
		{
			if ( document.theForm[qty].value.length < 1 )
				document.theForm[qty].value = 0;
			if ( !ValidNumber(document.theForm[qty]) )
				return;
			if ( document.theForm[qty].value > 0 && Perform1 == 0 )
			{
				alert("For multiple performances, please enter 1 for First Performance Royalty\nand the rest in Each Additional Performance.");
				document.theForm[qty].focus();
				return;
			}
		}
		qty = "qty_vr_" + sc;
		if ( document.theForm[qty] != null )
		{
			if ( document.theForm[qty].value.length < 1 )
				document.theForm[qty].value = 0;
			if ( !ValidNumber(document.theForm[qty]) )
				return;
			// Video Rights product: only valid entry is 0 or 1
			if ( document.theForm[qty].value != 0 && document.theForm[qty].value != 1 )
			{
				alert("The maximum needed quantity for Video rights is 1.");
				document.theForm[qty].focus();
				return;
			}
		}
		qty = "qty_aid_" + sc;
		if ( document.theForm[qty] != null )
		{
			if ( document.theForm[qty].value.length < 1 )
				document.theForm[qty].value = 0;
			if ( !ValidNumber(document.theForm[qty]) )
				return;
			// Artwork Image Download product: only valid entry is 0 or 1
			if ( document.theForm[qty].value != 0 && document.theForm[qty].value != 1 )
			{
				alert("The maximum needed quantity for Artwork Image Download is 1.");
				document.theForm[qty].focus();
				return;
			}
		}
		qty = "qty_pda_" + sc;
		if ( document.theForm[qty] != null )
		{
			if ( document.theForm[qty].value.length < 1 )
				document.theForm[qty].value = 0;
			if ( !ValidNumber(document.theForm[qty]) )
				return;
			// Play Audio download product: only valid entry is 0 or 1
			if ( document.theForm[qty].value != 0 && document.theForm[qty].value != 1 )
			{
				alert("The maximum needed quantity for Play Audio Download is 1.");
				document.theForm[qty].focus();
				return;
			}
		}
		qty = "qty_ps_" + sc;
		if ( document.theForm[qty] != null )
		{
			if ( document.theForm[qty].value.length < 1 )
				document.theForm[qty].value = 0;
			if ( !ValidNumber(document.theForm[qty]) )
				return;
			// Perusal script product: only valid entry is 0 or 1
			if ( document.theForm[qty].value != 0 && document.theForm[qty].value != 1 )
			{
				alert("The maximum needed quantity for Perusal Script Download is 1.");
				document.theForm[qty].focus();
				return;
			}
		}
	}

	//SubmitTheForm("default.aspx?pg=sc-u");
	SubmitTheForm(sAction);
}

function DeletePerform1(RowNum)
{
	var qty = "qty_p1_" + RowNum;
	//if ( document.theForm[qty] != null )
	//alert(document.theForm[qty].value);
	document.theForm[qty].value = 0;
	document.theForm[qty].focus();
}

function DeletePoster(sAction, sTitle)
{
	var OK = confirm("Are you sure you want to remove posters from your shopping cart for " + sTitle + "?");
	if ( !OK )
		return;

	SubmitTheForm(sAction);
}

function DeleteTshirt(sAction, sTitle)
{
	var OK = confirm("Are you sure you want to remove t-shirts from your shopping cart for " + sTitle + "?");
	if ( !OK )
		return;

	SubmitTheForm(sAction);
}

function PosterTitleChange(sAction)
{
	//document.theForm.PosterQty.value = "";
	//document.theForm.PosterText1.value = "";
	//document.theForm.PosterText2.value = "";
	//document.theForm.PosterText3.value = "";
	SubmitTheForm(sAction);
}

function ArtworkDownloadAddOrUpdate(sAction)
{
	SubmitTheForm(sAction);
}

function ArtworkDownloadTitleChange(sAction)
{
	SubmitTheForm(sAction);
}

function VideoRightsAddOrUpdate(sAction)
{
	if ( document.theForm.VideoRightsTitleNum.value == "0" )
	{
		alert("Please select a title to add to the cart.");
		document.theForm.VideoRightsTitleNum.focus();
		return;
	}
	SubmitTheForm(sAction);
}

function ReturnToOrdersSite(sAction)
{
	//alert(sAction);
	sAction = sAction.replace("+&+", "+%26+");
	document.theForm.action = sAction;
	document.theForm.submit();
}

function TshirtTitleChange(sAction)
{
	SubmitTheForm(sAction);
}

function TshirtTypeChange(sAction)
{
	//document.theForm.method = "get";
	SubmitTheForm(sAction);
}

function TshirtImgSizeChangeOld(sLeft, sTop, sHeight, sWidth)
{
	var sSrc1, sSrc2, iPos;

	sSrc1 = document.getElementById("TshirtArtworkImg").src;
	//alert(sSrc1);

	iPos = sSrc1.indexOf("&h=");
	sSrc2 = sSrc1.substr(0, iPos);
	sSrc2 = sSrc2 + "&h=";
	sSrc2 = sSrc2 + String(sHeight);
	sSrc2 = sSrc2 + "&w=";
	sSrc2 = sSrc2 + String(sWidth);
	
	//var dt = new Date();
	//var sec = dt.getSeconds();
	//var msec = dt.getMilliseconds();
	
	//document.getElementById("TshirtArtworkImg").style.visibility = "hidden";
	document.getElementById("TshirtArtworkImg").src = sSrc2;
	
	//alert(sLeft + "," + sTop + "," + sHeight + "," + sWidth);
	document.getElementById("TshirtArtworkImg").style.left = sLeft;
	document.getElementById("TshirtArtworkImg").style.top = sTop;

	//document.getElementById("TshirtArtworkImg").style.visibility = "visible";
}

function TshirtImgSizeChange(sSize)
{
	if ( sSize == "L" )
	{
		document.getElementById("TshirtArtworkImgSmall").style.visibility = "hidden";
		document.getElementById("TshirtArtworkImgPocket").style.visibility = "hidden";
		document.getElementById("TshirtArtworkImgLarge").style.visibility = "visible";
	}
	else if ( sSize == "S" )
	{
		document.getElementById("TshirtArtworkImgPocket").style.visibility = "hidden";
		document.getElementById("TshirtArtworkImgLarge").style.visibility = "hidden";
		document.getElementById("TshirtArtworkImgSmall").style.visibility = "visible";
	}
	else
	{
		document.getElementById("TshirtArtworkImgSmall").style.visibility = "hidden";
		document.getElementById("TshirtArtworkImgLarge").style.visibility = "hidden";
		document.getElementById("TshirtArtworkImgPocket").style.visibility = "visible";
	}
}

function TshirtBackOptionChange(sAction)
{
	SubmitTheForm(sAction);
}

function TshirtAddOrUpdateCart(sAction)
{
	if ( TshirtVerify() )
		SubmitTheForm(sAction);
}

function TshirtUpdate(sAction)
{
	if ( TshirtVerify() )
		SubmitTheForm(sAction);
}

function TshirtVerify()
{
	var x, str;
	var Qty = parseInt(0);
	var InvalidChar;
	var arrNames, NumNames;
	var YouthRequested = "";
	//var arrYouthColors;

	// check invalid characters in text entries
	InvalidChar = CheckForInvalidChar(document.theForm.elements["t-f-text1"].value);
	if ( InvalidChar != "" )
	{
		alert("Invalid character entered in text: " + InvalidChar);
		document.theForm.elements["t-f-text1"].focus();
		return;
	}
	InvalidChar = CheckForInvalidChar(document.theForm.elements["t-f-text2"].value);
	if ( InvalidChar != "" )
	{
		alert("Invalid character entered in text: " + InvalidChar);
		document.theForm.elements["t-f-text2"].focus();
		return;
	}
	InvalidChar = CheckForInvalidChar(document.theForm.elements["t-f-text3"].value);
	if ( InvalidChar != "" )
	{
		alert("Invalid character entered in text: " + InvalidChar);
		document.theForm.elements["t-f-text3"].focus();
		return;
	}
	if ( document.theForm.elements["t-b-opt"][1].checked || document.theForm.elements["t-b-opt"][2].checked )
	{
		InvalidChar = CheckForInvalidChar(document.theForm.elements["t-b-text1"].value);
		if ( InvalidChar != "" )
		{
			alert("Invalid character entered in text: " + InvalidChar);
			document.theForm.elements["t-b-text1"].focus();
			return;
		}
		if ( document.theForm.elements["t-b-opt"][1].checked )
		{
			//document.theForm.elements["t-b-names"].value = document.theForm.elements["t-b-names"].value.replace("Name One", "");
			//document.theForm.elements["t-b-names"].value = document.theForm.elements["t-b-names"].value.replace("Name Two", "");
			//document.theForm.elements["t-b-names"].value = document.theForm.elements["t-b-names"].value.replace("Name Three", "");
			//document.theForm.elements["t-b-names"].value = document.theForm.elements["t-b-names"].value.replace("etc.", "");
			//if ( document.theForm.elements["t-b-names"].value.charAt(0) == "\r" )
			//	alert("r");
			
			InvalidChar = CheckForInvalidChar(document.theForm.elements["t-b-names"].value);
			if ( InvalidChar != "" )
			{
				alert("Invalid character entered in text: " + InvalidChar);
				document.theForm.elements["t-b-names"].focus();
				return;
			}
			if ( document.theForm.elements["t-b-names"].value.indexOf(",") != -1 )
			{
				alert("Please do not enter commas in the names list");
				document.theForm.elements["t-b-names"].focus();
				return;
			}
		}
		else
		{
			InvalidChar = CheckForInvalidChar(document.theForm.elements["t-b-text2"].value);
			if ( InvalidChar != "" )
			{
				alert("Invalid character entered in text: " + InvalidChar);
				document.theForm.elements["t-b-text2"].focus();
				return;
			}
			InvalidChar = CheckForInvalidChar(document.theForm.elements["t-b-text3"].value);
			if ( InvalidChar != "" )
			{
				alert("Invalid character entered in text: " + InvalidChar);
				document.theForm.elements["t-b-text3"].focus();
				return;
			}
		}
	}
	
	// check qty
	for ( x=0; x<document.theForm.length; x++ )
	{
		if ( document.theForm.elements[x].name.length > 5 )
			if ( document.theForm.elements[x].name.substr(0, 5) == "t-ss-" ||
				document.theForm.elements[x].name.substr(0, 5) == "t-ls-" ||
				document.theForm.elements[x].name.substr(0, 5) == "t-ar-" )
			{
				document.theForm.elements[x].value = document.theForm.elements[x].value.replace(" ", "");
				if ( !TshirtVerifyQty(document.theForm.elements[x]) )
					return false;
				if ( document.theForm.elements[x].value.length > 0 )
				{
					Qty = Qty + parseInt(document.theForm.elements[x].value);
					if ( document.theForm.elements[x].name.indexOf("s-y-") != -1 )
						if ( parseInt(document.theForm.elements[x].value) > 0 )
							YouthRequested = "yes";
				}
			}
	}
	if ( Qty == 0 )
	{
		alert("Please enter your T-Shirt quantities.\n\nIf you would like to remove t-shirts from your cart, please click\nthe delete button next to t-shirts on the shopping cart page.");
		return false;
	}
	if ( Qty < 12 )
	{
		alert("Your total t-shirt quantity = " + Qty + ".\nA minimum quantity of 12 t-shirts is required, please increase.");
		return false;
	}
	
	// check for max # names in textarea
	if ( document.theForm.elements["t-b-opt"][1].checked )
	{
		NumNames = parseInt(0);
		arrNames = document.theForm.elements["t-b-names"].value.split("\n");
		for ( x=0; x<arrNames.length; x++ )
		{
			str = arrNames[x].replace(" ", "");
			str = str.replace("\n", "");
			str = str.replace("\r", "");
			if ( str != "" )
				NumNames++;
		}
		if ( NumNames > 40 )
		{
			alert("You have entered " + NumNames + ".\nPlease enter no more than 40 names.");
			document.theForm.elements["t-b-names"].focus();
			return;
		}
	}
	
	// check that color is available in youth colors
	//alert(sYouthColorList);
	//alert(document.theForm.t-color.value);
	if ( YouthRequested == "yes" )
		if ( sYouthColorList.indexOf(document.getElementById("t-color").value) == -1 )
		{
			// could list colors availble or not available here
			//arrYouthColors = sYouthColorList.value.split(",");
			// then remove first 7 chars from each array element (FFFFFF-)
			alert("Sorry, the color you have selected is not available in youth sizes.\nSome colors are only available in adult sizes.\nPlease make another selection.");
			document.getElementById("t-color").focus();
			return;
		}

	return true;
}

function TshirtVerifyQty(obj)
{
	var ReturnVal = true;

	if ( obj.value.indexOf(",") > -1 || obj.value.indexOf(".") > -1 )
		ReturnVal = false;

	if ( isNaN(obj.value) )
		ReturnVal = false;

	if ( !ReturnVal )
	{
		alert("Invalid quantity entered, please correct.");
		obj.focus();
		return false;
	}
	else
		return true;
}

function TshirtColorChange()
{
	var src, c, pos1, pos2, sOldImage, sNewImage;

	//if ( document.theForm.t-color.value.length == 13 )
	if ( document.getElementById("t-color").value.length == 13 )
	{	// Adult Ringer tshirt type
		// actually ringer bg color wouldn't need to be set if images were not transparent, but already coded
		document.getElementById("TshirtImg").style.backgroundColor = "#" + document.getElementById("t-color").value.substr(0, 6);

		// reset <img> src
		src = document.getElementById("TshirtImg").src;	// previous <img> src
		pos1 = src.indexOf("Ringer");
		pos2 = src.indexOf(".gif");
		sOldImage = src.substr(pos1+6, pos2-4);
		
		for ( c=0; c<arrRingerTshirtColorRgb.length; c++ )
		{
			if ( arrRingerTshirtColorRgb[c] == document.getElementById("t-color").value )
			{
				sNewImage = arrRingerTshirtColorName[c].replace("/", "") + ".gif";
				sNewImage = sNewImage.replace("Heather Grey", "Grey");
				src = src.replace(sOldImage, sNewImage);
				//alert(src);
				document.getElementById("TshirtImg").src = src;
			}
		}
		return;
	}

	//alert(document.theForm.t-color.value);
	if ( document.getElementById("t-color").value == sWhiteRgb )
	{
		src = document.getElementById("TshirtImg").src;
		src = src.replace("ShortSleeve.gif", "ShortSleeveWhite.gif");
		src = src.replace("LongSleeve.gif", "LongSleeveWhite.gif");
		document.getElementById("TshirtImg").src = src;
	}
	else
	{
		src = document.getElementById("TshirtImg").src;
		src = src.replace("ShortSleeveWhite.gif", "ShortSleeve.gif");
		src = src.replace("LongSleeveWhite.gif", "LongSleeve.gif");
		document.getElementById("TshirtImg").src = src;
	}
	document.getElementById("TshirtImg").style.backgroundColor = "#" + document.getElementById("t-color").value;
}

function VerifyDay(m, d, y)
{
	if ( m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12 )
		return true;
	if ( m != 2 )
		if ( d < 31 )
			return true;
		else
			return false;
	// month is february
	if ( y == 2004 || y == 2008 || y == 2012 || y == 2016 || y == 2020 )
		if ( d < 30 )
			return true;
		else
			return false;
	if ( d < 29 )
		return true;
	else
		return false;
}

function QtyFocus(obj)
{
	obj.select();
}

function PosterAddOrUpdate(sAction)
{
	var qty;
	var InvalidChar;

	if ( isNaN(document.theForm.PosterQty.value) || document.theForm.PosterQty.value == "" )
	{
		alert("Please enter a quantity of 0 to 15. Enter numbers only.");
		document.theForm.PosterQty.focus();
		return;
	}
	qty = parseInt(document.theForm.PosterQty.value);
	if ( qty != 0 && qty < 15 )
	{
		alert("Please enter a quantity of at least 15, or enter 0 to remove posters.");
		document.theForm.PosterQty.focus();
		return;
	}
	if ( qty == 0 )
	{
		document.theForm.PosterText1.value = "";
		document.theForm.PosterText2.value = "";
		document.theForm.PosterText3.value = "";
	}
	if ( qty > 0 )
		if ( document.theForm.PosterText1.value == "" && document.theForm.PosterText2.value == "" && document.theForm.PosterText3.value == "" )
		{
			alert("Please enter your customized poster text.");
			document.theForm.PosterText1.focus();
			return;
		}
	if ( document.theForm.PosterText1.value.indexOf("<br>") > -1 ||
		document.theForm.PosterText2.value.indexOf("<br>") > -1 ||
		document.theForm.PosterText2.value.indexOf("<br>") > -1 ) 
	{
		// <br> used as separator of 3 text fields in cart struct
		alert("Invalid characters <br> entered in text.");
		return;
	}
	InvalidChar = CheckForInvalidChar(document.theForm.PosterText1.value);
	if ( InvalidChar != "" )
	{
		alert("Invalid character entered in text: " + InvalidChar);
		document.theForm.PosterText1.focus();
		return;
	}
	InvalidChar = CheckForInvalidChar(document.theForm.PosterText2.value);
	if ( InvalidChar != "" )
	{
		alert("Invalid character entered in text: " + InvalidChar);
		document.theForm.PosterText2.focus();
		return;
	}
	InvalidChar = CheckForInvalidChar(document.theForm.PosterText3.value);
	if ( InvalidChar != "" )
	{
		alert("Invalid character entered in text: " + InvalidChar);
		document.theForm.PosterText3.focus();
		return;
	}

	SubmitTheForm(sAction);
}

function CheckForInvalidChar(inText)
{
	var CheckText;
	var ReturnChar = "";
	var x;

	// check that only valid characters used, to protect against potential string problems
	CheckText = inText.toLowerCase();
	for ( x=0; x<CheckText.length; x++ )
	{
		if ( CheckText.charAt(x) == "\"" ||
			CheckText.charAt(x) == ">" ||
			CheckText.charAt(x) == "\\" ||
			CheckText.charAt(x) == "/" ||
			CheckText.charAt(x) == ";" ||
			CheckText.charAt(x) == "~" ||
			CheckText.charAt(x) == "&" ||
			CheckText.charAt(x) == "`" ||
			CheckText.charAt(x) == "^" ||
			CheckText.charAt(x) == "_" ||
			CheckText.charAt(x) == "{" ||
			CheckText.charAt(x) == "}" ||
			CheckText.charAt(x) == "<")
		{
			ReturnChar = inText.charAt(x);
			x = CheckText.length; // stop loop
		}
	}
	return ReturnChar;
}

function CreditCardClick()
{
	document.theForm.PurchaseOrderNum.disabled = true;
	
	document.theForm.CcType.disabled = false;
	document.theForm.CcNum.disabled = false;
	document.theForm.CcExpireMonth.disabled = false;
	document.theForm.CcExpireYear.disabled = false;
	
	//alert(document.all.CcName.innerHTML);
	//alert(document.getElementById("CcName").innerHTML);
	//PayMethod = "cc";
	//document.getElementById("PayMethod").value = "cc";
}

function PurchaseOrderClick()
{
	document.theForm.PurchaseOrderNum.disabled = false;
	
	document.theForm.CcType.disabled = true;
	document.theForm.CcNum.disabled = true;
	document.theForm.CcExpireMonth.disabled = true;
	document.theForm.CcExpireYear.disabled = true;

	//PayMethod = "po";
	//document.getElementById("PayMethod").value = "po";
}

function LogIn(action)
{
	if ( !ValidEmail(document.theForm["CustInfoLoginEmail"].value) )
	{
		alert("Please enter a valid email address.");
		document.theForm["CustInfoLoginEmail"].focus();
		return;
	}
	if ( document.theForm.CustInfoLoginPw.value == "" )
	{
		alert("Please enter your password");
		document.theForm.CustInfoLoginPw.focus();
		return;
	}
	if (!ValidChars(document.theForm["CustInfoLoginEmail"]))
		return;
	if (!ValidChars(document.theForm.CustInfoLoginPw))
		return;

	SubmitTheForm(action);
}

function ForgotPassword(action)
{
	if ( document.theForm.CustInfoLoginEmail.value == "" )
	{
		alert("Please enter your email address, so we can email you your password");
		document.theForm.CustInfoLoginEmail.focus();
		return;
	}
	if ( !ValidEmail(document.theForm["CustInfoLoginEmail"].value) )
	{
		alert("Please enter a valid email address.");
		document.theForm["CustInfoLoginEmail"].focus();
		return;
	}
	if (!ValidChars(document.theForm.CustInfoLoginEmail))
		return;

	SubmitTheForm(action);
}

function ContinueToOrderPage(sAction, BillDiff, ShipDiff)
{
	var nNums;

	if ( !CheckAddressInfo("Cust") )
		return;
	if ( BillDiff == "y" )
		if ( !CheckAddressInfo("Bill") )
			return;
	if ( ShipDiff == "y" )
		if ( !CheckAddressInfo("Ship") )
			return;

	//alert(document.getElementById("PayMethod").value);
	//if ( document.theForm.PayMethod[0].checked )
	//	alert("-cc");
	//else
	//	alert("-po");

	if ( document.theForm.PayMethod[0].checked )
	//if ( PayMethod == "cc" )
	{
		if ( isNaN(document.theForm.CcNum.value) )
		{
			alert("Please enter a valid credit card number. Enter numbers only.");
			document.theForm.CcNum.focus();
			return;
		}
		nNums = CountNumbers(document.theForm.CcNum);
		if (document.theForm.CcType.value == "v" && nNums != 16 && nNums != 13)
		{
			alert("Please enter a valid credit card number. Enter numbers only.");
			document.theForm.CcNum.focus();
			return;
		}
		if (document.theForm.CcType.value == "mc" && nNums != 16)
		{
			alert("Please enter a valid credit card number. Enter numbers only.");
			document.theForm.CcNum.focus();
			return;
		}
		if (document.theForm.CcType.value == "ae" && nNums != 15)
		{
			alert("Please enter a valid credit card number. Enter numbers only.");
			document.theForm.CcNum.focus();
			return;
		}
		if (document.theForm.CcType.value == "d" && nNums != 16)
		{
			alert("Please enter a valid credit card number. Enter numbers only.");
			document.theForm.CcNum.focus();
			return;
		}
		if (document.theForm.CcExpireMonth.value == "0")
		{
			alert("Please select a credit card expiration date.");
			document.theForm.CcExpireMonth.focus();
			return;
		}			
		if ( document.theForm.CcExpireYear.value == "0" )
		{
			alert("Please select a credit card expiration date.");
			document.theForm.CcExpireYear.focus();
			return;
		}			
	}
	else
	{
		/*
		if ( document.theForm.PurchaseOrderNum.value.length == 0 )
		{
			alert("Please enter a purchase order number");
			document.theForm.PurchaseOrderNum.focus();
			return;
		}
		*/
		if (!ValidChars(document.theForm.PurchaseOrderNum))
			return;
		if (document.theForm.HasAid.value == "y")
		{
			alert("The credit card payment method must be used when purchasing the artwork image download.");
			return;
		}
		else if ( document.theForm.HasPda.value == "y" )
		{
			alert("The credit card payment method must be used when purchasing the play audio download.");
			return;
		}
		else if (document.theForm.HasPs.value == "y")
		{
			alert("The credit card payment method must be used when purchasing the perusal script download.");
			return;
		}
		else if (document.theForm.HasSt.value == "y")
		{
			alert("The credit card payment method must be used when purchasing slogan tees.");
			return;
		}
	}

	if ( document.theForm.Comments.value.length > 400 )
	{
		alert("Please limit your comment or question to 400 characters, currently it is " + document.theForm.Comments.value.length + " characters.");
		document.theForm.Comments.focus();
		return;
	}
	
	if ( document.theForm.Catalog.checked )
		document.theForm.Catalog.value = "y";
	else
		document.theForm.Catalog.value = "n";
	if ( document.theForm.Newsletter.checked )
		document.theForm.Newsletter.value = "y";
	else
		document.theForm.Newsletter.value = "n";
	
	//if (!document.theForm.ReceiveCatalog[0].checked && !document.theForm.ReceiveCatalog[1].checked)
	//{
	//	alert("Please select whether or not you received a Heuer catalog.");
	//	return;
	//}

	SubmitTheForm(sAction);
}

function AddressDiff(sAction)
{
	if ( document.theForm.Catalog.checked )
		document.theForm.Catalog.value = "y";
	else
		document.theForm.Catalog.value = "n";

	SubmitTheForm(sAction);
}

function CheckAddressInfo(sSection)
{
	var nNums;

	if ( sSection == "Cust" )
		sSection2 = " customer";
	else if ( sSection == "Bill" )
		sSection2 = " billing";
	else if ( sSection == "Ship" )
		sSection2 = " shipping";
	else	// order catalog
		sSection2 = "";

	//if (sSection != "News" && sSection != "NewsFf" && sSection != "PerusalDownload")
	if (sSection != "News" && sSection != "NewsFf")
	{
		if ( document.theForm[sSection + "FirstName"].value.length < 1 )
		{
			alert("Please enter the" + sSection2 + " first name.");
			document.theForm[sSection + "FirstName"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "FirstName"]))
			return;
		if (document.theForm[sSection + "LastName"].value.length < 1)
		{
			alert("Please enter the" + sSection2 + " last name.");
			document.theForm[sSection + "LastName"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "LastName"]))
			return;
	}
	//if (sSection != "Ship" && sSection != "Cat" && sSection != "News" && sSection != "NewsFf" && sSection != "PerusalDownload")
	if (sSection != "Ship" && sSection != "Cat" && sSection != "News" && sSection != "NewsFf")
	{
		if (document.theForm[sSection + "Org"].value.length < 1)
		{
			alert("Please enter the" + sSection2 + " organization.");
			document.theForm[sSection + "Org"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "Org"]))
			return;
	}
	if (sSection != "News" && sSection != "NewsFf" && sSection != "PerusalDownload")
	{
		if ( document.theForm[sSection + "Addr1"].value.length < 1 )
		{
			alert("Please enter the" + sSection2 + " address.");
			document.theForm[sSection + "Addr1"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "Addr1"]))
			return;
		if (document.theForm[sSection + "City"].value.length < 1)
		{
			alert("Please enter the" + sSection2 + " city.");
			document.theForm[sSection + "City"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "City"]))
			return;
		if (document.theForm[sSection + "Country"].value == "United States" || document.theForm[sSection + "Country"].value == "Canada")
		{
			if ( document.theForm[sSection + "State"].value.length == 0 )
			{
				alert("Please select a" + sSection2 + " state/province.");
				document.theForm[sSection + "State"].focus();
				return false;
			}
		}
		else
			if ( document.theForm[sSection + "State"].value.length != 0 )
			{
				alert("Conflicting" + sSection2 + " state/province and country selection made.\nPlease select 'None' for state/province if outside USA and Canada.");
				document.theForm[sSection + "State"].focus();
				return false;
			}
		if ( document.theForm[sSection + "Country"].value.length == 0 )
		{
			alert("Please select a" + sSection2 + " Country.");
			document.theForm[sSection + "Country"].focus();
			return false;
		}
		var MinLength = 5;
		if (document.theForm[sSection + "Country"].value != "United States")
			MinLength = 4;
		if ( document.theForm[sSection + "Zip"].value.length < MinLength )
		{
			alert("Please enter a valid" + sSection2 + " zip/postal code.");
			document.theForm[sSection + "Zip"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "Zip"]))
			return;
	}
	if (sSection != "Ship" && sSection != "News" && sSection != "NewsFf" && sSection != "PerusalDownload")
	{
		nNums = CountNumbers(document.theForm[sSection + "Phone"]);
		if ( nNums < 10 )
		{
			alert("Please enter a valid" + sSection2 + " phone number.");
			document.theForm[sSection + "Phone"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "Phone"]))
			return;
	}
	//if ( document.theForm[sSection + "Fax"].value.length < 10 )
	//{
	//	alert("Please enter a fax number.");
	//	document.theForm[sSection + "Fax"].focus();
	//	return;
	//}
	if (sSection == "Cust" || sSection == "Cat" || sSection == "News" || sSection == "NewsFf" || sSection == "PerusalDownload")
	{
		if ( !ValidEmail(document.theForm[sSection + "Email"].value) )
		{
			alert("Please enter a valid email address.");
			document.theForm[sSection + "Email"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "Email"]))
			return;
	}
	if ( sSection == "Cust" )
	{
		if ( document.theForm[sSection + "Email2"].value == "" )
		{
			alert("Please confirm your email address.");
			document.theForm[sSection + "Email2"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "Email2"]))
			return;
		if (document.theForm[sSection + "Email"].value != document.theForm[sSection + "Email2"].value)
		{
			alert("Your confirm email address is not the same as your email address");
			document.theForm[sSection + "Email2"].focus();
			return false;
		}
	}
	if ( sSection == "Cust" )
	{
		// password validation
		if ( document.theForm[sSection + "Pw"].value.length > 0 && document.theForm[sSection + "Pw"].value.length < 6 )
		{
			document.theForm[sSection + "Pw"].value = "";
			document.theForm[sSection + "Pw2"].value = "";
			alert("Please enter a password with at least 6 characters.");
			document.theForm[sSection + "Pw"].focus();
			return false;
		}
		if ( document.theForm[sSection + "Pw"].value.indexOf("'") != -1 )
		{
			document.theForm[sSection + "Pw"].value = "";
			document.theForm[sSection + "Pw2"].value = "";
			alert("Please do not include apostrophes in your password.");
			document.theForm[sSection + "Pw"].focus();
			return false;
		}
		if ( document.theForm[sSection + "Pw"].value != document.theForm[sSection + "Pw2"].value )
		{
			document.theForm[sSection + "Pw"].value = "";
			document.theForm[sSection + "Pw2"].value = "";
			alert("The Password entry is not the same as the Confirm Password entry.");
			document.theForm[sSection + "Pw"].focus();
			return false;
		}
		if (!ValidChars(document.theForm[sSection + "Pw"]))
			return;
		if (!ValidChars(document.theForm[sSection + "Pw2"]))
			return;
	}
	if (sSection == "PerusalDownload" && GetQsValue("pg") == "fpd-aact")
	{
		// next line added for campaign 2 - promo code is given away
		document.theForm["PromoCode"].value = "aact55";
		if (document.theForm["PromoCode"].value.length < 1)
		{
			alert("Please enter the Promo Code shown in our ad in the AACT magazine.");
			document.theForm["PromoCode"].focus();
			return false;
		}
		else if (document.theForm["PromoCode"].value.toLowerCase() != "aact55")
		{
			alert("Invalid Promo Code. Please enter the Promo Code shown in our ad in the AACT magazine.");
			document.theForm["PromoCode"].focus();
			return false;
		}
	}
	
	return true;
}

function ValidEmail(EmailValue)
{
	var len = EmailValue.length;
	if ( len < 10 )
		return false;
	var DotPos = EmailValue.indexOf(".");
	if ( DotPos < 1 || DotPos > len-3 )	// dot must exist and have at least 2 chars after it
		return false;
	var comma = EmailValue.indexOf(",");
	if (comma != -1)
		return false;
	var AmpPos = EmailValue.indexOf("@");
	if (AmpPos < 2)	// ampersand must exist and have at least 2 chars before it
		return false;
	var LastAmpPos = EmailValue.lastIndexOf("@");
	if (LastAmpPos != AmpPos)	// can't have 2 @
		return false;
	//if ( AmpPos+3 > DotPos ) // ampersand must be before dot and have at least 2 chars between them
	//	return false;
	if ( EmailValue.indexOf("..") > 0 )
		return false;
		
	return true;
}

function ChangeShoppingCart(sAction)
{
	var OK = confirm("Notice: Returning to your shopping cart will exit our secure site.\nFor security purposes, you will need to re-enter your personal information.\n\nDo you wish to continue?");
	if ( !OK )
		return;

	SubmitTheForm(sAction);
}

function OrderCatalogInsert(sAction)
{
	if (!CheckAddressInfo("Cat"))
		return;

	SubmitTheForm(sAction);
}

function FreePerusalInsert(sAction)
{
	if (!CheckAddressInfo("PerusalDownload"))
		return;

	SubmitTheForm(sAction);
}

function NewsletterSignupInsert(sAction)
{
	if (!CheckAddressInfo("News"))
		return;

	SubmitTheForm(sAction);
}

function NewsletterForward(sAction)
{
	if (!CheckAddressInfo("NewsFf"))
		return;

	SubmitTheForm(sAction);
}

function NewsletterRemoveInsert(sAction)
{
	if ( !ValidEmail(document.theForm["RemoveNewsEmail"].value) )
	{
		alert("Please enter a valid email address.");
		document.theForm["RemoveNewsEmail"].focus();
		return;
	}

	SubmitTheForm(sAction);
}

// loads bigger version of clicked image thumbnail
var bigImage;
function ProductImageClick(imgUrl, firstCall)
{
	if (firstCall)
	{
		bigImage = new Image();
		bigImage.src = imgUrl;
	}

	if (!bigImage.complete)
	{
		// image not loaded yet, wait a bit and recheck
		setTimeout("ProductImageClick('" + imgUrl + "', false)", 500);
		return;
	}
	//alert(bigImage.height + " x " + bigImage.width);
	//alert(imgUrl);

	// set image size
	var objImage = document.getElementById("imgPopup");
	objImage.src = imgUrl;
	objImage.height = bigImage.height;
	objImage.width = bigImage.width;

	// get pixel scroll value
	var yScroll = 0;
	if (document.all)
		yScroll = document.body.scrollTop;
	else if (document.getElementById)
		yScroll = window.pageYOffset;

	// set image position and show it
	var objImageTable = document.getElementById("tabImagePopup");
	objImageTable.style.top = (document.body.clientHeight / 2) - (bigImage.height / 2) + yScroll;
	objImageTable.style.left = (document.body.clientWidth / 2) - (bigImage.width / 2);
	objImageTable.style.visibility = "visible";

	// set close image src
	var adjTop, adjLeft;
	var objImageTableCloseBtn, objImageCloseBtn;
	if (imgUrl.indexOf("Makeup") != -1)
	{
		objImageTableCloseBtn = document.getElementById("tabImagePopupCloseX");
		objImageCloseBtn = document.getElementById("imagePopupCloseX");
		adjTop = 1;
		adjLeft = 2;
	}
	else
	{
		objImageTableCloseBtn = document.getElementById("tabImagePopupCloseBtn");
		objImageCloseBtn = document.getElementById("imagePopupCloseBtn");
		adjTop = 3;
		adjLeft = -1;
	}
	var closeImage = new Image();
	closeImage.src = objImageCloseBtn.src;

	// set close image position and show it
	objImageTableCloseBtn.style.top = parseInt(objImageTable.style.top.replace("px", "")) + adjTop;
	objImageTableCloseBtn.style.left = parseInt(objImageTable.style.left) + parseInt(bigImage.width) - parseInt(closeImage.width) + adjLeft;
	objImageTableCloseBtn.style.visibility = "visible";
}

function MakeupCheckOut()
{
	var cart = document.theForm.cart.value;
	var makeupTotal = document.getElementById("MakeupTotal").innerHTML;
	if (cart == "" && makeupTotal == "$0.00")
	{
		alert("There is nothing in your shopping cart");
		return;
	}
	SubmitTheForm("default.aspx?pg=sc");
}

function MakeupCart(mode, categoryId, productId, returnAnchor)
{
	var objQty = document.getElementById("MakeupQty_" + productId);
	if (!objQty)
		return;

	if (!ValidNumber(objQty))
	{
		objQty.focus();
		return;
	}

	if (mode == "add" && objQty.value == 0)
	{
		alert("Please enter a quantity.");
		objQty.focus();
		return;
	}

	var pg = "";
	if (mode == "add")
		pg = "sc-amu";
	else
		pg = "sc-umu"

	SubmitTheForm("default.aspx?pg=" + pg + "&mucid=" + categoryId + "&mupid=" + productId + returnAnchor);
}

function MakeupQtyKeyUp(productId)
{
	//MakeupProductTotalUpdate(productId);
}

function SloganTeeQtyKeyUp(productId, productSize)
{
	SloganTeeProductTotalUpdate(productId, productSize);
	SloganTeeTotalUpdate();
}

// update amount ordered total and for product with qty changed
function SloganTeeProductTotalUpdate(productId, productSize)
{
	var objQty = document.getElementById("st-" + productId + "-" + productSize);
	if (!objQty)
		return;
	var objProductTotal = document.getElementById("StTot-" + productId);
	if (!objProductTotal)
		return;

	if (!ValidNumber(objQty))
	{
		objQty.focus();
		return;
	}
	//if (objQty.value.length == 0)
	//	objQty.value = 0;

	var sizes = "S,M,L,XL";
	var arrSizes = sizes.split(",");
	var s, price, sizeTotal;
	var productTotal = 0;
	for (var s = 0; s < arrSizes.length; s++)
	{
		objQty = document.getElementById("st-" + productId + "-" + arrSizes[s]);
		if (!objQty)
			return;

		price = 15;
		//if (arrSizes[s] == "2XL")
		//	price = 17;

		if (objQty.value.length > 0)
		{
			sizeTotal = objQty.value * price;
			if (sizeTotal.toFixed)	// if browser supports toFixed() method (js ver 1.5)
				sizeTotal = sizeTotal.toFixed(2);
			productTotal = parseFloat(productTotal) + parseFloat(sizeTotal);
			if (productTotal.toFixed)	// if browser supports toFixed() method (js ver 1.5)
				productTotal = productTotal.toFixed(2);
		}
	}
	if (productTotal.toFixed)	// if browser supports toFixed() method (js ver 1.5)
		productTotal = productTotal.toFixed(2);			
	objProductTotal.innerHTML = "$" + productTotal;
}

function SloganTeeTotalUpdate()
{
	var productId = 1;
	var productTotal;
	var sloganTeeTotal = 0;
	var objProductTotal = document.getElementById("StTot-" + productId);
	
	while (objProductTotal)
	{
		productTotal = objProductTotal.innerHTML.replace("$", "");
		sloganTeeTotal += parseFloat(productTotal);

		productId++;
		objProductTotal = document.getElementById("StTot-" + productId);
	}

	if (sloganTeeTotal.toFixed)	// if browser supports toFixed() method (js ver 1.5)
		sloganTeeTotal = sloganTeeTotal.toFixed(2);

	var objSloganTeeTotal = document.getElementById("StTot");
	objSloganTeeTotal.innerHTML = "$" + sloganTeeTotal;
}

function SloganTeeCart(update)
{
	var sloganTeeTotal = document.getElementById("StTot").innerHTML;
	if (!update && sloganTeeTotal == "$0.00")
	{
		alert("There are no quantities entered to add to your shopping cart");
		return;
	}
	SubmitTheForm("default.aspx?pg=sc-st");
}

function HidePopupImage(obj)
{
	document.getElementById("tabImagePopup").style.visibility = "hidden";
	document.getElementById("tabImagePopupCloseX").style.visibility = "hidden";
	document.getElementById("tabImagePopupCloseBtn").style.visibility = "hidden";
}

function TrimString(str)
{
	if ( str.length == 0 )
		return "";
	while ( str.charAt(0) == " " ) // strip leading blanks (ltrim)
	{
		str = str.substr(1, str.length-1);
	}
	while ( str.charAt(str.length-1) == " " ) // strip trailing blanks (rtrim)
	{
		str = str.substr(0, str.length-1);
	}

	return str;
}

function CountNumbers(obj)
{
	var nNums = 0;
	var i;

	if ( obj.value.length == 0 )
		return 0;
	while ( obj.value.charAt(0) == " " ) // strip leading blanks (ltrim)
	{
		obj.value = obj.value.substr(1, obj.value.length-1);
	}
	while ( obj.value.charAt(obj.value.length-1) == " " ) // strip trailing blanks (rtrim)
	{
		obj.value = obj.value.substr(0, obj.value.length-1);
	}

	for ( i=0; i<obj.value.length; i++ )
	{
		if ( isNaN(obj.value.charAt(i)) )
			continue;
		else
			nNums++;
	}
			
	return nNums;
}

function LeavingHttps(sAction)
{
	alert(document.theForm.__VIEWSTATE.value);
	document.theForm.__VIEWSTATE.value = "";
	alert(document.theForm.__VIEWSTATE.value);
	SubmitTheForm(sAction);
}

// All links should use this function (if the cart is not empty),
// so there is always a form submit instead of just a link,
// so that the form maintains its values
function SubmitTheForm(sAction)
{
	//alert(document.theForm.StaySecure.value);
	sAction = sAction.replace("+&+", "+%26+");	// or maybe could use escape() or URLencode()
	//alert("SubmitTheForm" + sAction);
	var sSaveAction = sAction;
	
	// when going to a secure page, the ServerName needs to be included in sAction
	// otherwise non-secure is the default
	
	//if ( sServerName == "site231.mysite4now.com" )	// on a secure server
	//if ( sHttps == "on" )	// on a secure server
	if ( sAction.indexOf("http") == -1 )						// not forcing secure
	{
		// next stmt commented, if https, stay there too avoid browser (firefox i've seen) warning
		//if ( sServerName != "localhost" )
		//	sAction = "http://www.hitplays.com/" + sAction;	// go to non-secure server
		if (document.theForm.StaySecure)
			if (document.theForm.StaySecure.value == "y")	// coming from a secure page
				RemoveCustInfo();

		if (sServerName != "localhost" && sServerName != "site475.mysite4now.net")
			if ( sAction.indexOf("pg=a-so") != -1 )
			{	// author sign out, leaving secure
				document.theForm.AuthorEmail.value = "";
				if (document.theForm.AuthorPassword)
					document.theForm.AuthorPassword.value = "";
				document.theForm.AuthorFirstName.value = "";
				document.theForm.AuthorLastName.value = "";
				if (document.theForm.AuthorSsn1)
					document.theForm.AuthorSsn1.value = "";
				if (document.theForm.AuthorSsn2)
					document.theForm.AuthorSsn2.value = "";
				if (document.theForm.AuthorSsn3)
					document.theForm.AuthorSsn3.value = "";
			}
			else if ( sSaveAction.indexOf("pg=a-") != -1 )
				sAction = "https://www." + siteName + ".com/" + sSaveAction;	// author pages are secure
			else if ( sSaveAction.indexOf("pg=oc") != -1 )
				sAction = "https://www." + siteName + ".com/" + sSaveAction; // order catalog page is secure
	}

	document.theForm.action = sAction;
	document.theForm.submit();
}

function RemoveCustInfo()
{
	//alert("RemoveCustInfo");
	document.theForm.CustFirstName.value = "";
	document.theForm.CustLastName.value = "";
	document.theForm.CustOrg.value = "";
	document.theForm.CustAddr1.value = "";
	document.theForm.CustAddr2.value = "";
	document.theForm.CustCity.value = "";
	document.theForm.CustState.value = "";
	document.theForm.CustZip.value = "";
	document.theForm.CustPhone.value = "";
	document.theForm.CustFax.value = "";
	document.theForm.CustEmail.value = "";
	document.theForm.CustPw.value = "";

	if ( sBillAddressDiff == "y" )
	{
		document.theForm.BillFirstName.value = "";
		document.theForm.BillLastName.value = "";
		document.theForm.BillOrg.value = "";
		document.theForm.BillAddr1.value = "";
		document.theForm.BillAddr2.value = "";
		document.theForm.BillCity.value = "";
		document.theForm.BillState.value = "";
		document.theForm.BillZip.value = "";
		document.theForm.BillPhone.value = "";
		document.theForm.BillFax.value = "";
	}
		
	if ( sShipAddressDiff == "y" )
	{
		document.theForm.ShipFirstName.value = "";
		document.theForm.ShipLastName.value = "";
		document.theForm.ShipAddr1.value = "";
		document.theForm.ShipAddr2.value = "";
		document.theForm.ShipCity.value = "";
		document.theForm.ShipState.value = "";
		document.theForm.ShipZip.value = "";
		document.theForm.ShipPhone.value = "";
	}

	document.theForm.CcNum.value = "";
	document.theForm.CcType.value == "";
	document.theForm.CcExpireMonth.value == "";
	document.theForm.CcExpireYear.value == "";
	document.theForm.PurchaseOrderNum.value = "";
	document.theForm.Comments.value = "";
	document.theForm.Catalog.value = "n";
}

function PopUp(sMode, sWidth, sHeight)
{
	window.open("popup.asp?m=" + sMode, "Help", "menubar=no,location=no,scrollbars=no,width=" + sWidth + ",height=" + sHeight + ",resizable=yes")
}

function TableShow(obj, inTable, Mode)
{
	//var iWindowHeight = 200;	// could be passed in?
	//var iWindowWidth = 400;
	var iWindowWidth = document.getElementById(inTable).offsetWidth;
	var iWindowHeight = document.getElementById(inTable).offsetHeight;

	//alert("xMousePos="+xMousePos);
	//alert("yMousePos="+yMousePos);
	//alert("xMousePosMax="+xMousePosMax);
	//alert("yMousePosMax="+yMousePosMax);
	//alert("document.body.clientWidth="+document.body.clientWidth);
	//alert("document.body.clientHeight="+document.body.clientHeight);

	document.getElementById(inTable).style.visibility = "visible";

	// window relative to mouse click
	//document.getElementById(inTable).style.top = yMousePos - 200;
	//document.getElementById(inTable).style.left = xMousePos - 400;

	if ( Mode == "Video" )
	{
		// window centered on page
		document.getElementById(inTable).style.top = (document.body.clientHeight/2) - (iWindowHeight/2);
		document.getElementById(inTable).style.left = (document.body.clientWidth/2) - (iWindowWidth/2);
	}
	else
	{
		obj.style.textDecoration = "underline";
		if (Mode == "EditorChoice")
		{
			document.getElementById(inTable).style.left = xMousePos - (iWindowWidth / 4);
			document.getElementById(inTable).style.top = yMousePos - 12 - iWindowHeight;
		}
		else if (Mode == "OriginalSeries")
		{
			document.getElementById(inTable).style.left = xMousePos - (iWindowWidth * .7);
			document.getElementById(inTable).style.top = yMousePos - 12 - iWindowHeight;
		}
		else
		{
			document.getElementById(inTable).style.left = xMousePos+15;
			document.getElementById(inTable).style.top = yMousePos+15;
		}
		if (xMousePos > 400 && Mode != "OriginalSeries")
			document.getElementById(inTable).style.left = 400;
	}
}

function TableHide(obj, inTable)
{
	document.getElementById(inTable).style.visibility = "hidden";
	if (obj)
		if (obj.style)
			obj.style.textDecoration = "none";
}

function GetQsValue(name)
{
	var ix, nameValue;
	var queryString = window.location.search.substring(1);
	var arrQueryString = queryString.split("&");
	for (ix = 0; ix < arrQueryString.length; ix++)
	{
		nameValue = arrQueryString[ix].split("=");
		if (nameValue[0] == name)
			return nameValue[1];
	}
	return "";
}

function CaptureMousePosition(e)
{
	if ( document.all )
	{
		// When the page scrolls in IE, the event's mouse position 
		// reflects the position from the top/left of the screen the 
		// user is looking at. scrollLeft/Top is the amount the user
		// has scrolled into the page. clientWidth/Height is the height/
		// width of the current page the user is looking at. So, to be
		// consistent with Netscape (above), add the scroll offsets to
		// both so we end up with an absolute value on the page, no 
		// matter if the user has scrolled or not.
		xMousePos = window.event.x + document.body.scrollLeft;
		yMousePos = window.event.y + document.body.scrollTop;
		xMousePosMax = document.body.clientWidth + document.body.scrollLeft;
		yMousePosMax = document.body.clientHeight + document.body.scrollTop;
	}
	else if ( document.getElementById )
	{
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth + window.pageXOffset;
		yMousePosMax = window.innerHeight + window.pageYOffset;
    }
}

function ArtworkImageMouseDown(obj)
{
	bMouseOnArtwork = true;
}

function CaptureClick(e)
{
	//alert("CaptureClick");
	if (document.all)
	{
		if (event.button == 2 || event.button == 3)	// right click
		{
			if (bMouseOnArtwork)
			{
				alert("Right click not available on artwork.");
				// return;
			}
		}
	}
	else if ( document.getElementById )
	{
		//if (e.which == 3)	// right click
		if (e.button == 2 || e.button == 3)
		{
			if (bMouseOnArtwork)
			{
				e.preventDefault();
				e.stopPropagation();
				//alert("Right click not available on artwork.");
				bMouseOnArtwork = false;
				return false;
				// can't stop context menu (???)
			}
		}
    }
	//if (e.which)
	//	alert("oops Opera?")
	bMouseOnArtwork = false;
}

function KeyPressed(Event, sMode)
{
	var Key = 0;

	//if ( window.event )
	if ( document.all )
		Key = window.event.keyCode;	// IE
	else if ( document.getElementById )
		Key = Event.keyCode? Event.keyCode : Event.charCode;	// firefox
	//if ( Key != 0 )
	//	alert("Key pressed! ASCII-value: " + Key);
	if ( Key == 13 )
		if ( sMode == "AuthorSignInPassword" )
			AuthorSignIn();
		else if ( sMode == "SearchBox" )
			SearchBoxTitle();
		else if ( sMode == "TitleFind" )
			TitleFindClick();
		else if ( sMode == "AuthorFind" )
			AuthorFindClick();
}