
/*** ICOMMERCE ***/

function init(page)
{
	switch (page)
	{
		case	"emailReminder":
		{
			occasionDate();
			sendReminderOn();
			changeSRDay(document.emailReminder);
			getVerificationImage('');
			break;
		}
		case	"iContact":
		case	"memberCheck":
		{
			getVerificationImage('');
			break;
		}
		case	"shirtPanel":
		{
		//	adjust();
			break;
		}
	}
}

// ** Show currency converter for Value 'thePrice' **
function cConvert(thePrice)
{
//	var theURL = "http://www.xe.net/pca/input.cgi?amount=" + thePrice + "&From=AUD";

	CurrencyWindow = window.open ("http://www.xe.net/pca/input.cgi?amount=" + thePrice + "&From=AUD", 
									'CurrencyWindow', 
									'toolbar=0,location=0,directories=0=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600');
	CurrencyWindow.focus();
}

function verifyQuantity(theField)
{
	var theValue				= theField.value;

	if (theValue.length < 1)	theField.value  = "1";
	if (isNaN(theValue))		theField.value  = "1";
	theValue					= theValue - 0;
	if (theValue < 1) 			theField.value	= "1";
}
function verifyPrice(theField)
{
	var theValue				= theField.value;

	if (theValue.length < 1)	theField.value  = "0.00";
	if (isNaN(theValue))		theField.value  = "0.00";
	theValue					= theValue - 0;
	if (theValue < 1) 			theField.value	= "0.00";
}

/*** COLUMN HEIGHTS ***/

function getHeight(theEl)
{
	return (theEl.currentStyle) ? theEl.offsetHeight : stripPX(document.defaultView.getComputedStyle(theEl,'').height);
}
function stripPX(theValue)
{
	return (theValue.substring(0, theValue.length - 2) - 0);
}
function setHeight(element)
{
	leftSideHeight  	= getHeight(document.getElementById("leftColumn"));
	contentColumnHeight = getHeight(document.getElementById("contentColumn"));

	if (document.getElementById("rightColumn"))
	{
		rightSideHeight 	= getHeight(document.getElementById("rightColumn"));

		tallestColumn   	= (leftSideHeight > rightSideHeight)	? leftSideHeight	: rightSideHeight;
		tallestColumn   	= (tallestColumn > contentColumnHeight) ? tallestColumn 	: contentColumnHeight;
	}
	else
	{
		tallestColumn   	= (leftSideHeight > contentColumnHeight) ? leftSideHeight 	: contentColumnHeight;
	}

	if (element.style.minHeight)
	{
		element.style.minHeight = tallestColumn+"px";
	}
	else
	{
		element.style.height	= tallestColumn+"px";
	}
}

/*** GENERAL FORM CHECKING TOOLS ***/

function isFieldEmpty(theField)
{
	return (theField.value.length < 1) ? true : false;
}
function isFieldBadEmail(theField)
{
	theEmail = theField.value;
	if (theEmail.indexOf('@')==-1 || theEmail.indexOf('.')==-1 || theEmail.length<6) return true;
	return false;
}
function clearQuotes(theForm)
{
	for (i = 0; i < theForm.elements.length; i++)
	{
		if (theForm.elements[i].value) theForm.elements[i].value = theForm.elements[i].value.replace(/'/gi,"`");
	}
}

/*** REMEMBER ME ***/

function entLogin(f)
{
	with (f)
	{
		if (id.value.length < 1) {alert("Please enter your email address.");return false;}
		if (pw.value.length < 1) {alert("Please enter your password.");return false;}
	}
}
 function joinLogin(f)
{
	with (f)
	{
		if (fname.value.length<1) {alert("Please enter your first name.");return false;}
		if (lname.value.length<1) {alert("Please enter your last name.");return false;}
		if (email.value.length<1) {alert("Please enter your email address.");return false;}
		if (CheckEmail(email.value) == false) {alert("The email address you have entered does not seem to be valid.");return false;}
		if (password.value.length < 1) {alert("Please enter your password.");return false;}
	}
} 
function showPicture(theImage,width,height)
{
	if (width > 800)	width = 800;
	if (height > 600)   height = 600;
	
	showPictureWindow = window.open ("http://"+self.location.host+"/"+"story/showPicture.php?id=" + theImage, 
		'showPicture', 'toolbar=0,location=0,directories=0=0,menubar=0,scrollbars=1,resizable=1,height='+height+',width='+width);
	showPictureWindow.focus();
}

function addBookmarkForBrowser() {
  if (document.all)
  {
    window.external.AddFavorite(document.location.href, document.title);
  } 
}


/***** MAKE MENUS WORK IN EXPLORER *****/

sfHover = function()
{
	var sfEls = document.getElementById("NavHome").getElementsByTagName("LI");

	for (var i=0; i<sfEls.length; i++)
	{
		sfEls[i].onmouseover=function()
		{
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function()
		{
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}

}
if (window.attachEvent) window.attachEvent("onload", sfHover);
