	
	$(document).ready(function() {
		document._preloaded_images=new Array();
		preload_menu_images('#menu img');
		if($('#side_menu').size() != 0){
			preload_menu_images('#side_menu img',true);
			var j=document._preloaded_images.length;
			document._preloaded_images[j]=new Image; 
			document._preloaded_images[j++].src="images/banners/2.png"; 

			document._preloaded_images[j]=new Image; 
			document._preloaded_images[j++].src="images/banners/3.png"; 
		}
		$('.drop-menu td').click(function(){
			if($('a',this).size() > 0){
				document.location.href=$('a',this).attr('href');
			}
		});
		$('.drop-menu td').mouseover(function(evt){
				evt.stopImmediatePropagation();
		});
});
	
document._the_banner = 'm3';
function rotate_banner(ix){
	prev_banner = document._the_banner;
	document._the_banner = ix;
	if(prev_banner != document._the_banner){
		$('#theholder'+prev_banner).hide();
	}
	$('#theholder'+document._the_banner).show();
}	
document._default_menu = new Array();
function preload_menu_images(menu_id,callback){
	document._default_menu[menu_id] = new Array();

	var j=document._preloaded_images.length;
	$(menu_id).each(function(){
		var imgSrc = $(this).attr('src');
		$(this)[0]._orig_source = imgSrc;
		
		document._preloaded_images[j]=new Image; 
		if(imgSrc.indexOf('/on_') != -1){
			document._default_menu[menu_id] = $(this)[0];
			document._preloaded_images[j].src=imgSrc.replace('/on_','/off_');

			$(this).mouseover(function(evt){
				evt.stopImmediatePropagation();
				var $this = $(this)
				$(menu_id).each(function(){
					var $this = $(this);
					$this[0].src = $this[0]._orig_source;
				});
				$('.drop-menu').hide();
				if(menu_id.indexOf('side_menu') != -1){
					rotate_banner($this.attr('id'));
				}else if($this.hasClass('pop_trigger')){
					var pos = $this.offset();
					$('#drop_'+$this.attr('id')).css({left:pos.left,top:pos.top+$this.height()}).show();
				}
			});

		}else{
			document._preloaded_images[j].src=imgSrc.replace('/off_','/on_');

			$(this).mouseover(function(evt){
				evt.stopImmediatePropagation();
				var $this = $(this)

				$(menu_id).each(function(){
					var $this = $(this)
					$this[0].src = $this[0]._orig_source;
				});
	
				document._default_menu[menu_id].src = document._default_menu[menu_id]._alt_source;
				$this[0].src = $this[0]._alt_source;
				$('.drop-menu').hide();

				if(menu_id.indexOf('side_menu') != -1){
					rotate_banner($(this).attr('id'));
				}else if($this.hasClass('pop_trigger')){
					var pos = $this.offset();
					$('#drop_'+$this.attr('id')).css({left:pos.left,top:pos.top+$this.height()}).show();
				}

			});
		}
		$(this)[0]._alt_source = document._preloaded_images[j++].src;
	
	});
	$('body').mouseover(function(){
			$(menu_id).each(function(){
				$(this)[0].src = $(this)[0]._orig_source;
			});
			if(menu_id.indexOf('side_menu') != -1){
				rotate_banner('m3');
			}
			$('.drop-menu').hide();
		});
}	
	
	
