/*
	Created by: Klaus Hoermann <klaus@3b-solutions.net>
	Created for: Invite Business Solutions
	Client: Invite Business Solutions
	Description: Default JS functionality
	Copyright: (C) 3B-Solutions Klaus Hoermann 2010
*/

// jQuery's noConflict mode is used instead of the $
var J = jQuery.noConflict();

/* when the document is ready */
jQuery(document).ready(function()
{
	//--------------------------------------------------
	// header menu
	J("#headermenu ul li a").hover
	(
	 	// over
		function()
		{
			// get source image name, and prefix (without extension)
			var iconName = J(this).children("img").attr("src");
			var origin = iconName.split(".png")[0];
			
			// Set source of over image
			//J(this).children("img").attr({src: "" + origin + "Over.png"});
			
			// animate the link
			J(this).animate({width:"120px"}, {queue:false, duration:"normal"});
			
			// animate the span with the text
			J(this).children("span").animate({opacity: "show"}, "fast");			
		},
		// out
		function()
		{
			var iconName = J(this).children("img").attr("src");
			var origin = iconName.split("Over.")[0];
			//J(this).children("img").attr({src: "" + origin + ".png"});
			J(this).animate({width:"25px"}, {queue:false, duration:"normal"});
			J(this).animate("span").animate({opacity:"hide"}, "fast");
		}
	);
	
	//--------------------------------------------------
	// main menu
	J("#mainmenu ul li a").hover
	(	 
	 	// 
	 	function() 
		{ 
			//Drop down the subnav on click
			J(this).parent().find("ul.subnav").stop().slideDown("3000").show("2500", function()
			{
				J(this).height("auto");
			}); 

			//When the mouse hovers out of the subnav, move it back up
			J(this).parent().hover
			(
			 	// over
		 		function() {}, 
				// out
				function()
				{	
					J(this).parent().find("ul.subnav").stop().slideUp("2500")
				}
			);

		//Following events are applied to the trigger (Hover events for the trigger)
		}
	)
	.hover
	(
	 	// over
	 	function() { J(this).addClass("subhover"); }, 
		// out
		function(){	J(this).removeClass("subhover"); }
	);

	//--------------------------------------------------
	// cycle header image
	J("#headerimage").cycle({fx:"fade", speed:5000});

});
	
	
	
	
	
	
	
