var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

$(function () {

    if (scripts_isIE6) $(document).pngFix();

    $('.ro').mbRollover();

    initDD();

    $("a[rel^='lightbox']").prettyPhoto({
        animationSpeed: 'slow',
        padding: 40,
        opacity: 0.85,
        showTitle: false,
        allowresize: true,
        counter_separator_label: '/',
        theme: 'light_rounded'
    });
});

function initDD() {

    $('.dd').bind('mouseover', jsddm_open);
    $('.dd').bind('mouseout', jsddm_timer);

    document.onclick = jsddm_close;

    $('.dd > ul > li').hover(function () {
        $(this).css('background-color', '#d3a63e');
        $(this).find("a").eq(0).css("color", "#fff");
        $(this).css('cursor', 'pointer');
    }, function () {
        $(this).css('background-color', '#b9ab84');
        $(this).find("a").eq(0).css("color", "#28251d");
    });

    $('.dd > ul > li').bind('click', function () {
        var url = $(this).find("a").eq(0).attr("href");
        window.location = url;
    });
}

function jsddm_open() {
    jsddm_canceltimer();
    jsddm_close();
    ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
}

function jsddm_close() {
    if (ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}

function jsddm_timer() {
    closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}
