(function($){
	
/*
 * Email Defuscator - jQuery plugin 1.0 alpha
 *
 * Copyright (c) 2007 Joakim Stai
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 *
 */

/**
 * Converts obfuscated email addresses into normal, working email addresses.
 *
 * @name defuscate
 * @param Boolean link If true, all defuscated email addresses will be turned into links, defaults to true (optional)
 * @descr Converts obfuscated email addresses into normal email addresses
 */

jQuery.fn.defuscate = function( settings ) {
    settings = jQuery.extend({
        link: true
    }, settings);
    var regex = /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi;
    return this.each(function() {
        if ( $(this).is('a[href]') ) {
            // If it's an <a> element, defuscate the href attribute
            $(this).attr('href', $(this).attr('href').replace(regex, '$1@$2'));
            // Make sure that the element's contents is not made into a link
            var is_link = true;
            //alert($(this).attr('href'));
        }
        // Defuscate the element's contents
        $(this).html($(this).html().replace(regex, (settings.link && !is_link ? '<a href="mailto:$1@$2">$1@$2</a>' : '$1@$2')));
  });
}


/*
 *	Copyright Date Upkeep - jQuery plugin 1.0
 *
 *	Copyright (c) 2010 Joshua Brown - Aztek
 */
 
/*	Checks the date inside the element that calls the function,
 *	compares it to the current date and changes the year if necessary.
 */

$.fn.copyright = function() {
	// get the text inside the element
	var date = this.text();
	// get the current year & compare it to the one in the element
	var year = new Date().getFullYear();
	if(year>date) {
	  this.text(year);
	}
}


/**
* Fullscreenr - lightweight full screen background jquery plugin
* By Jan Schneiders
* Version 1.0
* www.nanotux.com
**/
	
$.fn.fullscreenr = function(options) {
	if(options.height === undefined) alert('Please supply the background image height, default values will now be used. These may be very inaccurate.');
	if(options.width === undefined) alert('Please supply the background image width, default values will now be used. These may be very inaccurate.');
	if(options.bgID === undefined) alert('Please supply the background image ID, default #bgimg will now be used.');
	var defaults = { width: 1280,  height: 1024, bgID: 'bgimg' };
	var options = $.extend({}, defaults, options); 
	$(document).ready(function() { $(options.bgID).fullscreenrResizer(options);	});
	$(window).bind("resize", function() { $(options.bgID).fullscreenrResizer(options); });		
	return this; 		
};	
$.fn.fullscreenrResizer = function(options) {
	// Set bg size
	var ratio = options.height / options.width;	
	// Get browser window size
	var browserwidth = $(window).width();
	var browserheight = $(window).height();
	// Scale the image
	if ((browserheight/browserwidth) > ratio){
		$(this).height(browserheight);
		$(this).width(browserheight / ratio);
	} else {
		$(this).width(browserwidth);
		$(this).height(browserwidth * ratio);
	}
	// Center the image
	$(this).css('left', (browserwidth - $(this).width())/2);
	$(this).css('top', (browserheight - $(this).height())/2);
	return this; 		
};



/*
 * In-Field Label jQuery Plugin
 * http://fuelyourcoding.com/scripts/infield.html
 *
 * Copyright (c) 2009 Doug Neiner
 * Dual licensed under the MIT and GPL licenses.
 * Uses the same license as jQuery, see:
 * http://docs.jquery.com/License
 *
 * @version 0.1
 */
$.InFieldLabels=function(b,c,d){var f=this;f.$label=$(b);f.label=b;f.$field=$(c);f.field=c;f.$label.data("InFieldLabels",f);f.showing=true;f.init=function(){f.options=$.extend({},$.InFieldLabels.defaultOptions,d);if(f.$field.val()!=""){f.$label.hide();f.showing=false};f.$field.focus(function(){f.fadeOnFocus()}).blur(function(){f.checkForEmpty(true)}).bind('keydown.infieldlabel',function(e){f.hideOnChange(e)}).change(function(e){f.checkForEmpty()}).bind('onPropertyChange',function(){f.checkForEmpty()})};f.fadeOnFocus=function(){if(f.showing){f.setOpacity(f.options.fadeOpacity)}};f.setOpacity=function(a){f.$label.stop().animate({opacity:a},f.options.fadeDuration);f.showing=(a>0.0)};f.checkForEmpty=function(a){if(f.$field.val()==""){f.prepForShow();f.setOpacity(a?1.0:f.options.fadeOpacity)}else{f.setOpacity(0.0)}};f.prepForShow=function(e){if(!f.showing){f.$label.css({opacity:0.0}).show();f.$field.bind('keydown.infieldlabel',function(e){f.hideOnChange(e)})}};f.hideOnChange=function(e){if((e.keyCode==16)||(e.keyCode==9))return;if(f.showing){f.$label.hide();f.showing=false};f.$field.unbind('keydown.infieldlabel')};f.init()};$.InFieldLabels.defaultOptions={fadeOpacity:0.5,fadeDuration:300};$.fn.inFieldLabels=function(c){return this.each(function(){var a=$(this).attr('for');if(!a)return;var b=$("input#"+a+"[type='text'],"+"input#"+a+"[type='password'],"+"textarea#"+a);if(b.length==0)return;(new $.InFieldLabels(this,b[0],c))})};
	
	
})(jQuery);
