$.validator.messages.required = " ";
$.validator.messages.email = " A valid email is required";

$(document).ready(function () {


    //    $.preload(['s0', 's1', 's2', 's3', 's4', 's5', 's6'], {
    //        base: root + 'style/images/',
    //        ext: '.png'
    //    });

    //    $("#container").supersleight();

    m.i();




    $("#nav li").hover(
		function () {
		    $("ul", this).show();
		},
		function () {
		    $("ul", this).hide();
		}
	);


    $(".s1 , .s2 , .s3").hover(
		function () {
		   var img = $(this).parent().find(".master");
		   img.attr('src', img.attr("src").replace('_s1.png', '_s2.png'));
		},
		function () {
		    var img = $(this).parent().find(".master");
		    img.attr('src', img.attr("src").replace('_s2.png', '_s1.png'));
		}
	);

    var section = $('head').attr("rel");
    if (section) {
        var img$ = GetImage("nav", section);
        img$.addClass("on").attr('src', img$.attr("src").replace('_s1.png', '_s2.png'));
    }


    //    if ($("#cycle").exists()) {
    //        $('#cycle').cycle();
    //    }


    $(".button").button();

    $(".update").button("option", {
        icons: {
            primary: "ui-icon-circle-check"
        }
    });
    $(".cancel").button("option", {
        icons: {
            primary: "ui-icon-cancel"
        }
    });
    $(".add").button("option", {
        icons: {
            primary: "ui-icon-plusthick"
        }
    });
    $(".edit").button("option", {
        icons: {
            primary: "ui-icon-pencil"
        }
    });
    $(".delete").button("option", {
        icons: {
            primary: "ui-icon-trash"
        }
    });
    $(".reset").button("option", {
        icons: {
            primary: "ui-icon-refresh"
        }
    });

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

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

    $(".save").button("option", {
        icons: {
            primary: "ui-icon-circle-check"
        }
    });
    $(".print").button("option", {
        icons: {
            primary: "ui-icon-print"
        }
    });
    $(".calendar").button("option", {
        icons: {
            primary: "ui-icon-calendar"
        }
    });




});

$.fn.hoverClass = function (c) {
    return this.each(function () {
        $(this).hover(
			function () { $(this).addClass(c); },
			function () { $(this).removeClass(c); }
		);
    });
};
jQuery.fn.exists = function () { return jQuery(this).length > 0; }
m = {
    i: function () {
        $(".hover img:not(.exclude)").hover(function () {
            m.o(this);
        }, function () {
            m.ou(this);
        });
    },
    o: function (e) {

        if (!$(e).hasClass('on')) {
            m.si(e, $(e).attr('src').replace('_s1.png', '_s2.png'));
        }
    },
    ou: function (e) {
        if (!$(e).hasClass('on')) {
            m.si(e, $(e).attr('src').replace('_s2.png', '_s1.png'));
        }
    },
    si: function (e, s) {

        if ($.browser.msie && $.browser.version < 7) {
        } else {
            $(e).attr('src', s);
        }
    }
}
function GotoValidationSummary() {
    if (typeof (ValidatorOnSubmit) == "function") {
        var isValidated = ValidatorOnSubmit();
        if (!isValidated) {
            var pos = $("#validationsummary").show().position();
            window.scrollTo(pos.left, pos.top);
            return false;
        }
        return true;
    }
}
function GetImage(id, alt) {
    var img$ = $("#" + id + " img").filter(function (index) {
        return $(this).attr("alt") == alt;
    })
    return img$;
}
function GetByRel(id, rel) {
    var img$ = $("#" + id + " img").filter(function (index) {
        return $(this).attr("rel") == rel;
    })
    return img$;
}
