var duration = 800;
var status = "closed";
jQuery.validator.messages.required = "";
$(document).ready(function () {
    //    $(".text").hover(
    //        function () {
    //            $(this).animate({
    //                left: '0',
    //                width: '160'
    //            });
    //        },
    //        function () {
    //            if (!$(".master").hasClass("opened")) {
    //                $(this).animate({
    //                    left: '55',
    //                    width: '105'
    //                });
    //            }
    //        }
    //    );
    $(".masterc").click(function () {
        if (status == "opened") {

        } else {
            AnimateMenu();
            return false;
        }
    });


    //    ,
    //		function () {
    //		    $(".master").removeClass("opened");
    //		    $(this).nextAll().animate({
    //		        top: '0'
    //		    });
    //		    $(this).children('ul').slideUp(duration, function () {
    //		    });

    //		    $(".master .text").animate({
    //		        left: '55',
    //		        width: '105'
    //		    }, duration);
    //		}


    $(".hover").hover(
        function () {
            var o = $(this).find("img");
            var s = $(this).find("img").attr("src");
            o.attr("src", s.replace('_s1.jpg', '_s2.jpg'));
        },
        function () {
            var o = $(this).find("img");
            var s = $(this).find("img").attr("src");
            o.attr("src", s.replace('_s2.jpg', '_s1.jpg'));
        }
    );


    $(".button").button();
    $(".go").button("option", {
        icons: {
            primary: "ui-icon-circle-arrow-e"
        }
    });


    $("#aspnetForm").validate({
        ignore: ".ignore",
        focusInvalid: false,
        showErrors: function (errorMap, errorList) {
            if (this.numberOfInvalids() > 0) {
                $(".summary").html("Form contains " + this.numberOfInvalids() + " error(s).");
            }
            this.defaultShowErrors();

        },
        highlight: function (element, errorClass) {
            $(element).addClass("red");
        },
        unhighlight: function (element, errorClass) {
            $(element).removeClass("red");
        }
    });

    $("a.submit").click(function () {
        $(".summary").show();
        if ($("#aspnetForm").validate().form()) {
            $(".summary").hide();
            $("input.submit").click();
        }
        return false;
    });


    $(".modal").fancybox({
        autoDimensions: false,
        margin: 0,
        width: 940,
        height: 540,
        type: 'iframe'
    });
});
function AnimateMenu() {
    var p = $(".master");
    p.addClass("opened");
    p.nextAll().animate({
        top: '110'
    }, duration);
    p.children('ul').slideDown(duration, function () {
    });
    status = "opened";
    return false;
}

 
