function AjaxDeleteSession(id){
	$.post('/ajax/delsess/'+id+'/', function(data){
		if(data != 'none'){
			alert(data);
		}
	});
}
function URLDecode (encodedString) {
    var output = encodedString;
    var binVal, thisString;
    var myregexp = /(%[^%]{2})/;
    while ((match = myregexp.exec(output)) != null
        && match.length > 1
        && match[1] != '') {
            binVal = parseInt(match[1].substr(1),16);
            thisString = String.fromCharCode(binVal);
            output = output.replace(match[1], thisString);
        }
    return output;
}
function getType(location, selected) {

    if(!selected) selected = '';
    
    document.getElementById('id_type').disabled = false;
    $("#id_type").removeOption(/./);
    
    $.getJSON('/ajax/get-types/' + location + '/',
    function(data){
        for(i=0; i<data.length; i++) {
            $('#id_type').addOption(data[i].name.replace(' ','-').replace(' ','-').toLowerCase(), data[i].name + " (" + data[i].count + ")");
        }
        if(selected != '') {
            $("#id_type").val(URLDecode(selected));
        } else {
            $("#id_type").val("");
        }
    });
}