
/*** ICOMMERCE ***/

function init(page)
{
	setHeight(document.getElementById('bodyBlock'));
	getremcookie();

	switch (page)
	{
		case	"emailReminder":
		{
			occasionDate();
			sendReminderOn();
			changeSRDay(document.emailReminder);
			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";
}

/*** 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"));
	rightSideHeight 	= getHeight(document.getElementById("rightColumn"));
	contentColumnHeight = getHeight(document.getElementById("contentColumn"));

	tallestColumn   	= (leftSideHeight > rightSideHeight)	? leftSideHeight	: rightSideHeight;
	tallestColumn   	= (tallestColumn > contentColumnHeight) ? tallestColumn 	: 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,"`");
	}
}

/*** MAKE DROPDOWN 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);

/*** REMEMBER ME ***/

function rememberMe1()
{
	if (document.entLoginForm.rememberMe.checked == true)
	{
         //SET COOKIE
        var username = document.entLoginForm.id.value;
        var password = document.entLoginForm.pw.value;
        var nextyear = new Date();

        nextyear.setFullYear(nextyear.getFullYear() +1);

        var cookiedata  = "gtprem=" + escape(username) + "|" + escape(password) + ";";
        cookiedata  	+= "expires=" + nextyear.toGMTString();

        document.cookie = cookiedata;
    }
    else
	{
		var nextyear = new Date();

		nextyear.setFullYear(nextyear.getFullYear() -1);

		document.cookie = "gtprem=;expiry=" + nextyear.toGMTString();
	}
    return true;
}

function getremcookie()
{
    var allcookies  = document.cookie;
    var pos 		= allcookies.indexOf("gtprem=");
	var value;

    if (pos != -1)
	{
        var start   = pos + 7;
        var end 	= allcookies.indexOf(";",start);
        if (end == -1) end = allcookies.length;
		
        value   									= allcookies.substring(start, end);
        value   									= unescape(value);
        value   									= value.split("|");

		if (document.entLoginForm.id)
		{
			document.entLoginForm.id.value  			= value[0];
			document.entLoginForm.pw.value  			= value[1];
			document.entLoginForm.rememberMe.checked	= true;
		}
    }
    else
	{
		if (document.entLoginForm.id)
		{
			document.entLoginForm.id.value  			= "";
			document.entLoginForm.pw.value  			= "";
			document.entLoginForm.rememberMe.checked	= false;
		}
	}
}

/* ****** PRINTER MENU SPECIFIC ****** */

function checkPrinters() {
	if (document.PrinterForm.brandselect.selectedIndex==0) {alert("Please select a Printer Brand");return false;}
	if (document.PrinterForm.idselect.selectedIndex==0) {alert("Please select a Printer Model");return false;}
}

function brandChange(field) {
	if (field.selectedIndex > 0)
	{
		document.PrinterForm.brand.value = field.options[field.selectedIndex].text;
		if (idArray[field.selectedIndex-1].length < 2)
		{
			document.PrinterForm.id.value = idArray[field.selectedIndex-1][0];
		}
		else
		{
			document.PrinterForm.id.value = "";
		}
		document.PrinterForm.idselect.options.length = 0;
		for (var i = 0; i < idArray[field.selectedIndex - 1].length; i++)
		{
		document.PrinterForm.idselect[i] = new Option(idArray[field.selectedIndex-1][i],idArray[field.selectedIndex-1][i]);
		}
	}
	else
	{
		document.PrinterForm.brand.value			= '';
		document.PrinterForm.id.value				= '';
		document.PrinterForm.idselect.selectedIndex	= 0;
	}
}