function trim(str) {
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function closeAll() {
    for (i=0;i<WinId.length;i++) {
        if (WinId[i] && !WinId[i].closed) WinId[i].close();
    }
}

function PNGfile(sfile) {
return sfile;
}

function ajaxcall(method, vars, async) {
	$.ajax({
		type: "POST",
		url: "methods/" + method +".php",
		async: async,
		data: "force=" + dummy.getTime() + '&' + vars,
		datatype: "json",
		success: function(msg) {
			eval('response_' + method + '(msg)');
		}
	});
}

function modal_popup(msg, canclose) {
	$("<div>")
			.css({
				'position': 'absolute',
				'top': '0px',
				'left': '0px',
				backgroundColor: 'black',
				'opacity': '0.75',
				'width': '100%',
				'height': $(window).height(),
				zIndex: 5000
			})
			.appendTo("body");
			
		$('<p>' + msg + '</p>')
			.css({
				backgroundColor: 'white',
				'top': '50%',
				'left': '50%',
				marginLeft: -210,
				marginTop: -100,
				width: 410,
				padding: 20,
				height: 200,
				'position': 'absolute',
				zIndex: 6000
			})
			.appendTo("body");
}

function error_popup(msg) {
	alert(msg);
}

debug = (window.console && window.console.error);
$(document).ajaxError(function(){
	if (debug) {
		console.error(arguments);
	}
});
dummy = new Date();
