$(document).ready(function(){
	
	//----------------------------- System tabs
	$('span#systems_trigger').addClass('active');

	$('span#systems_trigger').click( function () {
		$('#flashContentGallery2').fadeOut();	
		$('#flashContentGallery').fadeIn();	
		$(this).addClass('active');
		$('span#solutions_trigger').removeClass('active');
	});
	
	$('span#solutions_trigger').click( function () {
		$('#flashContentGallery').fadeOut();	
		$('#flashContentGallery2').fadeIn();	
		$(this).addClass('active');
		$('span#systems_trigger').removeClass('active');
	});


	$("div#makeMeScrollable").smoothDivScroll({
		autoScroll: "always",
		pauseAutoScroll: "mouseover",
		autoScrollDirection: "backandforth",
		/*autoScrollDirection: "endlessloop",*/
		autoScrollSpeed: 1
	});
	
	$("#makeMeScrollable").mouseleave(function(){
		$(this).find('.item_details').slideUp();
	});
	
	//----------------------------- Search Form
	$('input#ajaxSearch_input').focus(function(){ if (this.value=='Search') this.value='';});
	$('input#ajaxSearch_input').blur( function () { if (this.value=='') this.value='Search'; } );
	$('form').submit(function() { if ( ($('input#ajaxSearch_input').val() == 'Search') || ($('input#ajaxSearch_input').val() == '') ) { return false; } });

	//----------------------------- Main Navigation
	$("#main").lavaLamp({
                speed: 400
    });
	
	//----------------------------- Sliders
	$(".newsSlider").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".back",
			speed: 500,
			scroll: 1,
			easing: "easein",
			visible: 1
	});
	/*
	bounceout
	elasinout
	elasout
	backin
	backinout
	backout
	*/
	
	//------------------------------- Lightbox
	$('#content a.lightbox').lightBox({fixedNavigation:true});
	
	//------------------------------- Sub Menu
	$('#subMenu ul li ul').hide();
	$('#subMenu ul li:has(ul)').hoverIntent(function() {
		$(this).children("ul").css("display", "none");
		$(this).children("ul").fadeIn("normal");
	},
	function() {
		$(this).children("ul").fadeOut("normal");
	});

	//Hover class for ul li ul li
	$('#subMenu ul li ul li').hover(function() {
		$(this).parents('li').addClass('hover');
	},function() {
		$(this).parents('li').removeClass('hover');
	}); 
	$("#subMenu ul li a").each(function(){
		var current_href = $(this).attr("href");
		var currentUrl = 'products.php' + window.location.search;
		if (current_href==currentUrl) $(this).parents('li').addClass('hover2');

	});
	if ($('#downloads').length) {
		myH = $('#downloads').height();
		$('#leftSidebar').css('paddingBottom', myH+30);
	}


	$("#content,#leftSidebar").equalHeights();
	
	/*-------------------------------------- Table styling */
	$('#content tbody tr:odd').addClass('odd');
	$('#content tbody tr:even').addClass('even');	
	


	

}); //Close document.ready


jQuery.fn.equalHeights = function() {
	var maxHeight=0;
	this.each( function() {
		if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
	});
	this.each( function() {
		$(this).height(maxHeight + "px");
		if (this.offsetHeight>maxHeight) {
			$(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
		}
	});
};



