function pref(html, prefhtml){
	padding = 20;
	if($("#prefs:hidden").length == 0){
		if(prefhtml != html){
			$("#prefs #chng").fadeOut("slow", function(){
				$("#prefs").height( ($("#prefs #chng").height() + padding ) );
				$("#prefs #chng").html(html);
				$("#prefs #chng").fadeIn("slow");
				$("#prefs").animate({
					height: $("#prefs #chng").height() + padding
				}, 400);
			});
		}else {
			prefh();
		}
	} else {

		$("#prefs #chng").html(html);
		
		if(window.execScript && !window.XMLHttpRequest)//IE lte 6
			$("#prefs").slideDown("slow");
		else 
			$("#prefs").fadeIn("slow");
		
		if(!window.execScript)//not IE
			$("#dark").fadeIn("slow");
		
		$("#prefs").height( ($("#prefs #chng").height() + padding) );
	}
	return html;
}

function prefh(){
	if(window.execScript && !window.XMLHttpRequest)//IE lte 6
		$("#prefs").slideUp("slow");
	else 
		$("#prefs").fadeOut("slow");
	
	$("#dark").fadeOut("slow");
}

function cmd(elem){
	path = elem.attr("href");
	
	args = new Object();
	
	if(path.indexOf('?') != -1){
		path = path.split("?")[1].split('&');
		
		l = path.length;
		for(var i = 0; i < l; i++){
			arg = path[i].split('=');
			args[arg[0]] =  urldecode(arg[1]);
		}
	}
	
	if(typeof args['msg'] == "undefined")
	args['msg'] = '';
	
	return args;
}

function urldecode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    
    var histogram = {};
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
 
    for (replace in histogram) {
        search = histogram[replace]; // Switch order when decoding
        ret = replacer(search, replace, ret) // Custom replace. No regexing   
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}

$(function(){		
	var prefhtml;
	
	$('html').click(function(event) {
		var $tgt = $(event.target);
		if ($tgt.is('input.close, #close, img#dark')) {
			prefh();
			return false;
		}
	});

});
