var jj = jQuery.noConflict();
var itemCount;
function addMenuClass(el){
    var countEl = jj('> li', el).length - 1;
    jj('> li:eq(0)', el).addClass('first');
    jj('> li:eq('+ countEl +')', el).addClass('last');            
};
jj(document).ready(function() {
    itemCount = jj('.video-nav li').length;
    
    jj('.menu').each(function(){        
        addMenuClass(jj(this));
        
        var mainParent = jj(this);
        var countElParent = jj('ul', mainParent).length;
        if( countElParent > 0) {
            while (countElParent > 0) {                
                newEl = jj('ul:eq(' + (countElParent-1) + ')', mainParent);
                addMenuClass(newEl);
                countElParent--;
            }
        }
    });
     jj('#dinner_menu').each(function(){
        addMenuClass(jj(this));
     });
    jj("input[type='text'], textarea").mouseup(function(e) {
        e.preventDefault();
    });
    jj("input[type='text'], textarea").focus(function(e) {
        if (jj(this).val() == jj(this).attr("defaultValue")) jj(this).val('');
    }).blur(function(e) {
        if (jj(this).val() == "") jj(this).val(jj(this).attr("defaultValue"));
    });

    var showConteiner = jj('.special');
    function toggleConteiner(el){
        jj('.description', el).toggle().css('top',jj(el).outerHeight() - 5);
    };
    var timerShow;
    jj('span', showConteiner).hoverIntent(
        function(){            
            parEl = jj(this).parent();
            //function setShow(){
                toggleConteiner(parEl);
            //}
            //timerShow = setTimeout(setShow,300);
            
        },
        function(){
            toggleConteiner(parEl);
            //clearTimeout(timerShow);
        }
    );
    
    /* jj("a.cboxElementEmbed").colorbox({inline:true, href:".main_image .desc p object", onComplete: function() {
            var id = jj('#cboxLoadedContent p > object').attr('id');            
            swfobject.registerObject(id, "9.0.115");
    }});*/
  /*  var src;
    jj('a.cboxElementEmbed').click(function(){
      src = jj(this).attr('href');
    });*/
    jj("a.cboxElementEmbed").colorbox({
        width: 515,
        height: 355,
        iframe: true,
        opacity: 0.5
    });

    jj("a.cboxElement:not(.cboxElementEmbed)").colorbox({
        opacity: 0.5
    });

    jj('#slider_next').click(function(){    
      var index = jj('.video-nav .active').index();     
      index++;
      if(index > (itemCount-1)) index = 0;
      jj('.image_thumb ul li:eq(' + index +')').click();
    });

    jj('#slider_previous').click(function(){
      var index = jj('.video-nav .active').index();
      index--;
      if(index < 0) index = (itemCount-1);
      jj('.image_thumb ul li:eq(' + index +')').click();
    });
  
});

