$(document).ready(function(){

	/*............function for the center banner......*/
    $(function(){
		//Get our elements for faster access and set overlay width
		var div = $('div.sc_menu'),
               ul = $('ul.sc_menu'),
               // unordered list's left margin
               ulPadding = 0;

		//Get menu width
		var divWidth = div.width();

		//Remove scrollbars
		div.css({overflow: 'hidden'});

		//Find last image container
		var lastLi = ul.find('li:last-child');

		//When user move mouse over menu
		div.mousemove(function(e){

			//As images are loaded ul width increases,
			//so we recalculate it each time
			var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

			var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
			div.scrollLeft(left);
		});
	});
	
	/******************center banner motion***********************/
	$(function(){
		
		$('ul.sc_menu a').mouseover(function(){
		//alert("here");
			$('ul.sc_menu').css('width','3380px');
			$(this).css('padding','10px');
			$(this).css('background-color','gray');
			}).mouseout(function(){
			$(this).css('padding','0px');
			$('ul.sc_menu').css('width','3356px');
			$('#specials').css('padding-top','10px');
			});
			
		});	
		
		
	/***********************header image motion*************************/
	$(function(){
		
		$('#headerimg').mouseover(function(){
			$(this).css('margin-left','5px');
			}).mouseout(function(){
			$(this).css('margin-left','0px');
			});	

		$('#socialicons a').mouseover(function(){
			$(this).css('margin-right','5px');
			$(this).css('margin-left','-5px');
			}).mouseout(function(){
			$(this).css('margin-right','0px');
			$(this).css('margin-left','0px');
			});			
		});		
  
	/*****************************modal stuff***************************/
	var link
	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = '#dialog';
		link = '#' + $(this).attr('href');
		
		$(link).css('display','block');
		//alert(link);
		var btnid = $(this).closest("li").find("input").attr("name");

		$(id).find("input").attr("value",btnid);
		
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
		 
		 });
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$(link).css('display','none');
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
		$(link).css('display','none');
	});	
	
		
	/*...........function for the slideshow......*/
	$(function(){ 
		mypath = window.location.pathname
		//alert(mypath);
	if(mypath == '/eating/breakfast/')
	{
		pics = '#breakfastpics'
	}
	else if(mypath == '/eating/')
	{
		pics = '#eatingpics'
	}
	else if(mypath == '/eating/weekend-brunch/')
	{
		pics = '#brunchpics'
	}
	else if(mypath == '/eating/lunch/')
	{
		pics = '#lunchpics'
	}
	else if(mypath == '/eating/happyhour/')
	{
		pics = '#happyhourpics'
	}
	else if(mypath == '/eating/dinner/')
	{
		pics = '#dinnerpics'
	}
	else if(mypath == '/drinking/')
	{
		pics = '#drinkingpics'
	}
	else if(mypath == '/drinking/wine/')
	{
		pics = '#winepics'
	}
	else if(mypath == '/drinking/brunchtails/')
	{
		pics = '#brunchtailpics'
	}
	else if(mypath == '/drinking/cocktails/')
	{
		pics = '#cocktailpics'
	}
	
	else if(mypath == '/us/')
	{
		pics = '#uspics'
	}
	else if(mypath == '/wherewhen/')
	{
		pics = '#wherewhenpics'
	}
	else if(mypath == '/specials/')
	{
		pics = '#specialspics'
	}
	else if(mypath == '/stars/')
	{
		pics = '#starspics'
	}
	else if(mypath == '/talk/' || mypath == '/talk/talktous/' || mypath == '/talk/hearfromus/')
	{
		pics = '#talkpics'
	}
	else if(mypath == '/us/what-we-do/' || mypath == '/us/what-we-like/' || mypath == '/us/who-we-are/')
	{
		pics = '#uspics'
	}
		//alert(curpics);
		$(pics).innerfade({animationtype: 'fade',
								speed: 2500, 
								timeout: 1000, 
								type: 'random', 
								containerheight: '1em' 
		}); 
	});
	
	$(function(){
	
	mypath = window.location.pathname
	if(mypath == '/eating/breakfast/')
	{
		curmenu = '#eating'
		pics = '#breakfastpics'
	}
	else if (mypath == '/eating/')
	{
		curmenu = '#eating'
		pics = '#eatingpics'
	}
	else if(mypath == '/eating/weekend-brunch/')
	{
		curmenu = '#eating'
		pics = '#brunchpics'
	}
	else if(mypath == '/eating/lunch/')
	{
		curmenu = '#eating'
		pics = '#lunchpics'
	}
	
	else if(mypath == '/eating/happyhour/')
	{
		curmenu = '#eating'
		pics = '#happyhourpics'
	}
	else if(mypath == '/eating/dinner/')
	{
		curmenu = '#eating'
		pics = '#dinnerpics'
	}
	else if(mypath == '/drinking/')
	{
		curmenu = '#drinking'
		pics = '#drinkingpics'
	}
	else if(mypath == '/drinking/wine/')
	{
		curmenu = '#drinking'
		pics = '#winepics'
	}
	else if(mypath == '/drinking/brunchtails/')
	{
		curmenu = '#drinking'
		pics = '#brunchtailpics'
	}
	else if(mypath == '/drinking/cocktails/')
	{
		curmenu = '#drinking'
		pics = '#cocktailpics'
	}
	else if(mypath == '/us/')
	{
		curmenu = '#us'
		pics = '#uspics'
	}
	else if(mypath == '/wherewhen/')
	{
		curmenu = '#wherewhen'
		pics = '#wherewhenpics'
	}
	else if(mypath == '/specials/')
	{
		curmenu = '#specials'
		pics = '#specialspics'
	}
	else if(mypath == '/stars/')
	{
		curmenu = '#stars'
		pics = '#starspics'
	}
	else if(mypath == '/talk/' || mypath == '/talk/talktous/' || mypath == '/talk/hearfromus/')
	{
		curmenu = '#talk'
		pics = '#talkpics'
	}
	else if(mypath == '/us/what-we-do/' || mypath == '/us/what-we-like/' || mypath == '/us/who-we-are/')
	{
		curmenu = '#us'
		pics = '#uspics'
	}
		
	$(curmenu).css({'display':'block'});
	$(pics).css({'display':'block'});
	});
	
	$(".item a").click(function(e){ 
		//cancel link behaviour
        //e.preventDefault();
        //get link
        //var id = $(this).attr('href'); 
          
        //alert(id);  
        //$.get(id,function(data){
			//alert("Data Loaded: " + data);
			//alert($(".Scroller-Container").html());
			//$(".Scroller-Container").html(data);
		//});
		//$("#pagetext").animate({scrollTop:0}, 'slow'); 
	});
});
	
	

