/*
 * Equal Height 2.0
 * Andreas Lagerkvist
 * http://andreaslagerkvist.com/jquery/equal-height/
 */
jQuery.fn.equalHeight=function(){var height=0;var maxHeight=0;this.each(function(){height=jQuery(this).outerHeight();maxHeight=(height>maxHeight)?height:maxHeight});return this.each(function(){var t=jQuery(this);var minHeight=maxHeight-(t.outerHeight()-t.height());var property=jQuery.browser.msie&&jQuery.browser.version<7?'height':'min-height';t.css(property,minHeight+'px')})};

/**
 * Compact labels plugin
 */
(function($){$.fn.compactize=function(){return this.each(function(){var label=$(this),input=$('#'+label.attr('for'));input.focus(function(){label.hide();}).blur(function(){if(input.val()===''){label.show();}});window.setTimeout(function(){if(input.val()!==''){label.hide();}},50);});};})(jQuery);

/*
 * hrefID jQuery extention - returns a valid #hash string from link href attribute in Internet Explorer
 */
(function($){$.fn.extend({hrefId:function(){return $(this).attr('href').substr($(this).attr('href').indexOf('#'));}});})(jQuery);

/*
 * Scripts
 *
 */
jQuery(function($) {
 
	var Engine = {
		utils : {
			links : function(){
				$('a[rel*=external]').click(function(e){
					e.preventDefault();
					window.open($(this).attr('href'));						  
				});
			},
			mails : function(){
				$('a[href^=mailto:]').each(function(){
					var mail = $(this).attr('href').replace('mailto:','');
					var replaced = mail.replace('/at/','@');
					$(this).attr('href','mailto:'+replaced);
					if($(this).text() == mail) {
						$(this).text(replaced);
					}
				});
			}
		},
		forms : {
			labels : function(){
				$('div.join-a form.subscribe p label, div.forums-a form.a p label').compactize();
			}
		},
		design : {
			heights : function(){
				$('div.cols-b div.box-a').equalHeight();
			}
		}
	};

	Engine.utils.links();
	Engine.utils.mails();
	Engine.forms.labels();
	Engine.design.heights();
	
});
