<!--//--><![CDATA[//><!--
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
/*
old menu

sfHover = function() {
	if(document.getElementById("nav"))
	{
		var sfEls = document.getElementById("nav").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);

//--><!]]>
*/


/*
 * sfDelay - Suckerfish CSS menu with JS delay.
 *
 * Copyright (c) 2008 Peter Ryan (peter-ryan.co.uk)
 * This function is free for anyone to use, modify and redistribute.
 *
 * $Id: sfdelay.js 19 2008-05-19 15:33:48Z pryan $
 */

/* http://simonwillison.net/2004/May/26/addLoadEvent/ */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
};


sfHover = function() {
	var timeout = 3000;
	var cssClass = "sfhover";

	var queue = [];
	var reCSS = new RegExp("\\b" + cssClass + "\\b");
	
	// following clears queue when leavin page (so browser back is clean)
	window.onunload=function(){queueFlush()}
	
	var sfEls = document.getElementById("nav").getElementsByTagName("li");

	for (var i=0; i<sfEls.length; i++) {
  
		// mouseover and mouseout handlers for regular mouse based interface.
		sfEls[i].onmouseover = function() {
			queueFlush();
			this.className += " " + cssClass;
		}
		sfEls[i].onmouseout = function() {
			queue.push([setTimeout(queueTimeout, timeout), this]);
		}

		// focus and blur handlers for keyboard based navigation.
		sfEls[i].onfocus = function() {
			queueFlush();
			this.className += " " + cssClass;
		}
		sfEls[i].onblur = function() {
			queue.push([setTimeout(queueTimeout, timeout), this]);
		}

		// click event handler needed for tablet type interfaces (e.g. Apple iPhone).
		sfEls[i].onclick = function(e) {
			if (this.className.search(reCSS) == -1) {
				// CSS not set, so clear all sibling (and decendants) menus, and then set CSS on this menu...
				var elems = this.parentNode.getElementsByTagName("li");
				for (var i=0; i<elems.length; i++) {
					elems[i].className = elems[i].className.replace(reCSS, "");
				}
				this.className += " " + cssClass;
			} else {
				// CSS already set, so clear all decendant menus and then this menu...
				var elems = this.getElementsByTagName("li");
				for (var i=0; i<elems.length; i++) {
					elems[i].className = elems[i].className.replace(reCSS, "");
				}
				this.className = this.className.replace(reCSS, "");
			}
			if (e && e.stopPropagation)
				e.stopPropagation();
			else
				window.event.cancelBubble = true;
		}
	}

	queueFlush = function () {
		while (queue.length) {
			clearTimeout(queue[0][0]);
			queueTimeout();
		}
	}

	queueTimeout = function() {
		if (queue.length) {
			var el = queue.shift()[1];
			el.className = el.className.replace(reCSS, "");
		}
	}
}
addLoadEvent(sfHover);


/*
New suckerfish menu
*/
$(document).ready(function(){
	$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);

  	if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}
});
	  
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};	


<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function showSubCategories(catid)
{
	/* hide all */
	if(catid == -1)
	{
		var ins = document.getElementsByTagName('ul')
		var i;
		for(i=0;i<ins.length;i++)
		{
			ulID = ins[i].id;
			
			if(ulID.match(/subcategory_menu_[0-9]/))
			{
				ins[i].style.display = 'none';
			}
		}
	}
	/* show one */
	else
	{
		showSubCategories(-1);
	
		if(document.getElementById('subcategory_menu_' + catid))
		{
			ul = document.getElementById('subcategory_menu_' + catid);
			ul.style.display = 'block';
		}
	}
}

function confirmOrderCancel()
{
	return confirm("Are you sure you want to cancel your order?");
}

function confirmCancelOrder()
{
	return confirm("Are you sure you want to cancel this order?\nThis can not be undone.");
}

function disableButton(btn)
{
	if(btn.disabled == true)
		btn.disabled = false;
	else
		btn.disabled = true;
	
	return true;
}

function updateItem(url)
{
	window.open(url,'Update Item','toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=1,width=500,height=300,left=200,top=200');
}


function toggleSpecificStateClient(specCountry)
{
	country = document.getElementById('country').value;
	
	if(specCountry != "")
		country = specCountry;

	if(country == "Australia")
	{
		document.getElementById('state_specific').style.display = 'none';
		document.getElementById('state').style.display = 'block';
	}
	else
	{
		document.getElementById('state_specific').style.display = 'block';
		document.getElementById('state').style.display = 'none';
	}
}

function toggleSpecificStateRegister(specCountry)
{
	country = document.registerForm.country.value;
	
	if(specCountry != "")
		country = specCountry;

	if(country == "Australia")
	{
		document.getElementById('state_specific').style.display = 'none';
		document.getElementById('state').style.display = 'block';
	}
	else
	{
		document.getElementById('state_specific').style.display = 'block';
		document.getElementById('state').style.display = 'none';
	}
}

function changeProductImage(id, image, url)
{
	document.getElementById('productimage').setAttribute('src',url+'thumbs/'+image);
	document.getElementById('productlink').setAttribute('href',url+image);
}

function replaceFieldText(field, matchValue, replaceValue)
{
	if(document.getElementById(field))
	{
		f = document.getElementById(field);

		if(f.value == matchValue)
			f.value = replaceValue;
	}
	else
	{
		return false;
	}
}

function clearFieldIf(id, txt)
{
	if(document.getElementById(id))
	{
		div = document.getElementById(id);
		
		if(div.value == txt)
			div.value = '';
	}
}

function printPage()
{
	if(document.getElementById('contentarea'))
	{
		var randID = Math.random();

		childWindow = open('', 'printWindow'+randID,'resizable=yes,scrollbars=yes,width=760,height=500');

		if(childWindow.opener == null) childWindow.opener = self;

		var basetag = document.getElementsByTagName("base")[0];
		var basehref = basetag.href;
		var contentHTML = document.getElementById('contentarea').innerHTML;

		childWindow.document.write("<html><head><base href='"+basehref+"' /></head><body>");
		childWindow.document.write(contentHTML);
		childWindow.document.write("</body></html>");

		childWindow.print();
	}
	else
	{
		alert("Unable to print this page.");
	}
}

function RegenerateSecurityCode() {
        var dt_now = new Date();
        var securityimage_url = '/includes/SecurityImage.php?w=147&h=35&dt=' + dt_now;
        document.images.securitycode.src = securityimage_url;
}


function postLoad(){
	$('img[rel*=lightbox]').each(function(i) {
		
		imgSrc = $(this).attr("src");
		imgAlt = $(this).attr("alt");
		if(imgAlt == undefined)
			imgAlt="";

		imgSrc = imgSrc.replace('_gallery','');

		parentLink = $(this).parent('a[rel*=lightbox]');

		if(!parentLink.length)
		{
			aLink = '<a href="'+imgSrc+'" rel="lightbox" title="'+imgAlt+'"></a>';
			$(this).wrap(aLink);
		}

		$(this).parent().lightBox();	
	});
}
