/*var navLineStyles = [
	{ backgroundColor: "#15bef0", left: 0 },
	{ backgroundColor: "#7171b4", left: 130 }, 
	{ backgroundColor: "#f06098", left: 260 }, 
	{ backgroundColor: "#f58233", left: 390 }, 
	{ backgroundColor: "#fbae3b", left: 520 }, 
	{ backgroundColor: "#91c848", left: 650 }, 
	{ backgroundColor: "#00ac98", left: 780 }
];*/

(function($) {
	jQuery.fn.backgroundPosition = function() {
		var p = $(this).css("background-position");
		if (p === undefined) {
			return [
				$(this).css("background-position-x"), 
				$(this).css("background-position-y")
			].join(" ");
		} else {
			return p;
		}
	};
})(jQuery);


var Browser = {
  Version: function() {
    var version = 999; // we assume a sane browser
    if (navigator.appVersion.indexOf("MSIE") != -1)
      // bah, IE again, lets downgrade version number
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
  }
}

var $c = jQuery.noConflict();

$c(document).ready(function () {
	
	// var isAnimating = false;
	
	// moving header

	function updateBackground() {	
		var pos = parseInt($c("body").backgroundPosition(), 10);
		$c("body").css("background-position", (pos - 1) + "px 0px");
	}
		
    if (Browser.Version() > 6) 
    {												
	    setInterval(updateBackground, 100);
    }
	
	// end moving header
	
	// coloured line animation
	
	/*$c("#nav > ul > li").each(function (i) {
		$c(this).data("navLineStyle", navLineStyles[i]);
	});
	
	function getNavLine() {
		var $navLine = $c("#nav-line");
		if ($navLine.length === 0) { // coloured nav line doesn't exist, create it
			$c("#nav").append("<div id=\"nav-line\"></div>");
			$navLine = $c("#nav-line").fadeIn(250);
		}
		return $navLine;
	}*/
	
	// end coloured line animation
	
	// main dropdown menus
	
	function mainNavHoverIn(e) {		
		//var $navLine = getNavLine();
		$c(this).children("ul").slideDown(250);
		//$navLine.stop(true, true).animate($c(this).data("navLineStyle"), 250);
	}
	
	function mainNavHoverOut(e) {
		$c(this).children("ul").hide();	
	}	
	
	$c("#nav > ul > li").hoverIntent({
		over: mainNavHoverIn,
		timeout: 250,
		out: mainNavHoverOut
	});
	
	// end main dropdown menus
	
	// sub dropdown menus
	
	function subNavHoverIn(e) {		
		$c(this).children("ul").slideDown(250);
	}
	
	function subNavHoverOut(e) {
		$c(this).children("ul").hide();	
	}	
	
	$c("#nav > ul > li > ul > li").hoverIntent({
		over: subNavHoverIn,
		timeout: 250,
		out: subNavHoverOut
	});
	
	// end sub dropdown menus
	
	/*$c("#nav > ul > li").live("mouseenter mouseleave", function (e) {
		var $navLine = $c("#nav-line");
		if ($navLine.length === 0) {
			$c("#nav").append("<div id=\"nav-line\"></div>");
			$navLine = $c("#nav-line").fadeIn(250);
		}
		if (e.type === "mouseover") {
			isAnimating = true;
			$c("#nav > ul > li > ul").slideUp(250);
			$c(this).children("ul").stop(true, true).slideDown(250, function () {
				isAnimating = false;
			});
			$navLine.stop(true, true).animate($c(this).data("navLineStyle"), 250);
		} else {
			if (!isAnimating) {
				//$c(this).children("ul").stop(true, true).slideUp(250);	
				$c(this).children("ul").stop(true, true).hide();	
			}
		}		
	});
	
	$c("#nav > ul > li > ul > li").live("mouseenter mouseleave", function (e) {
		if (e.type === "mouseover") {
			$c(this).children("ul").stop(true, true).slideDown(250);
		} else {
			$c(this).children("ul").stop(true, true).hide();	
		}		
	});*/
	
});
