/**
 * Opens popup window.
 */
function openPopup(url) {
	window.open(url, 'mywindow', 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=no,resizable=yes,width=450,height=250');
}

/**
 * Go to the given URL without encoding the request parameters.
 */
function gotoNoEncoding(url) {
	document.location.href = url;
}

/**
 * Go to the given URL, encoding the request parameters.
 */
function goto(url) {
	document.location.href = encodeURL(url);
}

/**
 * Encode the request parameters in the URL (escape function).
 * DO NOT USE TO ENCODE PARAMS WITHOUT URL! Use escape() for this.
 */
function encodeURL(url) {
	var address = url.substring(0, url.indexOf('?') + 1);
	var query 	= url.substring(url.indexOf('?') + 1);
	
	var encodedQuery = "";
	var vars = query.split("&");
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		
		if (i != 0) 
			encodedQuery += '&';			
		encodedQuery += pair[0] + '=' + escape(pair[1]);
	}
	
	return address + encodedQuery;
}

/**
 * Get the value of the request parameter, decoding it first (unescape function).
 */
function getQueryVariable(varName) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == varName) {
			return unescape(pair[1]);
		}
	}
}