
	/*** Checkout variable ***/

	var dl = 0;

	/*** ICOMMERCE ***/

	function init(page)
	{
		// limit width to between 779 and 1003
		if (document.all) {
			var thePage = document.getElementById('page');
			var theWidth = getWidth(thePage);
			if (theWidth>1003) thePage.style.width = "1003px";
			if (theWidth<779)  thePage.style.width = "779px";
		}
		setHeight(document.getElementById('bodyBlock'));

		switch (page)
		{
			case	"emailReminder":
			case	"iContact":
			case	"memberCheck":
			case	"addResource":
			{
				getVerificationImage('');
				break;
			}
		}
	}
	var theTimer;
/*
	$(document).ready(function()
	{
		setInterval(
			function()
			{
				var theOpacity = $("#rightAssessmentGlow").css('opacity');

				if( theOpacity == 0.0 )
				{
					DoFadeIn();
				}
				else
				{
					DoFadeOut();
				}
			}, 700
		);

		function DoFadeIn()
		{
			$("#rightAssessmentGlow").stop().animate({
			opacity: 1.0
			}, 600);
		}
		function DoFadeOut()
		{
			$("#rightAssessmentGlow").stop().animate({
			opacity: 0.0
			}, 600);
		}
		leftMenuAccordion();
	});
*/
	function leftMenuAccordion()
	{
// if (leftNavSelect == 7)	alert(leftNavSelect);
		$('#leftNavMenu h3').click(function() {
//				alert(this.title);

		urlData = "http://www.3monkeysav.com/navbars/leftNavSelect.php?tag="+escape(this.title);
		// alert(urlData);

			$.ajax({
			   type: "POST",
			   url: urlData,
			   success: function(dump)
			   {
			   	 leftNavSelect = parseInt(dump);
			   //	 alert(leftNavSelect);
				   // setTimeout(";", 500);
			   }
			});
		});

		$("#leftNavMenu").accordion({
			collapsible: true,
			autoHeight: false,
			active: leftNavSelect
		});

		StopNavMonitor();
		$( "#leftNavMenu" ).bind( "accordionchangestart", function(event, ui)
		{
			StartNavMonitor();
		});
		$( "#leftNavMenu" ).bind( "accordionchange", function(event, ui)
		{
			StopNavMonitor();
		});

	}


	function StartNavMonitor()
	{
		theTimer = self.setInterval( "ProcessNav()", 40 );
	}
	function StopNavMonitor()
	{
		theTimer = window.clearInterval( theTimer );
		var menuHeight = $( "#leftNavMenu" ).outerHeight() + 38;
		$('#leftProductsBackgroundImage').css( "height",menuHeight );
		$('#leftProducts').css( "height",menuHeight );
	}
	function ProcessNav()
	{
		var menuHeight = $( "#leftNavMenu" ).outerHeight() + 38;
		$('#leftProductsBackgroundImage').css( "height",menuHeight );
		$('#leftProducts').css( "height",menuHeight );
	}


	function strip_tags (str, allowed_tags) {
	    // Strips HTML and PHP tags from a string
	    //
	    // version: 1004.2314
	    // discuss at: http://phpjs.org/functions/strip_tags    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   improved by: Luke Godfrey
	    // +      input by: Pul
	    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   bugfixed by: Onno Marsman    // +      input by: Alex
	    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +      input by: Marc Palau
	    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +      input by: Brett Zamir (http://brett-zamir.me)    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   bugfixed by: Eric Nagel
	    // +      input by: Bobby Drake
	    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   bugfixed by: Tomasz Wesolowski    // *     example 1: strip_tags('<p>Kevin</p> <b>van</b> <i>Zonneveld</i>', '<i><b>');
	    // *     returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
	    // *     example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
	    // *     returns 2: '<p>Kevin van Zonneveld</p>'
	    // *     example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
		// *     returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
	    // *     example 4: strip_tags('1 < 5 5 > 1');
	    // *     returns 4: '1 < 5 5 > 1'

	    var key = '', allowed = false;
	    var matches = [];    var allowed_array = [];
	    var allowed_tag = '';
	    var i = 0;
	    var k = '';
	    var html = '';
	    var replacer = function (search, replace, str) {
	        return str.split(search).join(replace);
	    };
	     // Build allowes tags associative array
	    if (allowed_tags) {
	        allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi);
	    }
	     str += '';

	    // Match tags
	    matches = str.match(/(<\/?[\S][^>]*>)/gi);
	     // Go through all HTML tags
	    for (key in matches) {
	        if (isNaN(key)) {
	            // IE7 Hack
	            continue;        }

	        // Save HTML tag
	        html = matches[key].toString();
	         // Is tag not in allowed list? Remove from str!
	        allowed = false;

	        // Go through all allowed tags
	        for (k in allowed_array) {            // Init
	            allowed_tag = allowed_array[k];
	            i = -1;

	            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
	            if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}

	            // Determine
	            if (i == 0) {                allowed = true;
	                break;
	            }
	        }
	         if (!allowed) {
	            str = replacer(html, "", str); // Custom replace. No regexing
	        }
	    }
	     return str;
	}

// ** 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 getWidth(theEl)
{
	return (theEl.currentStyle) ? theEl.offsetWidth : stripPX(document.defaultView.getComputedStyle(theEl,'').width);
}
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)
{
	var leftSide		= document.getElementById("leftColumn");
	var theMiddle    	= document.getElementById("contentColumn");
	var theMiddleWide  	= document.getElementById("contentColumnWide");
	var rightSide   	= document.getElementById("rightColumn");
	
	leftSideHeight  	= (leftSide)		? Math.ceil(parseInt(getHeight(leftSide)))  		: 0;
	theMiddleHeight 	= (theMiddle)   	? Math.ceil(parseInt(getHeight(theMiddle))) 		: 0;
	theMiddleWideHeight = (theMiddleWide)   ? Math.ceil(parseInt(getHeight(theMiddleWide))) 	: 0;
	rightSideHeight 	= (rightSide)   	? Math.ceil(parseInt(getHeight(rightSide))) 		: 0;
	
	if (theMiddleWideHeight > theMiddleHeight) theMiddleHeight = theMiddleWideHeight;

	tallestColumn   	= (leftSideHeight > rightSideHeight)	? leftSideHeight	: rightSideHeight;
	tallestColumn   	= (tallestColumn > theMiddleHeight) 	? tallestColumn 	: theMiddleHeight;

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

	if (theMiddle)  	theMiddle.style.zIndex  		= "1";
	if (theMiddleWide)  theMiddleWide.style.zIndex  	= "1";


}

/*** 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 (document.getElementById("leftNavMenu"))
	{
		var sfEls = document.getElementById("leftNavMenu").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)
	{
		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 (document.entLoginForm)
	{
		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;
			}
		}
	}
} 
function showPicture(theImage,width,height)
{
	if (width > 800)	width = 800;
	if (height > 600)   height = 600;
	
	pathname = self.location.pathname.substr(0, self.location.pathname.lastIndexOf("/") + 1);
	if (pathname.indexOf("gallery/") != -1) pathname = pathname.substr(0, pathname.indexOf("gallery/"));
	url = "http://"+self.location.host+pathname+"story/showPicture.php?id=" + theImage;
	showPictureWindow = window.open (url, '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);
  } 
}
