$(function() {
    // <IE7 Navigation
    if ($.browser.msie && $.browser.version < 7) {
        // Emulate menu hover
        $("#navigation li").mouseover(function() {
            $(this).addClass("hover");
        });
        $("#navigation").mouseout(function() {
            $("li", this).removeClass("hover");
        });
        // Style required labels
        $("span.required + label").addClass("required");
    }

    // Alternate row colours
    $("table.enhancedtable tr:even").addClass("even");
});
function resetAndHide(ele) {
    $("dd.mandatory").remove();
    $(ele).parents("form").hide();
}
function rotate_foo(banners) {
    this.rotate = function rotate() {
        var bg      = $("div#rotator div");
        var img     = $("div#rotator img:last");
        var rand    = banners.shift();
        banners.push(rand);

        var pic = new Image();
        pic.src = banners.shift();
        banners.unshift(pic.src);

        img.fadeOut("slow", function() {
            img.attr("src", rand);
            img.fadeIn("slow", function() {
                bg.css("background-image", "url(" + rand + ")");
            });
        });
    }

    setInterval(this.rotate, 4000);
}
function validate(form) {
    var valid = true;
    $("dd.mandatory").remove();
    $("#" + form + " :input.required").each(function() {
        if ($(this).val() === "") {
            if (valid) {
                // Give focus to the first invalid item
                $(this).focus();
            }
            $(this).parents("dd").after("<dd class='mandatory'>This is a required field</dd>");
            valid = false;
        }
    });
    $("#" + form + " :input.email").each(function() {
        if ($(this).val() !== "") {
            var isEmail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$/.test($(this).val());
            if (!isEmail) {
                if (valid) {
                    // Give focus to the first invalid item
                    $(this).focus();
                }
                $(this).parents("dd").after("<dd class='mandatory'>Please input a valid e-mail address</dd>");
                valid = false;
            }
        }
    });
    $("dd.mandatory+dd.mandatory").remove();
    return valid;
	
	
}
// VIDEO POP-UP
function popUp(url, w, h) {
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	popWindow = window.open (url, "mywindow", "location=0,status=1,scrollbars=0,width="+w+",height="+h+", top="+wint+", left="+winl);
}
