/**
 * 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);
					}
				});
			}
		},
		enhancements : {
			tabs : function(){
				$('div.tabs-a').each(function(){
					var triggers = $(this).find('ul.nav a');
					var tabs = $(this).find('div.tab');
					
					triggers.each(function(index){
						$(this).data('tab',tabs.eq(index));
					}).click(function(e){
						e.preventDefault();
						triggers.removeClass('active')
						tabs.removeClass('tab-active');						
						$(this).addClass('active').data('tab').addClass('tab-active');
					}).eq(0).triggerHandler('click');
				})
			}
		}
	};

	Engine.utils.links();
	Engine.utils.mails();

	Engine.enhancements.tabs();
	
});

