/*

var DDSPEED = 5;
var DDTIMER = 0;
ua   = navigator.userAgent.toLowerCase();
ie6  = (ua.indexOf("msie") && document.all && ua.indexOf("netscape") == -1);
if (jQuery.browser.msie) {
  if(parseInt(jQuery.browser.version) == 7) {
	  DDSPEED = 1;
  } else if(ie6) {
	  DDSPEED = 1;
  }

}

// main function to handle the mouse events //
function ddMenu(id, d) {
    var h = document.getElementById(id + '-ddheader');
    var c = document.getElementById(id + '-ddcontent');
    clearInterval(c.timer);
    if (d == 1) {
        clearTimeout(h.timer);
        if (c.maxh && c.maxh <= c.currh) { return }
        else if (!c.maxh) {
            c.style.display = "block";
            c.style.visibility = 'visible';
            c.style.height = 'auto';
            c.maxh = c.offsetHeight;
            c.currh = 0;
            c.style.height = '0px';
        }
        c.timer = setInterval(function() { ddSlide(c, 1) }, DDTIMER);
    } else {
        h.timer = setTimeout(function() { ddCollapse(c) }, 50);
    }
}

// collapse the menu //
function ddCollapse(c) {
    c.timer = setInterval(function() { ddSlide(c, -1) }, DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id) {
    var h = document.getElementById(id + '-ddheader');
    var c = document.getElementById(id + '-ddcontent');
    clearTimeout(h.timer);
    clearInterval(c.timer);
    if (c.currh < c.maxh) {
        c.timer = setInterval(function() { ddSlide(c, 1) }, DDTIMER);
    }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c, d) {
    var currh = c.currh;
    var dist;
    if (d == 1) {
        dist = (Math.round((c.maxh - currh) / DDSPEED));
        $(c).prev('a.pnav').siblings().removeClass('hover');
        $(c).prev('a.pnav').addClass('hover');
    } else {
        dist = (Math.round(currh / DDSPEED));
        $(c).prev('a.pnav').removeClass('hover');
    }
    if (dist <= 1 && d == 1) {
        dist = 1;
    }
    c.currh = (currh + (dist * d));
    c.style.height = (currh + (dist * d)) + 'px';

    if(ie6){

	} else {
	    c.style.opacity = currh / c.maxh;
	    c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
	}
    // Collapse
    if (currh < 5 && d != 1) {
        clearInterval(c.timer);
        c.style.height = "0px";
        c.style.visibility = 'hidden';
        c.maxh = 0;
        c.currh = 0;

        return;
    }

    // Expand
    if (currh > (c.maxh - 2) && d == 1) {
        clearInterval(c.timer);
    }
}

function toggleHide(id) {
    var c = document.getElementById(id + '-ddcontent');
    if(c.currh > 0)
        setTimeout(function() { ddCollapse(c) }, 50);
}

function toggleShow(id) {
    var c = document.getElementById(id + '-ddcontent');
    c.style.display = "block";
    c.style.visibility = 'visible';
    c.style.height = 'auto';
    c.maxh = c.offsetHeight;
    c.currh = 0;
    c.style.height = '0px';
    c.timer = setInterval(function() { ddSlide(c, 1) }, DDTIMER);
}
*/

jQuery.noConflict();
jQuery(document).ready(function() {

var tId;

    function navHover(id) {

        if(jQuery('ul.sub', id).attr('title')=='closed'){
            // don't show it's sub menu
        }else{
            //show its submenu
            jQuery('ul.sub', id).animate({
                opacity: 1
            }, 100, function() {});
            jQuery('ul.sub', id).slideDown(100);
            clearTimeout(tId);
        }
    }

jQuery(document).ready( function() {
    jQuery('#nav li').hover(
        function () {
            var elem = this;
            tId = setTimeout(function(){
                navHover(elem);
                elem=null;
            },200);  // elem = null is for an IE memory leak bug. YAY IE!
        },
        function () {

            // clear the timeout if the animation hasn't started to avoid delayed animation
            clearTimeout(tId);
            //hide its submenu
            jQuery('ul.sub', this).animate({
                opacity: 0
            }, 100, function() {});
            jQuery('ul.sub', this).slideUp(100);
        });


});

});
