function nav_animations(){
	//overrides for JS only
	$(".nav li img").hide();
	$(".nav li div").css('left','auto').hide();

	$(".nav li").mouseover(function(){
		var goo = $('img', this);					 
		$('div', this).slideDown( 'slow', function(){ goo.fadeIn('slow'); } );					
	});
	$(".nav li").mouseleave(function(){
		//resets default action
		$('div', this).css('left','-999em');
		$(this).mouseenter(function(){	
			$('div', this).css('left','auto');
		});
	});

}

function equalHeight(group) {
    var tallest = 0;
	var thisHeight;
	group.each(function() {
		thisHeight = $(this).height() ;
        tallest = (thisHeight < tallest) ? tallest : thisHeight;
    });
    group.css({'height': tallest});
}

function JQuery_page_ready(){
	$(document).ready(function(){
		nav_animations();

		$('.two_column').each(function(){
			equalHeight( $('.column', this) );
		});
		$('.three_column').each(function(){
			equalHeight( $('.column', this) );
		});
		$('.four_column').each(function(){
			equalHeight( $('.column', this) );
		});
		$('.six_column').each(function(){
			equalHeight( $('.column', this) );
		});


		window.setTimeout(
			function () {
				window.setInterval( function(){
					var obj = $('#selling_point');
					if (obj.length){
						$.get('images/backgrounds/rotator2.php', { 'new': 'test' }, function(data){
							if ( checkImages(obj, data) ){
								setImages(obj, data);
							}
						});
					}
				 }, 5000 );
			}, 1000
		);
		function checkImages(obj, img){
			var base = 'http://static5.apisupport.net',
				base2 = 'http://www.ancoproductsinc.com',
				regex1 = /(url\()(.*)(\))/,
				regex2 = /\"/g,
				goes = true,
				foo;
			$.each( obj, function(i) {
				foo = $(this).css('background-image');
				foo = foo.replace( regex1, '$2' );
				foo = foo.replace( regex2, '' ); 
				foo = foo.replace( base, '');
				foo = foo.replace( base2, '');
				if (foo == img){ goes = false; }
			});
			return goes;
		}
		function setImages(obj, img){
			$(obj).fadeOut(
				'normal',
				function(){
					$(obj).css( 'background-image', 'url(' + img +')' );
					$(obj).fadeIn( 'normal' );
				}
			);
		}
	});	
}
