/**
* Small extensions/helper functions for the jquery library
* @Maya Feb 2010
**/

$.extend({
	
	postScript:function(url,data,type,callback){
		type = type || 'html';//possible datatypes: xml,html,script,json
		$.ajax({
			type:"POST",
			url:url,
			dataType:type,
			data:data,
			complete:function(req,stat){
				if(typeof callback == 'function'){
					return callback(req,stat);
				}
			}
		});
	},

	appendCSS:function(cssurl,options){
		if(cssurl == null || typeof(cssurl) != 'string'){
			return;
		}
		options = options || {};
		options.media = (typeof(options.media) == 'undefined' ? 'screen' : options.media);
		var sheet = document.createElement('link');
		sheet.type = 'text/css';
		sheet.media = options.media;
		sheet.rel = 'stylesheet';
		sheet.href = cssurl;
		$('head').append(sheet);
	},
	
	appendJS:function(jsurl){
		if(jsurl == null || typeof(jsurl) != 'string'){
			return;
		}
		var js = document.createElement('script');
		js.type = 'text/javascript';
		js.charset = 'utf-8';
		js.src = jsurl;
		$('head').append(js);
	}
});
