function User()
{var ana=this;ana.quotes={};ana.data={};ana.isLogged=false;ana.errorMessages={"_login":"Email o contraseña incorrectos.  Por favor, vuelve a intentarlo","_duplicateUser":"Este mensaje de correo electrónico ya las salidas"};this.init=function()
{}
var loginCallback=function(response,params)
{if(response.errorCode=='OK')
{ana.email=params.email;controller.user.quotes=response.quotes;controller.user.isLogged=true;controller.switchView('userpanel');}
if(response.errorCode=='AuthenticationError')
{alert(ana.errorMessages["_login"]);}}
var changeCallback=function(response,params)
{if(response.errorCode=='OK')
{ana.accessPwd=response.pwd
ana.accessCode=response.userCode;controller.switchView('accesscode');}
if(response.errorCode=='AuthenticationError')
{alert(ana.errorMessages["_login"]);}}
var registerCallback=function(response,params)
{if(response.errorCode=='OK')
{controller.results.quoteDef=response.QuoteDef;ana.email=params.email;controller.results.fetchResults('results','view',response.QuoteID);}
if(response.errorCode=='DuplicateUser')
{alert(ana.errorMessages["_duplicateUser"]);}}
this.login=function(email,password,login_type)
{if(email&&password)
ajax.requestPost('user','login',{email:email,password:password,login_type:login_type},loginCallback);else
alert("Introduce tu email y contraseña por favor");}
this.register=function(email,password)
{var module=ana.savingMode.module;var action=ana.savingMode.action;alert(callback);var callback=ana.savingMode.callback;var params={email:email,password:password};ajax.requestPost(module,action,params,callback);}
this.changeEmailPass=function()
{ana.savingMode={module:'user',action:'modify',callback:changeCallback};ajax.requestPost('user','modify',{},changeCallback);ajax.requestInvisiblePost("sessionFlow","saveIconClicked");}
this.newEmailPassword=function()
{ana.savingMode={module:'forms',action:'saving',callback:registerCallback};controller.switchView('saving');}
this.modifyQuote=function(qid)
{ajax.requestPost('quote','modify',{currentQuote:qid},function(response){controller.forms.quoteModifyCallback(response);controller.forms.gotoSummary('A','B');ajax.broadcast('clientRequest','redrawSummary');});}
this.modifyQuoteGeneral=function(qid,first,second)
{ajax.requestPost('quote','modify',{currentQuote:qid},function(response){controller.forms.quoteModifyCallback(response);controller.forms.gotoSummary('A','B');controller.forms.gotoSummary(first,second);});}
this.updateQuote=function(qid)
{ajax.requestPost('quote','modify',{currentQuote:qid},function(response){controller.forms.quoteModifyCallback(response);controller.results.fetchResults('results','view',qid,'quoteId');});}
this.newQuote=function(qid)
{ajax.requestPost('quote','new',{currentQuote:qid},function(response){controller.forms.quoteModifyCallback(response);controller.forms.gotoSummary('A','B');});}
this.deleteQuote=function(qid)
{ajax.requestPost('quote','delete',{currentQuote:qid},function(response)
{if(response.errorCode=='OK')
{ana.quotes.removeObjByParamVal('quoteID',qid);ajax.broadcast('clientRequest','redrawQuotes',{});}});}
this.refreshQuotes=function()
{ajax.requestPost('quote','refreshQuotes',null,function(response)
{if(response.errorCode=='OK')
{ana.quotes=response.quotes;}});}
this.enableBalloons=function(id)
{ana.hb1=new HelpBalloon({returnElement:true,title:'Non-Ajax Balloon',content:'This is an example of static balloon content.'});$(id).appendChild(ana.hb1._elements.icon);}}
if(controller)controller.user=new User();
