;(function($){

	$.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);

// Fancybox popup wrapper
function openPopup(url, srcEle, width, height, callback){
	$.fancybox({
		type: 'iframe',
		href: url,
		titleShow: false,
		transitionIn: 'elastic',
		overlayColor: '#000',
		overlayOpacity: 0.4,
		padding: 10,
		width: width,
		height: height,
		orig: srcEle,
		scrolling: 'no',
		onStart: function(){ $('iframe').addClass('aid'); },
		onClosed: function(){ $('iframe').removeClass('aid'); },
		onComplete: callback || new Function()
	});
}
