/*
	Zicht jQuery Tools
*/

;(function($){

	$.fn.pngfix = function () {	
		if ($.browser.msie && $.browser.version < 7) {
			return this.each (function () {
				$(this).css({
					filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.src+"')"
				});
				this.src = 'images/blank.gif';
			});
		} else {
			return this;
		}
	};

	$.prefetch = function () {
		for (var i=0; i<arguments.length; i++)  {
			$('<img>').attr('src', arguments[i]);
		}
	}

	$.fn.imghover = function () {
		return this.each (function () {
			$(this).data('__img__original', this.src);
			$.prefetch($(this).attr('data-hover'));
		}).hover(function(){
			this.src = $(this).attr('data-hover');
			$(this).pngfix();
		},function(){
			this.src = $(this).data('__img__original');			
			$(this).pngfix();
		});
	};

	$.fn.inputPlaceholder = function () {
		return this.each(function(){
			if ($(this).val() == '' || $(this).val() == $(this).attr('data-placeholder')) {
				$(this).val($(this).attr('data-placeholder'))
					.addClass('init');
			}
			$(this).focus(function(){
				if ($(this).val() == $(this).attr('data-placeholder'))
					$(this).val('').removeClass('init');
			}).blur(function(){
				if ($(this).val() == '') {
					$(this).val($(this).attr('data-placeholder'))
						.addClass('init');
				}
			});
		});
	};

})(jQuery);
