$j=jQuery.noConflict();


jQuery(function(){


	if($j("#clientRedirect").attr("href")){
	var newURL = $j("#clientRedirect").attr("href").toLowerCase();
	$j("#clientRedirect").attr("href", newURL);
		
	}



	$j(".parent-pageid-474 .innerTwo").append("<p><a href = '/wp-login.php?action=logout'>Click Here</a> to log out.</p>");

	$j(".wp-paginate").css("margin-left",(($j(".innerTwo").width() - $j(".wp-paginate").width()) / 2))

	var timeout    = 500;
	var closetimer = 0;
	var ddmenuitem = 0;

	function jsddm_open()
	{
		jsddm_canceltimer();
		jsddm_close();
		ddmenuitem = $j(this).find('ul').css('visibility', 'visible');
		menuItem = $j(this).children('a');
		menuItem.addClass("test");
	}

	function jsddm_close()
	{
		if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
		if(ddmenuitem) menuItem.removeClass("test");
	}

	function jsddm_timer()
	{
		closetimer = window.setTimeout(jsddm_close, timeout);
	}

	function jsddm_canceltimer()
	{
		if(closetimer)
		{
			window.clearTimeout(closetimer);
			closetimer = null;
		}
	}

	document.onclick = jsddm_close;

	$j(function(){

		

		
		$j("#footer li li:first").addClass("first");
		$j("ul.threeCol").append("<div class = 'clearer'></div>");

		$j("#menu-navigation-menu ul").each(function(){
			$j(this).append("<div class = 'shadowBtm'></div><div class = 'shadowSide'></div><div class = 'shadowTop'></div><div class = 'menuBG'></div>")
		})

		$j("#menu-navigation-menu > li:has(ul)").children('a').click(function(){ return false; }).css('cursor','default');


	


		$j("#menu-navigation-menu > li > a").each(function(){
			if($j(this).text() == "Team"){
				$j(this).click(function(){ window.location = $j(this).attr("href") }).css('cursor','pointer');
			};
			if($j(this).text() == "About Us"){
				$j(this).click(function(){ window.location = $j(this).next("ul").children("li:first").children("a").attr("href") }).css('cursor','pointer');
			};
			if($j(this).text() == "Services"){
				$j(this).click(function(){ window.location = $j(this).next("ul").children("li:first").children("a").attr("href") }).css('cursor','pointer');
			};
		});

		$j("#menu-navigation-menu > li").each(function(){
			if ($j(this).children('ul').height() <= $j(this).children('ul').children('.menuBG').height()) {
				$j(this).children('ul').children('.menuBG').css('min-height',$j(this).children('ul').height());
			};
		});

		$j('#menu-navigation-menu > li').bind('mouseover', jsddm_open)
		$j('#menu-navigation-menu > li').bind('mouseout',  jsddm_timer)

		$j('#slideshow #images .textwidget').cycle({fx: "fade", timeout: 4000});
		$j('#newsStories .inner').cycle({fx: "fade", timeout: 12000, cleartype:  1});
		$j("#header #menu-navigation-menu li:last a").addClass("last");
		$j("#header #menu-navigation-menu ul").each(function(){

			$j(this).children("li:last").addClass("last");
		});

		var slope = 1.99019608;

		if ($j.browser.msie) {
    		$j("#blueStripe").addClass("msie");
		}


		$j("#tagLine").animate({
			left: 25,
			opacity: 1
		}, 1000,
		function(){
			$j("#tagLineTwo").animate({
				opacity: 1
			}, 
			1000);	
		});

		$j("#learnMoreBox").hover(
		function(){
			$j("#learnMore").addClass("hover");
		},
		function(){
			$j("#learnMore").removeClass("hover");
		}
		).click(
		function(){
			document.location = $j("#learnMore a").attr('href');
		}
		)

		$j("#signUp").hover(
		function(){
			$j("#signUp").addClass("hover");
		},
		function(){
			$j("#signUp").removeClass("hover");
		}
		).click(
		function(){
			document.location = $j("#signUp a").attr('href');
		}
		)

	})






	/*


	moveTopBig(slope);
	moveBottomOne(slope)


	function moveTopBig(slope){
		var height = 225;
		var moveLeft = (height / slope) + parseFloat($j("#animatedStripes #big").css("left"))
		var moveHeight = parseFloat($j("#animatedStripes #big").css("top")) - height

		$j("#animatedStripes #big").animate({
			left: moveLeft,
			top: moveHeight,
		}, 
		500,
		function(){

			moveTopOne(slope)
		});
	}
	function moveTopOne(slope){
		var height = 192;
		var moveLeft = (height / slope) + parseFloat($j("#animatedStripes #one").css("left"))
		var moveHeight = parseFloat($j("#animatedStripes #one").css("top")) - height

		$j("#animatedStripes #one").animate({
			left: moveLeft,
			top: moveHeight,
		},
		function(){

			moveTopTwo(slope)
		});
	}
	function moveTopTwo(slope){
		var height = 80;
		var moveLeft = (height / slope) + parseFloat($j("#animatedStripes #two").css("left"))
		var moveHeight = parseFloat($j("#animatedStripes #two").css("top")) - height

		$j("#animatedStripes #two").animate({
			left: moveLeft,
			top: moveHeight,
		},
		500);

	}


	function moveBottomOne(slope) {
		var height = 180;
		var moveLeft = (((height / slope) * -1) + parseFloat($j("#bottomAnimatedStripes #bottomOne").css("left")))
		var moveHeight = (parseFloat($j("#bottomAnimatedStripes #bottomOne").css("top")) + height)

		$j("#bottomAnimatedStripes #bottomOne").animate({
			left: moveLeft,
			top: moveHeight,
		}, 
		500,
		function(){
			moveBottomTwo(slope)
		});

	}

	function moveBottomTwo(slope) {
		var height = 205;
		var moveLeft = (((height / slope) * -1) + parseFloat($j("#bottomAnimatedStripes #bottomTwo").css("left")))
		var moveHeight = (parseFloat($j("#bottomAnimatedStripes #bottomTwo").css("top")) + height)

		$j("#bottomAnimatedStripes #bottomTwo").animate({
			left: moveLeft,
			top: moveHeight,
		}, 
		500);

	}


	*/


})

$j(window).load(function(){
		var totalWidth = 0;
		var listNum = 0;
		$j("#menu-navigation-menu > li").each(function(){
			totalWidth = totalWidth + $j(this).width();
			listNum++
		});


		var padding = ($j("#menu-navigation-menu").width() - totalWidth) / listNum;
		padding = padding / 2;


		$j("#menu-navigation-menu > li > a").each(function(){
			$j(this).css("padding-left", padding + "px").css("padding-right", padding - 1 + "px")
		});

});
