
var hoverItem;

$(function() {
	$(".menu li a").hover(function(){ 
	    hoverItem = this;
	    var currentItem = this;
	    var navArray = getElementsByClass("subnav",document,"*");

	    var timer = setTimeout(function(){ var newItem = currentItem;
	    if(hoverItem == newItem){
		$(newItem).parent().find("ul.subnav").slideDown('slow');
		$(newItem).parent().hover(function() {
		}, function() {
			// On hovering out slide subnav menus back up
			$(newItem).parent().find("ul.subnav").slideUp('slow');
			hoverItem = null;
		})}}, 300);
	});
});
/*
$(document).ready(function(){
	$("#btnCustomise").click(function(){
		$(".lensForm").slideToggle('slow');
		$(this).toggleClass("active"); return false;
	});
});

*/

function getElementsByClass(searchClass,node,tag) {
    var classElements = new Array();
    if ( node == null )
        node = document;
    if ( tag == null )
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if ( pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}