﻿$(document).ready(function() {    
    $("span.validation-error").bind("DOMAttrModified propertychange", function(e) {
        if (e.originalEvent.propertyName && e.originalEvent.propertyName != "isvalid") return;

        var controlToValidate = $("#" + this.controltovalidate);
        var validators = controlToValidate.attr("Validators");
        if (validators == null) return;

        var isValid = true;
        $(validators).each(function() {
            if (this.isvalid !== true) {
                isValid = false;
            }
        });

        if (isValid) {
            controlToValidate.removeClass("error");
        } else {
            controlToValidate.addClass("error");
        }
    });
    $('a[rel=new-window]').click(function() {
        window.open($(this).attr('href'));
        return false;
    });
    $('.ro').hover(function() {
        $(this).attr('src', $(this).attr('src').replace('.jpg', '_o.jpg'));
        $(this).attr('src', $(this).attr('src').replace('.png', '_o.png'));
    }, function() {
        $(this).attr('src', $(this).attr('src').replace('_o.jpg', '.jpg'));
        $(this).attr('src', $(this).attr('src').replace('_o.png', '.png'));
    });
});
