var replaySim = {
	projectId:null,
	amount:null,
	trackMsg:{
		msg1:'/simulation/resultats/ppr-ppc/modif-simul-ppr/',
		msg2:'/simulation/resultats/ppr-ppc/modif-simul-ppc/',
		msg3:'/simulation/resultats/ppc-ppr/modif-simul-ppc/',
		msg4:'/simulation/resultats/ppc-ppr/modif-simul-ppr/',
		msg5:'/simulation/resultats/ppc/div/mns/modif-simul-ppc/',
		msg6:'/simulation/resultats/ppc/div/dur/modif-simul-ppc/',
		msg7:'/simulation/resultats/ppc/tvx/mns/modif-simul-ppc/',
		msg8:'/simulation/resultats/ppc/vn/mns/modif-simul-ppc/',
		msg9:'/simulation/resultats/ppc/vo/mns/modif-simul-ppc/'
	},
	load:function(defaultprojectId, defaultAmount){
		if(typeof(tangane)!='undefined' && tangane){
			this.projectId = tangane.request.getParameter('chx');
			this.amount = tangane.request.getParameter('mtProjet');
		}
		if(this.projectId == null){
			this.projectId = defaultprojectId;
		}
		if(this.amount == null){
			this.amount = defaultAmount; 
		}
	},
	go:function(trackMsg, isPpr){
		this.tracking(trackMsg);
		var referrerUrl = document.referrer;
		var projTyp, amount;
		if(referrerUrl.length != 0 && typeof(tangane)!='undefined' && tangane){
			projTyp = tangane.request.getParameter('chx');
			projTyp = (projTyp == null) ? '' : '?chx='+projTyp;
			amount = tangane.request.getParameter('mtProjet');
			amount = (amount == null) ? '' : '&mtProjet='+amount;
			if(referrerUrl.indexOf("?") != -1){
				referrerUrl = referrerUrl.substring(0, referrerUrl.indexOf("?"));
			}
			window.location.href = referrerUrl + projTyp + amount;
		}
		else{
			if(typeof(mediatisSimulator)!='undefined' && mediatisSimulator){
				projTyp = '?chx=';
				amount = '&mtProjet=' + mediatisSimulator.getAmount();
				
				var projectIds = {'PPR':'01','VN':'03','VO':'04','TWX':'05','DIV':'02'};
				if(typeof(isPpr)!='undefined' && isPpr){
					projTyp += projectIds['PPR'];
				}
				else{
					projTyp += projectIds[mediatisSimulator.type];
				}
			}
			window.location.href = "/" + projTyp + amount;
		}
	},
	tracking:function(msg){
		urchinTracker(msg);
	}
}