$(document).ready(function(){
	//Fix the login link on the page
	$("#loginlink").attr('href',"/Login.action?redirectURL="+document.location);
	
	/* Note that '#default_menu' is hidden through an inline script - does not use jquery */

	$.ajax({
		url: "/static/header/submenus.html?v13",
		dataType: "html",
        //Copy over the requestId into local scope through a closure
        success: function (data) {
	  		var menuRoot = $('#header_submenus');
	  		
          	menuRoot.html(data);

			if(typeof(IB) != "undefined" ) {
		  		if(IB && IB.sson && IB.fixPic2Links) {
		  			IB.fixPic2Links(menuRoot);
		  		}
	  		}
	  		

          	var selects=$('select');
          	
          	var allHeaderLIs = $("#header li");
          	var allmenuContents = $("#header li .mainDiv");
          	
	       	allHeaderLIs.hoverIntent({
	       		//mouse over
	       		over: function() {
	       			var elLi = $(this);
	       			
	       			allHeaderLIs.removeClass('hover')
	       			allmenuContents.css('display','none');
	       			
	       			elLi.addClass('hover');
	       			
	       			var mainDiv= $('.mainDiv', elLi);
	       			if(mainDiv.size()==0) {
	       				var menuId = "#"+elLi.attr('id').replace("mainmenu_","menucontent_")
	       				
	       				elLi.append($(menuId, menuRoot).get(0));
	       				mainDiv= $('.mainDiv', elLi);
	       			}
	       			
	       			mainDiv.css('display','block');
       				selects.css('visibility','hidden');
	       		},
	       		//mouse out
	       		out: function() {
		       		var elLi = $(this);
	       			elLi.removeClass('hover');
	       			$('.mainDiv', elLi).css('display','none');
	       			selects.css('visibility','visible'); 
	       		} ,
	       		timeout : 200,
	       		interval : 100
	       	});
	       	
	       	$('#sitelogo').parents('div.logo').append($('#logo_allstore').css('display','none'));
	       	
	       	$('div.logo').hover(
	       		function() {
	       			$('#logo_allstore').show()
	       			selects.css('visibility','hidden');
	       		},
	       		
	       		function() {
	       			$('#logo_allstore').hide()
	       			selects.css('visibility','visible'); 
	       		}
	       	);
	       	
		},
		error : function() {
        	$('#default_menu').css('display','block');
		},
        timeout : function() {
        	$('#default_menu').css('display','block');
		}
	});
	
	(function() {
		all=$('div.testimonials li')
		count=all.size();
		current=0;
		if(count>0) {
			function rotate() { 
				all.eq(current).hide('slow',function() { 
					all.eq((current+1)%count)
						.hide()
						.show('slow', function() { 
							current=(current+1)%count
							
						}) 
					});  
				setTimeout(rotate,1000*10);
			}
			rotate();
		}
	})();
	//for adding underline in showcasetile
	$('.showcaseTitle').hover(function(){
		$(this).css('text-decoration','underline');
	},function(){
			$(this).css('text-decoration','none');
	});
	/*
    $('div.sublinks').each(function(){
    	$('li').hover(function() {
			$(this).addClass('hover');
		}, 
		function() {
			$(this).removeClass('hover');
		});
    });
    */
});

