/*!
 * (v) Compact labels plugin
 * Takes one option: labelOpacity [default: true] set to false to disable label opacity change on empty input focus
 */
(function($){$.fn.compactize=function(options){var defaults={labelOpacity:true};options=$.extend(defaults,options);

return this.each(function(){
  var label=$(this),input=$('#'+label.attr('for'));
  input.focus(function(){
    if(options.labelOpacity){
      if(input.val()===''){
        label.css('opacity','0');
      }
    }
    else{
      label.hide();
    } 
    input.addClass('bolder');
  });
  if(options.labelOpacity){
    input.keydown(function(){
      label.hide();
      label.css('opacity',1);}
      );
  } 
  input.blur(function(){
    input.removeClass('bolder');
    if(input.val()===''){
      label.show(); 
    } 
    if(options.labelOpacity){
      label.css('opacity',1);
    }
  });
  window.setTimeout(function(){label.toggle(input.val()==='');},50);});};})(jQuery);

/*!
 * (v) 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().toLowerCase() == mail) {
						$(this).text(replaced);
					}
				});
			},
			labels : function(){
				$(".contact-form label, .apply-form label").compactize();
			}
		}
	};

	Engine.utils.links();
	Engine.utils.mails();
	Engine.utils.labels();
});
