include_once('ressources/class.user.inc');
	include_once('ressources/class.ini.inc');	
	
	if((isset($_GET["uid"])) && (!isset($_GET["userid"]))){$_GET["userid"]=$_GET["uid"];}
	
	if(!GetRights_aliases2()){
		$tpl=new templates();
		echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
		die();exit();
	
	}
	
	if(isset($_GET["popup"])){popup();exit;}
	if(isset($_GET["RecipientToAdd"])){SAVE();exit;}
	if(isset($_GET["usermap"])){usermap();exit;}
	if(isset($_GET["RedirectDelete"])){REDIRECT_DELETE();exit;}
	
js();


function js(){
	$page=CurrentPageName();
	$tpl=new templates();
	$title=$tpl->_ENGINE_parse_body("{inbound_parameters}");
	
	$html="
	function USER_RECIPT_LOAD(){
		YahooWin3(650,'$page?userid={$_GET["userid"]}&popup=yes','$title');
	}
	
	function RecipientToAddCheck(e){if(checkEnter(e)){RecipientToAdd();}}
    exit;
}
if (isset($_GET["popup"])) {
    popup();
    exit;
}
if (isset($_GET["RecipientToAdd"])) {
    SAVE();
    exit;
}
if (isset($_GET["usermap"])) {
    usermap();
    exit;
}
if (isset($_GET["RedirectDelete"])) {
    REDIRECT_DELETE();
    exit;
}
js();
function js()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $title = $tpl->_ENGINE_parse_body("{inbound_parameters}");
    $html = "\n\tfunction USER_RECIPT_LOAD(){\n\t\tYahooWin3(650,'{$page}?userid={$_GET["userid"]}&popup=yes','{$title}');\n\t}\n\t\n\tfunction RecipientToAddCheck(e){if(checkEnter(e)){RecipientToAdd();}}\n\t\nvar x_RecipientToAdd= function (obj) {\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);}\n\tUSER_RECIPT_LOAD();\n}\n\nfunction RecipientToAdd(){\n\tvar UserID='{$_GET["userid"]}';\n\tvar RecipientToAdd=document.getElementById('RecipientToAdd').value;\n\t\n\tdocument.getElementById('RecipientToAddID').innerHTML='<center style=width:100%><img src=img/wait_verybig.gif></center>';\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('RecipientToAdd',RecipientToAdd);\n\tXHR.appendData('MailAlternateAddress',document.getElementById('MailAlternateAddress').value);\n\tXHR.appendData('redirect_messages_to',document.getElementById('redirect_messages_to').value);\n\tXHR.appendData('uid',UserID);\n\tXHR.sendAndLoad('{$page}', 'GET',x_RecipientToAdd);\t\n\t\n}\n\tfunction HideRedirect(){document.getElementById('redirect_messages_to').disabled=true;}\n\t\n\tfunction RedirectDelete(id){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('RedirectDelete',id);\n\t\tXHR.sendAndLoad('{$page}', 'GET',x_RecipientToAdd);\t\t\n\t\n\t}\n\n\n\tUSER_RECIPT_LOAD();\n\t";
    echo $html;
}
function popup()
{
    $page = CurrentPageName();
    writelogs("USER_ACCOUNT::{$_GET["userid"]}", __FUNCTION__, __FILE__, __LINE__);