﻿// JavaScript Document
/*Custom Script Functions for Layout Interactive Elements
Developed : SepiaSolutions
Updated: 28 Feb 2010
*/
$(document).ready(function(){
/*======== JQUERY EASING ADD ON =============*/						   
		jQuery.extend( jQuery.easing,
		{
			
			easeInOutBack: function (x, t, b, c, d, s) {
				if (s == undefined) s = 1.70158; 
				if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
				return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
			},
			
			easeInBack: function (x, t, b, c, d, s) {
				if (s == undefined) s = 1.70158;
				return c*(t/=d)*t*((s+1)*t - s) + b;
			},
			easeOutBack: function (x, t, b, c, d, s) {
				if (s == undefined) s = 1.70158;
				return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
			},
			
			easeInOutCubic: function (x, t, b, c, d) {
				if ((t/=d/2) < 1) return c/2*t*t*t + b;
				return c/2*((t-=2)*t*t + 2) + b;
			}
		
		
		});
/*======== JQUERY EASING ADD ON =============*/						   


/*=========== VERTICAL MENU FIX =============*/
$('#vertNav ul li a:last').addClass('lastItem')
/*=========== VERTICAL MENU FIX =============*/
							
//Div Grid Table Formating
$(".contentTable tr:even").addClass('altRow');
/*======== WATERMARK REMOVAL ========*/

    //Newsletter Watermark Removes
	/*
    	$('.waterMarkNewsletter , .waterMark').show();
		$('.waterMarkNewsletter').click(function () {
        $(this).hide();
        $('#txtnewletter').focus();

    });
*/

    //Newsletter Watermark Removes
/*   	
	$('.waterMark').click(function () {
        $(this).hide();
        $('#searchBox').focus();

    });
*/

/*============= SLIDER FOR PAGE WIDGET ================*/
		$('.week li:first').addClass('active');
		$('.dailySlide:not(":first")').hide();
		$('.dailySlide:first').addClass('hozCurrentSlide').show();
			 
		// Set the class of the first link to active	
		$('.week li:first').addClass('active'); 
		
		var anim = 0;
		//////////////////////////////////////////////////////////
		//When any link is clicked , with Multi class approach
		$('.week li a').click(function(){ 
			
			if( $(this).parents('li').hasClass('active') ){ 
			
			/* DO NOTHING WHEN CLICKED CURRENT TAB */
					return false;
				 }
		 if ( anim == 1 ) {
			 return false
			 }
		else {
			/*value is 1 so , disabled other tab buttons, till animation is done*/
			anim = 1;
			//Get Index of Previous
			var oldIndex = $('.week li').index($('.active'))
						
			// Remove active class from all links
			$('.week li').removeClass('active'); 
					
			//Set clicked link class to active
			$(this).parents('li').addClass('active'); 
			
			//current index
			var  currentIndex = $(this).parents('li').index()
		
			// Set variable currentTab to value of href attribute of clicked link
			var currentTab = $(this).attr('href'); 
			
			//get Height to animate container
			cHeight = $(currentTab).height();
		
			//console.log("Current Slide is " + $('.hozCurrentSlide').attr('id') + " current Index is  "+ currentIndex + ", n old index is " + oldIndex + " , link is to " + currentTab + " and outter height is  " +cHeight);
			
			
			
			//Slider Effect/*
			// new aSlide replaces position  n get deleted.n assign current slide to newly positioned layer
		
		/* animation controller, if value is 0 then animation will play, else wont */
		
		if( oldIndex < currentIndex ) {
				
				$(currentTab).addClass('hozNewSlide').css('left','620px').show();
				$('.hozCurrentSlide, .hozNewSlide').animate(
						{left:"-=620px"},{duration:800,easing:'easeInOutCubic' , queue:true , complete:function(){
							/* call back after animation is done */
							anim = 0;
							} 
					});
			}
			else {
				
				$(currentTab).addClass('hozNewSlide').css('left','-620px').show();
				$('.hozNewSlide , .hozCurrentSlide').animate(
						{left:"+=620px"},{duration:800, queue:true, complete:function(){
							/*call back animation*/
							anim = 0;
							} 
					});
			};
	
			//Hiding and replacing the new slide to current slide and hiding previous slide. with call back
			
			$('.horizWidgetContainer').queue(function(){
				$('.hozNewSlide').addClass('hozCurrentSlide').show(function()
							{
								//callback to replace new slide with current and hide previous slide
								$('.dailySlide:not(".hozNewSlide")').hide();
								$('.hozNewSlide').removeClass('hozNewSlide');
							}
							);
				$('.horizWidgetContainer').dequeue();
					
			});
			return false;
		}//Else Condit
		
	})
		//Height fix for menu table
		if( $('table.menu').length > 0 )
			{
				//table menu height control
				var divHeight = 100
				$('div.dailySlide').each(function(){
						var divCurHeight = $(this).outerHeight();
						if ( divCurHeight > divHeight)
							{	divHeight = divCurHeight	}
							else { divHeight = divHeight}
						});//loop	
			
			$('.horizWidgetContainer').height(divHeight)
			
			}// table height detector ends



/*=============== CATERING CAROUSEL ===============*/
if( $('div.catering33').length > 0 )
	{
		var left = $('.catuering ul').css('left')
		//move the last list item before the first item. The purpose of this is if the user clicks previous he will be able to see the last item.  
        $('.catering ul li:first').before($('<li class="spacer"></li>')).addClass("i-am-here"); 
		
		//when user clicks the image for sliding right  
        $('.arrowSlider .right').click(function(){  
  
            //get the width of the items   
            var item_width = $('.catering ul li').outerWidth() + 10;  
  
            //calculate the new left indent of the unordered list  
            var left_indent = parseInt($('.catering ul').css('left')) - item_width;  
  
            //make the sliding effect using jquery's anumate function '  
			
            $('.catering ul').animate({'left' : left_indent},{queue:true,easing:'easeInOutCubic', duration:500,complete:function(){
  
                //get the first list item and put it after the last list item (that's how the infinite effects is made) '  
              //  $(this).click(function(){return false})
			  $('.catering ul li:last').after($('.catering ul li:first')); 
                //and get the left indent to the default -210px  
                $('.catering ul').css({'left' : '-200px'});  
             } });  
			return false
        });  
  
        //when user clicks the image for sliding left  
        $('.arrowSlider .left').click(function(){  
  
            var item_width = $('.catering ul li').outerWidth() + 10;  
  
            /* same as for sliding right except that it's current left indent + the item width (for the sliding right it's - item_width) */  
            var left_indent = parseInt($('.catering ul').css('left')) + item_width;  
  
            $('.catering ul').animate({'left' : left_indent},{queue:true, duration:500,easing:'easeInOutCubic',complete:function(){  
  
            /* when sliding to left we are moving the last item before the first item */  
            $('.catering ul li:first').before($('.catering ul li:last'));  
  
            /* and again, when we make that change we are setting the left indent of our unordered list to the default -210px */  
            $('.catering ul').css({'left' : '-200px'});  
            }}); 
			  return false
		  
        });  
		
		
		}//catering carousel

//POPUP for News


if($('.popup').length > 0){

	$('<div class="resizeCont"><div class="imgdiv"><img src="" class="imNew" /> </div></div>').insertAfter($('#footer'));

	
	$('.popup').click(function(){
		var currentImg = $(this).attr("href");
		var currentTop = $(window).scrollTop();	
		
			//remove old image which is in PreLoader
			
			$('.resizeCont').show();//.height(docHeight);
			$('.imNew').attr('src',currentImg) 
			
			
			//auto scroll to body to prevent nasty jump =)
			/*if( $('.zoomed').height() >	$('.resizeCont').height() )
			{
				alert("this is larger than container")
				$('body').css('overflow','hidden')
			}*/
		$('html').css('overflow','hidden')
		
		$(window).scrollTop(currentTop);
		
		
		$('.resizeCont').click(function(){
			$(this).hide();
			$('html').css('overflow','auto');
			$(window).scrollTop(currentTop);
		})
	 return false
	})

}


//temp fix
$('#vertNav').insertAfter($('.callNow'))


}); //Jquery



