function loginPopup(message, urlAfterLogin, selfAfterLogin) {
	if (typeof (urlAfterLogin) != 'undefined') {
		var expdate = new Date();
		expdate.setTime(expdate.getTime() + (1 * 60 * 1000)); // 1 min
		try{
			$.cookie('urlAfterLogin', urlAfterLogin, {
				path : '/',
				expires : expdate
			});
		}catch(err){
			
		}
	}
	if (typeof (selfAfterLogin) != 'undefined') {
		var expdate = new Date();
		expdate.setTime(expdate.getTime() + (1 * 60 * 1000)); // 1 min
		try{
			$.cookie('selfAfterLogin', selfAfterLogin, {
				path : '/',
				expires : expdate
			});
		}catch(err){
			
		}
	}
	var pagehtml = '';
	pagehtml += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
	pagehtml += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
	pagehtml += '<head>';
	pagehtml += '	<title>login</title>';
	pagehtml += '	<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />';
	pagehtml += '	<link href="' + ctx + '/css/ffl.css" type="text/css" rel="stylesheet" media="screen" />';
	pagehtml += '	<!--[if IE 7]>';
	pagehtml += '		<link href="' + ctx + '/css/ffl.ie7.css" rel="stylesheet" type="text/css" media="screen" />';
	pagehtml += '	<![endif]-->';
	pagehtml += '	<!--[if lt IE 7]>';
	pagehtml += '		<link href="' + ctx + '/css/ffl.ie6.css" rel="stylesheet" type="text/css" media="screen" />';
	pagehtml += '	<![endif]-->';

	pagehtml += '</head>';
	pagehtml += '<body class="popup">';
	pagehtml += '	<div id="popup">';
	pagehtml += '		<div id="popup_header"> </div>';
	pagehtml += '		<form method="POST" action="' + action + '">';
	pagehtml += '		<input type="hidden" name="loginChoice" value="1"/>';
	pagehtml += '		<input type="hidden" name="screen" value="save"/>';
	if (message)
		pagehtml += '			<h1>' + message + '</h1>';
	pagehtml += '			<label for="username">' + login + '</label>';
	pagehtml += '			<input type="text" id="username" name="username" class=""  />';

	pagehtml += '			<div class="clear"></div>';
	pagehtml += '			<div class="br5"> </div>';

	pagehtml += '			<label for="password">' + pass + '</label>';
	pagehtml += '			<input type="password" id="password" name="password" class="" />';

	pagehtml += '			<div class="clear"></div>';
	pagehtml += '			<div class="br17"> </div>';

	pagehtml += '			<hr />';

	pagehtml += '			<div class="fr"><input type="submit" id="popup_login" value="Login" /></div>';
	pagehtml += '			<input type="reset" id="popup_reset" value="Cancel" onclick="javascript:window.close();"/>';
	pagehtml += '			<div class="clear"></div>';
	pagehtml += '		</form>';
	pagehtml += '	</div>';
	pagehtml += '	<div class="popup_edge"> </div>';
	pagehtml += '</body>';
	pagehtml += '</html>';

	var pcw = window.open("", "Login", conf);
	pcw.document.write(pagehtml);

}
function decrypt_str(to_dec) {
	var dec_res = "";

	var key = parseInt(to_dec.substring(0, 1));
	for (i = 1; i < to_dec.length; i++) {
		dec_res += String.fromCharCode(key ^ to_dec.charCodeAt(i));
	}
	return dec_res;
}
function URLDecode(encoded) {
	// Replace + with ' '
	// Replace %xx with equivalent character
	// Put [ERROR] in output if %xx is invalid.
	var HEXCHARS = "0123456789ABCDEFabcdef";
	var plaintext = "";
	var i = 0;
	while (i < encoded.length) {
		var ch = encoded.charAt(i);
		if (ch == "+") {
			plaintext += " ";
			i++;
		} else if (ch == "%") {
			if (i < (encoded.length - 2)
					&& HEXCHARS.indexOf(encoded.charAt(i + 1)) != -1
					&& HEXCHARS.indexOf(encoded.charAt(i + 2)) != -1) {
				plaintext += unescape(encoded.substr(i, 3));
				i += 3;
			} else {
				// alert( 'Bad escape combination near ...' + encoded.substr(i)
				// );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
			plaintext += ch;
			i++;
		}
	} // while
	return plaintext;
};
