/**
 * @author Paul Chan / KF Software House 
 * http://www.kfsoft.info
 *
 * Version 0.5
 * Copyright (c) 2010 KF Software House
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
	
(function($) {

    var _options = null;

	jQuery.fn.MyLoading = function(options) {
		_options = $.extend({}, $.fn.MyLoading.defaults, options);
		$("body").append("<img style='position:absolute;top:-1000px' src='" + _options.loadingImgPath + "'>");
		
		return this.each(function()
		{
			$(this).click(function(event){
				$("#myLoadingImg").remove();
				var href = $(this).attr('href');
				var target = $(this).attr("target");
				
				if (target=="")
				{
					var winHeight = $(window).height();
					$(this).append(" <span id=myLoadingImg><img style='border:0px' src='" + _options.loadingImgPath + "'></span>");
					
					if (_options.bFadeoutPage)
					{
						$("body").fadeTo('slow', 0.6);	
					}
					
				}
				
			});
			
		});

		function goLink(href)
		{
			window.location.href = href;
		}
	}
	
	//default values
	jQuery.fn.MyLoading.defaults = {
		loadingImgPath: 'load.gif',
		bFadeoutPage: true
	};
})(jQuery);

