﻿$(document).ready(function () {



    // initMenu();

    $.embedSwf();

    $('.gallery a').lightBox();

    if ($('.left_menu').length != 0) {
        initMenu();
    }
    initGuestBook();

    //if ($('#search_form').length != 0) {
    //  initSearch()
    //}

    iniSlideshow();


    $(".enablebillingaddress input").click(
        function (event) {
            
            if ($(this).is(':checked')) {
                $(".billingaddressfield").attr("disabled", "disabled");

               
            } else {
                $(".billingaddressfield").attr("disabled", "");
            }

        }

    );
});

function initGuestBook() {
    $(".btnReact").click(function (event) {
        var item = $("#" + $(this).attr('id') + "_form");
        if (!item.is(':visible')) {
            $(".react").slideUp()
            item.slideDown()
        }

        event.stopPropagation();
        event.stopImmediatePropagation();

        return false;
    });
}

function initMenu() {
    $('.left_menu li ul').hide();
    $('.left_menu li span').click(
        function() {
            var checkElement = $(this).next();
            if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
                checkElement.slideUp('normal');
                return false;
            }
            if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
                $('.left_menu ul:visible').slideUp('normal');
                checkElement.slideDown('normal');
                return false;
            }
        });
}

function iniSlideshow() {
    if ($('#slideshow').length > 0) {
        var flashvars = {};
        flashvars.siteUrl = siteUrl;
        flashvars.photoUrl = siteUrl + 'photos.xml';
        flashvars.configUrl = siteUrl + 'config.xml';
        flashvars.sort = 0;
        var params = {};
        params.wmode = 'transparent';
        var attributes = {};
        swfobject.embedSWF('' + siteUrl + 'transitions.swf?t=' + new Date().getTime(), 'slideshow', '239', '451', '9.0.0', false, flashvars, params, attributes);
    }
}
