

/**************************************
@Clase jsRecordControl
***************************************
@Autor: jmartin@inout.tv
@Fecha: 2008/08/26
*/

var jsRecordControl = Class.create();

jsRecordControl.prototype = {
	/**********************************************************************************************
	* Construct
	**********************************************************************************************/
	initialize: function(){},
	/**********************************************************************************************
	* whoIam
	**********************************************************************************************/
	whoIam: function(){
		alert("jsRecordControl.js");
	},
	step1: function(UserId,IdEvent,Channel,Titles,mydate,command,couponId){
				initialHTML='<div id="panelPopupContent"></div>'; 
			  p = Create.popup(initialHTML,'panelPopup',-1,false,"contained");
				p.center();
		    if (UserId=='-'){
  			  	this.drawUserPass(UserId,IdEvent,Channel,Titles,mydate,command,couponId);
			  }
			  else{
			  	var user2="-";
			  	var pass2="-";
			  	this.step2(UserId,IdEvent,Channel,Titles,mydate,command,couponId,user2,pass2);
			  }	
	},
	drawUserPass : function(UserId,IdEvent,Channel,Titles,mydate,command,couponId){
				this.ajx = new clsAjx()
				this.ajx_TxtCargando="... cargando ...";
				var params = "do=ajax@Grabar&accion=drawNoValidate&UserId="+UserId+"&IdEvent="+IdEvent+"&Channel="+Channel+"&Titles="+Titles+"&mydate="+mydate+"&command="+command+"&couponId="+couponId;
				this.ajx.setTxtCargando("&nbsp;&nbsp;Cargando...");
				this.ajx.objOwner = this;
				this.ajx.setValores(params);
				this.ajx.setURL("index.php");
				this.ajx.ResultinTA(false);
				this.ajx.setCapa("panelPopupContent");
				this.ajx.setCallBack("");
				this.ajx.runAjx();
	},
	checkUser: function(UserId,IdEvent,Channel,Titles,mydate,command,couponId,user,pass){
	      
	      if (document.getElementById("usuario2"))
		    	var user=document.getElementById("usuario2").value;
		    if (document.getElementById("password2"))	
		    	var pass=document.getElementById("password2").value;
				this.ajx = new clsAjx()
				this.ajx_TxtCargando="... cargando ...";
				var params = "do=ajax@Grabar&accion=getCheckUser&usuario="+user+"&password="+pass+"&UserId="+UserId+"&IdEvent="+IdEvent+"&Channel="+Channel+"&Titles="+Titles+"&mydate="+mydate+"&command="+command+"&couponId="+couponId+"&user="+user+"&pass="+pass;
				this.ajx.setTxtCargando("&nbsp;&nbsp;Cargando...");
				this.ajx.objOwner = this;
				this.ajx.setValores(params);
				this.ajx.setURL("index.php");
				this.ajx.ResultinTA(false);
				this.ajx.setCapa("panelPopupContent");
				this.ajx.setCallBack("");
				this.ajx.runAjx();
	},
	step2: function(UserId,IdEvent,Channel,Titles,mydate,command,couponId,user,pass){
				this.ajx = new clsAjx()
				this.ajx_TxtCargando="... cargando ...";
				var params = "do=ajax@Grabar&accion=getPVRUser&UserId="+UserId+"&IdEvent="+IdEvent+"&Channel="+Channel+"&Titles="+Titles+"&mydate="+mydate+"&command="+command+"&couponId="+couponId+"&user="+user+"&pass="+pass;
				this.ajx.setTxtCargando("&nbsp;&nbsp;Cargando...");
				this.ajx.objOwner = this;
				this.ajx.setValores(params);
				this.ajx.setURL("index.php");
				this.ajx.ResultinTA(false);
				this.ajx.setCapa("panelPopupContent");
				this.ajx.setCallBack("");
				this.ajx.runAjx();
	},
	step3: function(UserId,IdEvent,Channel,Titles,mac,mydate,command,couponId,user,pass,prodDesc,pid){
		    this.ajx = new clsAjx()
				this.ajx_TxtCargando="... cargando ...";
				var params = "do=ajax@Grabar&accion=getAccept&UserId="+UserId+"&IdEvent="+IdEvent+"&Channel="+Channel+"&Titles="+Titles+"&mac="+mac+"&mydate="+mydate+"&command="+command+"&couponId="+couponId+"&user="+user+"&pass="+pass+"&prodDesc="+prodDesc+"&pid="+pid;
				this.ajx.setTxtCargando("&nbsp;&nbsp;Cargando..."+params);
				this.ajx.objOwner = this;
				this.ajx.setValores(params);
				this.ajx.setURL("index.php");
				this.ajx.ResultinTA(false);
				this.ajx.setCapa("panelPopupContent");
				this.ajx.setCallBack("");
				this.ajx.runAjx();
	} ,
	step4: function (UserId,IdEvent,Channel,Titles,mac,mydate,command,couponId,user,pass,pid){
		 		this.ajx = new clsAjx()
				this.ajx_TxtCargando="... cargando ...";
				var params = "do=ajax@webRecordingManager&accion=addRecording&UserId="+UserId+"&IdEvent="+IdEvent+"&Channel="+Channel+"&Titles="+Titles+"&mac="+mac+"&mydate="+mydate+"&command="+command+"&couponId="+couponId+"&user="+user+"&pass="+pass+"&pid="+pid;
				this.ajx.setTxtCargando("&nbsp;&nbsp;Cargando...");
				this.ajx.objOwner = this;
				this.ajx.setValores(params);
				this.ajx.setURL("index.php");
				this.ajx.ResultinTA(false);
				this.ajx.setCapa("panelPopupContent");
				this.ajx.setCallBack("");
				this.ajx.runAjx();
	},
	validateInWeb: function (usuario, pass){
				var params="do=Usuario&accion=login&usuario="+usuario+"&password="+pass;
				this.ajx = new clsAjx()
				this.ajx_TxtCargando="... cargando ...";
				this.ajx.setTxtCargando("&nbsp;&nbsp;Cargando...");
				this.ajx.objOwner = this;
				this.ajx.setValores(params);
				this.ajx.setURL("index.php");
				this.ajx.ResultinTA(false);
				this.ajx.setCapa("panelPopupContent");
				this.ajx.setCallBack("");
				this.ajx.runAjx();
				window.location.reload()
				//window.history.go(0); 
	},
	conditionsuse: function(UserId,IdEvent,Channel,Titles,mac,mydate,command,couponId,pass2,user){
				this.ajx = new clsAjx()
				this.ajx_TxtCargando="... cargando ...";
				var params = "do=ajax@Grabar&accion=getConditions&UserId="+UserId+"&IdEvent="+IdEvent+"&Channel="+Channel+"&Titles="+Titles+"&mac="+mac+"&mydate="+mydate+"&command="+command+"&couponId="+couponId+"&user="+user+"&pass="+pass2;
				this.ajx.setTxtCargando("&nbsp;&nbsp;Cargando...");
				this.ajx.objOwner = this;
				this.ajx.setValores(params);
				this.ajx.setURL("index.php");
				this.ajx.ResultinTA(false);
				this.ajx.setCapa("panelPopupContent");
				this.ajx.setCallBack("");
				this.ajx.runAjx();
	}

};


function remoteRecord(UserId,IdEvent,Channel,Titles,mydate,command,couponId){
	 var control= new jsRecordControl();
	 mydate=mydate.replace("_"," ");
   control.step1(UserId,IdEvent,Channel,Titles,mydate,command,couponId);
}
