
onload=function(){
	if (document.getElementsByClassName == undefined) {
		document.getElementsByClassName = function(className)
		{
			var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
			var allElements = document.getElementsByTagName("*");
			var results = [];

			var element;
			for (var i = 0; (element = allElements[i]) != null; i++) {
				var elementClass = element.className;
				if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
					results.push(element);
			}

			return results;
		}
	}
}

function showDirections( id ){
	
	for( var i = 0; i < 3; i++ ){
		var div = document.getElementById( "directions"+i );
		var img = document.getElementById( "arrow"+i );
		if( i == id ){
			if( div ){
				if( div.style.display == "none" ){
					div.style.display = "";
					img.src = "images/down-arrow.gif";
				}
				else {
					div.style.display = "none";
					img.src = "images/right-arrow.gif";
				}
			}
		}
		else {
			div.style.display = "none";
			img.src = "images/right-arrow.gif";
		}
	}
	return 1;
	
}

function showGallery( id ){
	var els = document.getElementsByClassName( 'gallery' );
	for (i = 0; i < els.length; i++){
		var img = document.getElementById( "arrow"+i );
		if( els[i].id == id ){
			if( els[i].style.display == "none" ){
				els[i].style.display = "";
				img.src = "images/down-arrow.gif";
			}
			else{
				els[i].style.display = "none";
				img.src = "images/right-arrow.gif";
			}
		}
		else {
			els[i].style.display = "none";
			img.src = "images/right-arrow.gif";
		}
	}
}

var $j = jQuery.noConflict();
var weather = 0;
var totalWeathers = 3;
function slideMe(obj){
    $j(".slideMe:visible").slideUp("slow");
    $j(".slideDown").removeClass("arrowDown");
    $j(".slideDown").addClass( "arrowUp");
    var cur = $j(obj).parent().find(".slideMe");
    //alert( cur.css("display"));
    if( cur.css("display") == "none" ){
        cur.slideDown("slow");
        $j(obj).toggleClass("arrowUp");
        $j(obj).toggleClass("arrowDown");

    }
}

function hideWeather(){
    //$j(".weather:visible").fadeOut("slow");
    //$j("#weather"+id).fadeIn("slow");
    $j(".weather:visible").fadeOut( "slow", showWeather() );
    

    
}

function showWeather(){
   //$j("#weather:visible").css("display","none");
  // $j("#weather"+weather).css("display",""); 
   $j("#weather"+weather).fadeIn( "slow", function(){
        //$j(this).style.removeAttribute("filter");
   } );
   

   weather++;
}



$j(document).everyTime(5000, function() {
    if( weather == totalWeathers ) weather = 0;
    hideWeather( );
});

$j(document).everyTime(15000, function() {
    $j.post("specialsadmin.php",{func:"rand"},function(data){
        if( data.success ){
            $j("#specials").slideDown("slow");
            $j("#specials").html("<h3>"+data.title+"</h3><p>"+data.info+"</p>");
        }
        else {
            $j("#specials").slideUp("slow"); 
        }
    },"json");
});

$j(document).ready(function() {
    $j( 'a[rel*=lightbox]').lightBox(); 
    
    $j("#headings span").livequery("click", function(e){
           
           //hide all content           
           $j(".content")
           .fadeTo('slow',0)
           .css("display",'none') 
           ;
                   
           //show the id value that's been clicked
           $j('#'+ e.target.id + "_content")
           .css("opacity",0)
           .css("display",'') 
           .fadeTo('slow',1)
           ;
      
    });
    
    $j("#specials").livequery("click", function(){
        window.location = "contact.php";
    });
    
    $j.post("specialsadmin.php",{func:"rand"},function(data){
        if( data.success ){
            if( "'.$this->name.'" == "Home" ){
                $j("#specials").slideDown("slow");
            }
            else {
                $j("#specials").css("display","");
            }
            $j("#specials").html("<h3>"+data.title+"</h3><p>"+data.info+"</p>");
        }
        else {
            
            $j("#specials").slideUp("slow"); 
        }
    },"json");
    slideMe($j(".slideDown[name='showFirst']"));
    
    $j(".slideDown").click( function(){ slideMe(this); });
    
    $j(".imgFade").fadeTo("fast", 0.7 );
    $j(".imgFade").mouseenter( function() {
        $j(this).fadeTo("slow", 1.0 );
    });
    
    $j(".imgFade").mouseleave( function() {
        $j(this).fadeTo("slow", 0.7 );
    });
    
   /* $j(".weather").click( function(){
        var id = $(this).next().attr('id');
        id = id.substr( 7 );
        alert( id );
        showWeather( $(this).next().attr("weatherid"));
    });*/
    
    showWeather( );
    
    $j(".reviewHide").css("display","none");
    
    $j("#content a.showReview").click( function(){
        var id= $j(this).attr("href");
        $j(this).hide("fast");
        $j("#reviewHide"+id).slideDown("slow");
        return false;
    });
    
    $j("#content a.hideReview").click( function(){
        var id= $j(this).attr("href");
        $j("#showReview"+id).show("fast");
        $j("#reviewHide"+id).slideUp("slow");
        return false;
    });
    
    $j(".text").livequery( function(){
        if( $j(this).attr("origVal")){
            $j(this).val($j(this).attr("origVal"));
        }
    });
    
    $j(".text").livequery('focus', function(){
        //alert( $j(this).val());
        if( $j(this).val() == $j(this).data('orig')){
            $j(this).val("");
            
        }
        $j(this).css("color","#000" );
    });
    
    $j(".text").livequery(function(){
        $j(this).data( 'orig', $j(this).attr('value') );
    });
    
    $j(".text").livequery( 'blur', function(){
        if( $j(this).val() == ""){
            $j(this).val($j(this).data('orig'));
            
        }
        $j(this).css("color","#707070" );
    });
    
    
    
            
    bindSpecials();        

    
});


/* This shouldn't have to be used but for some reason I was having trouble
     with events not rebinding after ajax content was added... really weird
*/
function bindSpecials(){
    $j('#specialsList img.sdelete').unbind('click');
    $j('#specialsList img.sdelete').livequery('click', function(){
        var id = $j(this).attr('sid');
        $j(this).css( 'display', 'none' );
       // alert( id );
        $j.post('specialsadmin.php',{func:'delete',id:id},function(data){
                $j('li[sid='+id+']').remove();
        },"html" );
         
    });
    
    $j('#specialsList img.edit').unbind('click');        
    $j( '#specialsList img.edit').livequery(  'click', function(){
        $j.post( 'specialsadmin.php', {func:'edit', id:$j(this).attr('sid') }, function( data ){
            $j( '#formholder' ).html( data );
            bindSpecials();
        },"html" ); 
    });
    
    $j('#specialsList img.active').unbind('click');        
    $j( '#specialsList img.active').livequery(  'click', function(){
        $j.post( 'specialsadmin.php', {func:'active', id:$j(this).attr('sid') }, function( data ){
             $j(data.selector).html(data.content);
             bindSpecials();
        },"json" ); 
    });
    
    $j('#formholder form').unbind('submit'); 
    $j( '#formholder form' ).livequery( 'submit', function(e){
       e.preventDefault();     
        var items = $j(this).serialize();
        var post = "func="+$j(this).attr('action')+"&"+items;
        $j.post('specialsadmin.php', post ,function(data){
               $j(data.selector).html(data.content);
               bindSpecials();
        },"json" );
        return false; 
        
    });    
}