$(document).ready(function(){
	$("#loginlink").attr('href',"/Login.action?redirectURL="+ encodeURIComponent(document.location));
	if(isHomePage=="false"){
		$('.mainDiv').hide();
	
		$('#mainmenu').hoverIntent({
			over: function(){
				$(this).css('cursor','pointer');
				$('.mainDiv').show();	
			},
			out: function(){
				$('.mainDiv').hide();	
			},
	   		timeout : 200,
	   		interval : 100
		
		});
	}
	var default_scroll = 85;


	$('.menuLink').hoverIntent({
   		//mouse over
   		over: function() {
		
		
			$(this).addClass('hover');
			var submenu= $(this).children('.store').children('.subMenu');
            var window_height =  $(window).height();
            var offset = $(this).offset();
            var refferer = offset.top;
            default_scroll = parseInt(default_scroll);
            if($(document).scrollTop() < default_scroll){
                    window_height = window_height - default_scroll;
                    refferer = refferer - default_scroll;        
            }else{
                    refferer = refferer -$(document).scrollTop() ;
            }
            var submenu_top = 0;
            var submenu_height = submenu.height();
            var backgroundposition = "-400px";

           if((refferer + submenu_height) > window_height){
                    submenu_top = ((refferer + submenu_height)-window_height);
            }
            if(submenu_top > refferer){
                    submenu_top = refferer;
            }
            if(submenu_top == 0){
                    submenu_top =0;
            }
            if(refferer > submenu_top){
                    backgroundposition = "-"+(400-submenu_top)+"px";
                    
            }else{
                    backgroundposition = "-"+(400-refferer)+"px";
                    
            }
			
			
			submenu.css({'left':'185px','top':'-'+submenu_top+'px','z-index':'1','background-position':'left '+backgroundposition});
			submenu.show();
		},
		out: function(){
			$(this).children('.store').children('.subMenu').hide();
			$(this).removeClass('hover');
		} ,
   		timeout : 50,
   		interval : 50
	});
	
	(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');
	});

	 
 });
