/***************************************/
// jQuery Tabber
// By Jordan Boesch
// www.boedesign.com
// Dec 25, 2007 (Merry Christmas!)
/***************************************/

(function($){

		$.jtabber = function(params){
				
				// parameters
				var navDiv = params.mainLinkTag;
				var selectedClass = params.activeLinkClass;
				var hiddenContentDiv = params.hiddenContentClass;
				var showDefaultTab = params.showDefaultTab;
				var showErrors = params.showErrors;
				var effect = params.effect;
				var effectSpeed = params.effectSpeed;
				
				// If error checking is enabled
				if(showErrors){
					if(!$(navDiv).attr('rel')){
						alert("ERROR: The elements in your mainLinkTag paramater need a 'title' attribute.\n ("+navDiv+")");	
						return false;
					}
					else if(!$("."+hiddenContentDiv).attr('id')){
						alert("ERROR: The elements in your hiddenContentClass paramater need to have an id.\n (."+hiddenContentDiv+")");	
						return false;
					}
				}
				
				// If we want to show the first block of content when the page loads
				if(!isNaN(showDefaultTab)){
					showDefaultTab--;
					$("."+hiddenContentDiv+":eq("+showDefaultTab+")").css('display','block');
					$(navDiv+":eq("+showDefaultTab+")").addClass(selectedClass);	
				}
				
				// each anchor
				$(navDiv).each(function(){
										
					$(this).click(function(){
						// once clicked, remove all classes
						$(navDiv).each(function(){
							$(this).removeClass();
						})
						// hide all content
						$("."+hiddenContentDiv).css('display','none');
						
						// now lets show the desired information
						$(this).addClass(selectedClass);
						var contentDivId = $(this).attr('rel');
						
						if(effect != null){
							
							switch(effect){
								
								case 'slide':
								$("#"+contentDivId).slideDown(effectSpeed);
								break;
								case 'fade':
								$("#"+contentDivId).fadeIn(effectSpeed);
								break;
								
							}
								
						}
						else {
							$("#"+contentDivId).css('display','block');
						}
						return false;
					})
				})
			
			}
	
})(jQuery);	



$(document).ready(function(){
    var tab;
    var c_name = "Dining" + "_tab";
    if (document.cookie.length>0) {
      c_start = document.cookie.indexOf(c_name + "=");
      if (c_start != -1) { 
        c_start = c_start + c_name.length + 1; 
        c_end = document.cookie.indexOf(";", c_start);
        if (c_end == -1) c_end = document.cookie.length;
        tab = unescape(document.cookie.substring(c_start, c_end));
      }else {
        tab = 1;
      }
    }else{
      tab = 1;
    }
    $.jtabber({
      mainLinkTag: "#listing-nav a", // much like a css selector, you must have a 'title' attribute that links to the div id name
      activeLinkClass: "selected", // class that is applied to the tab once it's clicked
      hiddenContentClass: "hiddencontent", // the class of the content you are hiding until the tab is clicked
      showDefaultTab: tab, // 1 will open the first tab, 2 will open the second etc.  null will open nothing by default
      showErrors: false, // true/false - if you want errors to be alerted to you
      effect: null, // null, 'slide' or 'fade' - do you want your content to fade in or slide in?
      effectSpeed: 'fast' // 'slow', 'medium' or 'fast' - the speed of the effect
    })
  })
