jQuery.fn.defuscate = function(settings) {
	settings = jQuery.extend({link: true}, settings);
	regex = /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi;
	classes = $(this).attr("class");
	mailto = '<a href="mailto:$1@$2" class="'+classes+'">$1@$2</a>';
	plain = "$1@$2";
	return this.each(function() {
	defuscated = $(this).html().replace(regex, settings.link ? mailto : plain)
		$(this).after(defuscated).remove();
	});
};

jQuery.fn.checkHeight = function(){
  var $t = $(this);
  var $heightLast = $t.height();
  var $zoomed = 0;
  
  $('#mainNav .bg').css({'height':$heightLast-5+'px','opacity': 0.6});
  
  setInterval(function(){
    var $heightCurrent = $t.height();
    
    if ($heightCurrent != $heightLast) {
      $heightLast = $heightCurrent;
      $('#mainNav .bg').css({
        'height':($heightCurrent-5)+'px',
        'opacity': 0.6
      });
    }
  }, 100);
}


$(document).ready(function(){
	$("span.email").defuscate();
	$('#mainNav li:first').addClass('first');
	$('#mainNav li:first').checkHeight();
	
	$('#mainNav .hasSub').each(function(){
    if($(this).hasClass('act')) {
      $tx = $(this).parent().find('li.act>span:first,li.act>a:first').wrapInner('<span class="inner" />');
      $('body').addClass('isSub');
      $(this).find('.inner').append('<span class="dot" />');
    }
	})
});

$(document).ready(function() {
    $('.img').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
});

