(function($){
     $.fn.extend({
          addInput: function (options) {
               return this.each(function() {
				   var form = $(this);
				   if ( form[0].nodeName.toLowerCase() == 'form') {
					   for(var name in options){
						   form.append($('<input type="hidden" />').attr({'name' : name, 'value' : options[name] }));
					   }
				   }
                    return form;
               });
          }
     });
})(jQuery);

var cfx={};
cfx.uriLib='js/';
cfx.loadLib=function(lib, notUri){
	if(!notUri)lib = cfx.uriLib.concat(lib);
	$.ajaxSetup({ cache:true });
  	$('head').append($('<script type="text/javascript"></script>').attr({ src:lib }));

}
cfx.loadCSS=function(lib, notUri){
	if(!notUri)lib = cfx.uriLib.concat(lib);
	$.ajaxSetup({ cache:false });
  	$('head').prepend($('<link rel="stylesheet" type="text/css">').attr({ href:lib }));

}
cfx.swin_list=new Array();
cfx.swin_show=false;
cfx.swin_close=function(options){
	var settings = {
			show_b :false
		};
	options = $.extend(settings, options);
	var wb=$('#swin_b');
	var wt=$('#swin_t');
	if(cfx.swin_list.length){
		cfx.swin_show=false;
		var txt = cfx.swin_list.shift();
		cfx.swin(txt);
		return;
	}
	cfx.swin_show=false;
	wt.fadeOut('slow',function(){ wt.html('') });
	if(options.show_b!=true)
	wb.fadeOut('slow');
}
cfx.swin=function(text, options){
	var settings = {
			inlist   	:false
		};
	options = $.extend(settings, options);
	if(!text)return;
	if(options){
		if(options.inlist){
			if(cfx.swin_show){
				cfx.swin_list.push(text);
				return;
			}
		}
	}
	cfx.swin_show=true;
	var wb=$('#swin_b');
	if (!wb.length){
	  	$(document.body).prepend('<div id="swin_b"></div>');
		wb = $('#swin_b');
		wb.bind('click', cfx.swin_close);
	}
	var wt=$('#swin_t');
	if (!wt.length){
	    $(document.body).prepend('<div id="swin_t"></div>');
		wt = $('#swin_t');
	}
	
	$('img',text).each(function(){
		var im=$(this);
		$(new Image()).load(function(){
			wt.center();
		}).attr({ src:im.attr('src')})
	});
	wt.fadeOut('fast',function(){
		wt.html(text).center().fadeIn('slow');
		if(!wb.is(":visible")){
			wb.show().fadeTo(0,0).fadeTo('slow', 0.7);
		}
	});
	
}
function loading_open(no, text, buttons){
	cfx.swin(text);
	
}
function loading_close(n){
	cfx.swin_close();
}
	
