﻿jQuery.fn.equalHeight = function(resetHeights) {
	if (resetHeights == undefined) {
		resetHeights = false;
	}
	if (resetHeights) {
		this.height("auto");
	}
	var maxHeight = 0;
	this.each(function() {
		if ($(this).height() > maxHeight) {
			maxHeight = $(this).height();
		}
	});
	this.height(maxHeight);
};

jQuery.fn.center = function() {
	this.css("position", "absolute");
	this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
	this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
	return this;
}

jQuery.fn.equalMinHeight = function() {
	var maxHeight = 0;
	this.each(function() {
		if ($(this).height() > maxHeight) {
			maxHeight = $(this).height();
		}
	});
	if ($(".ie6,.ie7").length) {
		this.height(maxHeight);
	}
	else {
		this.css({ 'min-height': maxHeight });
	}
};

// --- Regular expression to check target location of a link// Creating custom :external selector
$.expr[':'].external = function(obj) {
    try {
        return !obj.href.match(/^mailto\:/)
	        && !(obj.href.indexOf("javascript") == 0)
	        && !(obj.href == "#")
            && (obj.hostname != location.hostname);
    }
    catch (exception) {
        if (exception.message = "A security problem occurred.") {
            return false;
        }
        else {
            throw(exception);
        }
    }
};
