﻿/// <reference name="MicrosoftAjax.js"/>
/// <reference path="../services/ItemDispatch.asmx" />
/// <reference path="jquery/jquery-1.3.2-vsdoc2.js" />
/// <reference path="jquery/inlineEdit.js" />
/// <reference path="jquery/jquery.cycle.js" />
/// <reference path="jquery/jquery.metadata.js" />
/// <reference path="jquery/imageRotate.js" />



function hoverItemIn() {
    var item = $(".title", this);
    var itemRoll = $(".rollover", this);
    if ((item.queue("fx") != null && item.queue("fx").length == 0) &&
            (itemRoll.queue("fx") != null && itemRoll.queue("fx").length == 0) &&
            $(this).hasClass("ui-state-disabled") == false) {
        item.addClass('ui-state-hover');
        itemRoll.fadeTo('normal', 0.8, null);

    }
};

function hoverItemOut() {
    var item = $(".title", this);
    var itemRoll = $(".rollover", this);

    if (itemRoll.queue("fx") != null && itemRoll.queue("fx").length <= 1 &&
         $(".description", this).attr("contentEditable") != "true" &&
         !$( this ).hasClass("disable-hover-out")         
        ) {
        itemRoll.fadeTo('fast', 0, null);
        item.removeClass('ui-state-hover');
    }
};

$(document).ready(function() {
    /**
    Drop Down menus initilisation.
    */

    $(".dropdown > li").mouseenter(function() {
        $(this).addClass('ui-state-hover selected');
        //$(this).addClass('ui-state-hover');
        var menuItem = $("ul", this);
        /**if (menuItem.queue("fx") != null && menuItem.queue("fx").length == 0) {
        menuItem.show('normal', null);
        }*/
        //menuItem.stop();
        menuItem.show(0, null);
    });
    $(".dropdown > li").mouseleave(function() {
        $(this).removeClass('ui-state-hover selected');
        var menuItem = $("ul", this);
        //menuItem.stop();
        menuItem.hide(0, null);
    });

    /**
    TODO: Move this out of here into page specific js
    */
    /**
    Tag last item.    
    */
    $("#items > ul > li:last").addClass("lastItem");

    /**
    Tag hover items.
    */
    //$("#items > ul > li").addClass("hoveritem");

    /**
    Hover Item initilisation.
    */

    $(".hoveritem").hover(hoverItemIn, hoverItemOut);    

});
