$.fn.equals = function(compareTo) {
    if (!compareTo || !compareTo.length || this.length!=compareTo.length) return false;
    for (var i=0; i<this.length; i++) {
        if (this[i]!==compareTo[i]) return false;
    }
    return true;
}

var Site = {
    obj : {},
    
    // toolkit
    tk : {
        loadImg : function( path ) {
            var theImg = new Image();
            theImg.src = path;
        },
        
        whichChild : function( $child, $parent, $children ) {
            // if you have to determine children
            if ( typeof $children == 'undefined' ) {
                if ( typeof $parent == 'undefined' ) $parent = $child.parent();
                $children = $parent.children();
            }
            
            for ( var i = 0; i < $children.length; i++ ) {
                if ( $child.equals( $($children[i]) ) ) return i;
            }
        }
    },
    
    // restaurants page
    rs : {
        obj : {},
        
        init : function() {
            // preload back panel images
            Site.tk.loadImg('img/restaurant-page-backs.png');
            
            Site.rs.obj.panels = $('#restaurants div.panel', Site.obj.body);
            //Site.rs.obj.backPanels = $('div.back-panel', Site.rs.obj.panels);
            
            Site.rs.obj.panels.hover(function(ev) {
                var $this = $(this);
                
                $('div.back-panel', $this).fadeIn(100);
            }, function(ev) {
                var $this = $(this);
                
                $('div.back-panel', $this).fadeOut(150);
            });
        }
    }
};


$(function() {
    Site.obj.body = $('body');
    
    if ( Site.obj.body.hasClass('restaurants') ) Site.rs.init();
    
    $('input.input-hint').focus(function() {
        var $this = $(this);
        if ( $this.hasClass('input-hint') ) {
            $this.removeClass('input-hint');
            $this.val('');
        }
    });
});

var bergen = { src: 'swf/north-bergen.swf' };

sIFR.fitExactly = true;

sIFR.activate(bergen);
// red
sIFR.replace(bergen, {
  selector: '.special-red',
  css: '.sIFR-root { color: #DC1F25; text-deoration: none; }',
  wmode: 'transparent'
});

// brown
sIFR.replace(bergen, {
  selector: '.special, #content h1, #content h3, #sidebar h2, #sidebar h3, #content h4.special, #content h5.special',
  css: '.sIFR-root { color: #4F352C; text-deoration: none; }',
  wmode: 'transparent'
});

//white
sIFR.replace(bergen, {
  selector: '#content .white-text',
  css: '.sIFR-root { color: #FFFFFF; text-deoration: none; }',
  wmode: 'transparent'
});
