function registerCell(handlerObject) {
  this.pixel_attr_str         = handlerObject.init.pixel_attr_str;
  this.pixel_str              = handlerObject.init.pixel_str;
  this.GoSubmitUrlBase        = handlerObject.init.GoSubmitUrlBase;
  this.GoSubmitStore          = handlerObject.init.GoSubmitStore;
  this.GoSearchUrlBase        = handlerObject.init.GoSearchUrlBase;
  this.GoSearchStore          = handlerObject.init.GoSearchStore; 
  this.GoSearchUrlEnd         = handlerObject.init.GoSearchUrlEnd;
  this.step3Display           = handlerObject.init.step3Display;
  this.displayCarriersOverlay = handlerObject.init.displayCarriersOverlay;
  this.askForPinGeneralParams = handlerObject.askForPinInitArray;
  this.confirmPinArray        = handlerObject.confirmPinArray;
  this.reqUrlParams           = handlerObject.reqUrlParams;
  this.stepImages             = handlerObject.stepImages;
  this.blockedMatrix          = handlerObject.blockedCarriers;
  this.priceBlurbs            = handlerObject.priceBlurbs;
  this.disclaimers            = handlerObject.disclaimers;
  this.stepHeaders            = handlerObject.stepHeaders;
  this.miniCarriers           = handlerObject.miniCarriers;
  this.noCarriersArray        = new Array();
  this.dragTimer              = 0;
  this.stop                   = 0;
  this.w2w                    = 0;
  this.secsCounter            = 30;
  this.usr                    = '';
  this.pwd                    = '';
  this.pendingCell            = '';
  this.userCarrier            = '';

  var opzioni = {
		  setName:      'root',
		  rowName:      'result',
		  statusAttr:   null,
		  okValue:	null,
		  errorAttr:    null,
		  randomizeURL: true
	        };

  this.config = {
		  scriptBaseUrl: '/sso/',
		  registerScript: 'register.php',
		  confirmScript: 'register.php'
	        };

  this.dati = new Array();
}

registerCell.prototype.initialize = function(gp) {
  this.generalParams = gp;
  this.dati          = gp;
};

registerCell.prototype.setupPage = function() {
  if (!($('#formInsertCell').length > 0)) {
    alert('formInsertCell element doesn\'t exist! Please check html code');
    return false;
  }

  if(location.href.search(/mobi2/ ) != -1) {
    $( '#_test_buttons' ).style.display = 'block';
  }
  if($('#cell').length > 0) {
    $('#cell').onkeyup = function() {
      this.numTyped('#cell', $('#cell_1') ? '#cell_1' : '#cell' ,$('#cell').attr('maxlength'));
    };
  }
  if($('#cell_1').length > 0) {
    $('#cell_1').onkeyup = function() {
      this.numTyped('#cell_1', $('#cell_2') ? '#cell_2' : '#cell_1' ,$('#cell_1').attr('maxlength'));
    };
  }
  if($('#cell_2').length > 0) {
    $('#cell_2').onkeyup = function() {
      this.numTyped('#cell_2','#cell_2',$('#cell_2').attr('maxlength'));
    };
  }

  if (this.displayCarriersOverlay) {
    $.blockUI({
                     message: $("#carrier_area"),
                     css: { position: 'relative', top: '-730px', left: '0%', background: 'transparent', width: '773px', margin: '0 auto' , border: 'none', cursor: 'default'},
                     overlayCSS: {cursor: 'default'},
                     applyPlatformOpacityRules: false
                   });
  }else {
    $("#content").show();
  }

  return true;
};

registerCell.prototype.updateBlockedCarriers = function(carrierID) {
	
    var bc = this.blockedMatrix;
    this.noCarriersArray = bc[carrierID];
};

registerCell.prototype.updateStepHeader = function(stepObject) {
	
	$("#step_header").html("<img src='"+stepObject.src+"' id='step_image' class='border' alt='"+ stepObject.alt+"' title='"+stepObject.title+"' />")
    //$("#step_image").attr("src", stepObject.src);
    //$("#step_image").attr("alt", stepObject.alt);
    //$("#step_image").attr("title", stepObject.title);
};

registerCell.prototype.updatePriceBlurbs = function(carrierID) {
    var pb = this.priceBlurbs;

    if (pb[carrierID].showHideSwitchOn == "1") {
        // $(pb[carrierID].hideElementID).html("");
	$('#not_att_sprint_cell').html(this.stepHeaders.insertCell[this.userCarrier]);
        $(pb[carrierID].showElementID).html(pb[carrierID].blurbText);
		if(carrierID == "25"){
		$('#musica_logo').hide(); //if sprint. dont show musica.com logo
	
		}
		//alert('here');

		if(carrierID == "29" || carrierID == "31"){
		$('#pininfo').hide();
		$('.pinflds').hide();
		$('#VZWwrap').show();
		//alert('hertr');
		$('#pin').css({ display:'inline', position:'absolute'});
		/*$('#pin').removeClass('pinflds');
        $('#pin').addClass('pinfldsVZW');*
		$('#pin').css({ display:'inline'});*/
	
		//$('.pinfldsVZW').show();

	}



    }
	if ($('#carriers_list_cell').length > 0){
	$("#carriers_list_cell").html(this.miniCarriers[this.userCarrier]);
	}
};


registerCell.prototype.setCarrier = function(carrierID) {
    this.userCarrier = carrierID;
	
};

registerCell.prototype.askForPin = function() {
	
  var cell = $('#cell').val();
  if ($('#final_site').val() != ""){
    site = $('#final_site').val();
  }
  if ($('#cell_1').val() != "") {
    cell += $('#cell_1').val();
  }
  if( $('#cell_2').val() != "" ) {
    cell += $('#cell_2').val();
  }
  this.pendingCell = cell;
  
  var op = "";
  if ($('#op').val() != "") {
    op = $('#op').val();
  }

  var pars = "service="+this.generalParams['service'] + "&cellulare="+escape(this.pendingCell);

  if ($('#idwapldld').val() != "") {
    pars += "&id_wapdld="+$('#idwapldld').val();
  }
  if ($('#class').val() != "") {
    pars += "&class="+$('#class').val();
  }
  if (site) {
    pars += "&site="+site;
  }

  for (var key in this.generalParams) {
    if ($.inArray(key, this.askForPinGeneralParams) != -1) {
      if (this.generalParams[key]) {
        if (key == "referrer") {
          pars += "&specialoffer=" + this.generalParams[key];
        }else {
          pars += "&" + key + "=" + this.generalParams[key];
        }
      }
    }
  }

  pars += "&xml=1";
  pars += "&widget_mode=0";
  var pinUrl = this.config['scriptBaseUrl'] + this.config['registerScript'];

  var noCarriersString = this.noCarriersArray ? this.noCarriersArray.join("-") : "";
  pars += "&nocarriers=" + noCarriersString;

  this.askForPinRPC(pinUrl, pars.replace(/\+/,"%2b"), 'get');
  timerDrag();
  this.showWaitForPinMessage();
  return;
};

registerCell.prototype.askForPinRPC = function(pinUrl, params, m_type) {
  var nd = new Date();
  var tstamp = nd.getTime();
  var reqParams = params + "&tstamp=" + tstamp;
  var obj = this;
  $.ajax({
    url: pinUrl,
    type: m_type,
    dataType: 'xml',
    data: reqParams,
    error: function(){
      obj.hideAllMessages();
      $('#not_att_sprint_pin').html(obj.stepHeaders.insertCell[obj.userCarrier]);
	  if ($('#carriers_list_pin').length > 0){
		 $("#carriers_list_pin").html(obj.miniCarriers[obj.userCarrier]);
	  }
      $('#insertCell').fadeIn("slow", function(ev) { $('#generalError').show(); });
    },
    success: function(xml){
      var action_node;
      var status_i;
      var msg_title;
      var msg_desc;
      var code;
      var phone_company;
      var cellulare;
      var is_in_club;
      var is_in_life_love;
      var download;
      var mp3_url;

      $(xml).find('action').each(function(){
        action_node        = $(this).text();
        obj.dati['action'] = action_node;
      });
      $(xml).find('status').each(function(){
        status_i = $(this).text();
      });
      $(xml).find('msg_title').each(function(){
        msg_title             = $(this).text();
        obj.dati['msg_title'] = msg_title;
      });
      $(xml).find('msg_desc').each(function(){
        msg_desc             = $(this).text();
        obj.dati['msg_desc'] = msg_desc;
      });
      $(xml).find('code').each(function(){
        code             = $(this).text();
        obj.dati['code'] = code;
      });
      $(xml).find('phone_company').each(function(){
        phone_company             = $(this).text();
        obj.dati['phone_company'] = phone_company;
      });
      $(xml).find('cellulare').each(function(){
        cellulare             = $(this).text();
        obj.dati['cellulare'] = cellulare;
      });
      $(xml).find('is_in_club').each(function(){
        is_in_club             = $(this).text();
        obj.dati['is_in_club'] = is_in_club;
      });
      $(xml).find('is_in_life_love').each(function(){
        is_in_life_love             = $(this).text();
        obj.dati['is_in_life_love'] = is_in_life_love;
      });
      $(xml).find('download').each(function(){
        download             = $(this).text();
        obj.dati['download'] = download;
      });
      $(xml).find('mp3_url').each(function(){
        mp3_url             = $(this).text();
        obj.dati['mp3_url'] = mp3_url;
      });

      if (status_i) {
        status_i = status_i;
      }else {
        status_i = 'error';
      }

      obj.dati['status'] = status_i;

      switch(action_node) {
        case 'askPin':
          if(obj.dragTimer<100) {
            obj.dragTimer=0;
	    obj.Sleep(2);
          }
          obj.dragTimer=0;
          obj.askPinResponse();
          break;
        case 'confirmPin':
          obj.confirmPinResponse();
          break;
        case 'oppc':
          if (obj.dati['status'] == "OK") {
              var myform = document.runtimeFormName;
              var myparamspre = return_url.split("?");
              var myurl       = myparamspre[0];
              var myparams    = myparamspre[1].split("&");
              for (var fp in myparams) {
                  var fpar = myparams[fp].split("=");
                  var mypar = document.createElement("input");
                  mypar.setAttribute("type", "hidden");
                  mypar.setAttribute("name", fpar[0]);
                  mypar.setAttribute("id", fpar[0]);
                  mypar.setAttribute("value", fpar[1]);
                  myform.appendChild(mypar);
              }
              myform.setAttribute("method", "POST");
              myform.setAttribute("action", myurl);
              myform.setAttribute("id", "runtimeForm");
              myform.setAttribute("name", "runtimeFormName");
              myform.submit();
          }else {
              obj.askPinResponse();
          }
          break;
        case 'web2wap':
            if (obj.dati['status'] == "OK") {
              obj.showWaitForPinMessage();
              var interID   = setInterval(function() {
                                              if (obj.w2w <= 20) {
                                                  var ndn     = new Date();
                                                  var tstampn = ndn.getTime();
                                                  $.ajax({
                                                      url: "/sso/checkuser.php",
                                                      type: "GET",
                                                      dataType: 'xml',
                                                      data: "cellulare=" + obj.pendingCell + "&tstamp=" + tstampn,
                                                      error: function(){
                                                          inst.hideAllMessages();
                                                          $('#not_att_sprint_cell').html(obj.stepHeaders.insertCell[obj.userCarrier]);
                                                          $('#insertCell').show("slow", function(ev) { $('#generalError').show(); });
                                                      },
                                                      success: function(xml){
                                                          var status_i;
                                                          var passwd;
                                                          var phone_company;
                                                          var cellulare;

                                                          $(xml).find('status').each(function(){
                                                              status_i = $(this).text();
                                                          });

                                                          if (status_i == "ok") {
                                                              $(xml).find('password').each(function(){
                                                                  passwd = $(this).text();
                                                              });

                                                              if ($('#opInProgress').length > 0) {
                                                                  $('#opInProgress').fadeOut();
                                                              }
                                                              $('#not_att_sprint_completed').html(obj.stepHeaders.opCompleted[obj.userCarrier]);
															  if ($('#carriers_list_completed').length > 0){
																$("#carriers_list_completed").html(this.miniCarriers[this.userCarrier]);
															  }
                                                              $('#insertCell').fadeOut("slow", function(ev) {$('#opCompleted').fadeIn("slow");});

                                                              obj.updateStepHeader(obj.stepImages.step4);

                                                              $('#web2wapEnd').show();
                                                              $('#search').show();
                                                              obj.w2w = 100;
                                                              $('#w2wUsername').val(obj.pendingCell);
                                                              $('#w2wPassword').val(passwd);

                                                              $('#frmSS5Username').val(obj.pendingCell);
                                                              $('#frmSS5Password').val(passwd);

                                                              var iframe = $("<iframe>");
                                                              iframe.attr("id","checkUserOKIFrame");
                                                              iframe.attr("src", (obj.pixel_attr_str + obj.reqUrlParams['partner_id'])); 
                                                              iframe.css("width", "1px");
                                                              iframe.css("height", "1px");
                                                              iframe.css("display", "none");
                                                              $("body").append(iframe);
                                                          }else {
                                                              obj.w2w = obj.w2w + 1;
                                                          }
                                                      }
                                                  });
                                              }
                                  },
                                  30000
                              );
              var timeoutID = setTimeout(function() {
                                      clearInterval(interID);
                                      if (obj.w2w != 100) {
                                          obj.hideAllMessages();
                                          if ($('#opInProgress').length > 0) {
                                              $('#opInProgress').fadeOut();
                                          }
                                          $('#not_att_sprint_cell').html(obj.stepHeaders.insertCell[obj.userCarrier]);
                                          $('#insertCell').fadeIn("slow");
                                      }
                                  },
                                  600000
                              );
          }else {
              obj.askPinResponse();
          }
          break;
      }
    }
  });
};

registerCell.prototype.askPinResponse = function () {
  var status_i = this.dati['status'];
  switch (status_i.toLowerCase()){
    case 'ok':
      this.showInsertPinForm(this.dati['msg_title'], this.dati['msg_desc']);
      break;
    case 'error':
      this.askPinError();
      break;
    default:
      this.askPinError();
      break;
  }	
};

registerCell.prototype.showEnterCellForm = function() {
    $('.to_hide_all').hide();
    $('#carrierSelect').hide("slow");
    $('#not_att_sprint_cell').html(this.stepHeaders.insertCell[this.userCarrier]);
    $('#insertCell').show("slow");
    this.updateStepHeader(this.stepImages.step2);
};

registerCell.prototype.askPin = function(msg_title, msg_desc) {
  $('.to_hide_all').hide();
  $('#not_att_sprint_pin').html(this.stepHeaders.insertPin[this.userCarrier]);
  if ($('#carriers_list_pin').length > 0){
	$("#carriers_list_pin").html(this.miniCarriers[this.userCarrier]);
  }
  $('#insertPin').show("slow");
  this.updateStepHeader(this.stepImages.step3);

  $('#requestPin').hide();
  $('#countDown1').show();
  if ($('#mycarrier').length > 0){
    $('#mycarrier').val(this.dati['phone_company']);
    if(($('#mycarrier').val()=='53') && ($('#device').length > 0)){
      $('#device').show();
    }
	
  }
  
  this.startCountDown(30, 1000);
  
  if ($('#mycarrier').length > 0){
    $('#mycarrier').val(this.dati['phone_company']);
    $("#disclaimer").show();
    var di = this.disclaimers;
    if (di[this.userCarrier].onOff == "1") {
        $(di[this.userCarrier].showElementID).html(di[this.userCarrier].disclaimerText);
    }

	
  }
};

registerCell.prototype.confirmPinResponse = function () {
  var status_i = this.dati['status']?this.dati['status']:'error';
  switch (status_i.toLowerCase()){
    case 'ok':
      this.showCompleteMessage();
      break;
    case 'error':
      this.confirmPinError();
    break;
    default:
      this.confirmPinError();
      break;
  }
};

registerCell.prototype.confirmPin = function (password) {
  var pars ="service="+this.generalParams['service'] + "&password="+escape(password);
  if (this.pendingCell){
    pars += "&cellulare="+this.pendingCell;
  }else if (this.generalParams['pendingCell']){
    pars += "&cellulare="+this.generalParams['pendingCell'];
  }

  if ($('#class').val() != ""){
    pars += "&class="+$('#class').val();
  }
  if ($('#idwapldld').val() != ""){
    pars += "&id_wapdld="+$('#idwapldld').val();
  } 
  if (($('#mycarrier').length > 0) && ($('#mycarrier').val() == "53")) {
    if($('#info_cell').val() != ""){
      pars += "&info_cell="+$('#info_cell').val();
    }
  }
  if ($('#final_site').val() != ""){
    pars += "&site="+$('#final_site').val();
  }

  for (var ki in this.confirmPinArray) {
    if (this.dati[this.confirmPinArray[ki]]){
      pars += "&" + this.confirmPinArray[ki] + "=" + this.dati[this.confirmPinArray[ki]];
    }else if (this.generalParams[this.confirmPinArray[ki]]){
      pars += "&" + this.confirmPinArray[ki] + "=" + this.generalParams[this.confirmPinArray[ki]];
    }
  }

  pars += "&xml=1";
  pars += "&widget_mode=1";
  var pinUrl = this.config['scriptBaseUrl'] + this.config['confirmScript'];

  this.askForPinRPC(pinUrl, pars.replace(/\+/,"%2b"), 'get');
  this.showWaitForConfirmMessage();
  return ;
};

registerCell.prototype.hideAllMessages = function() {
  $('#opInProgress').hide();
  $('#opInProgressPin').hide();
  $('#opCompleted').hide();
  $('#insertPin').hide();
  $('#responseTitle').hide();
  $('#responseDesc').hide();
  $('#errorTitle').hide();
  $('#errorDesc').hide();
  $('#insertCell').hide();
  $('#generalError').hide();
  if ($('#xmlRpcWaitMessage').length > 0) {
    $('#xmlRpcWaitMessage').hide();
  }
};

registerCell.prototype.showCompleteMessage = function() {
  var msg_title = this.dati['msg_title'] ? this.dati['msg_title'] : '';
  var msg_desc = this.dati['msg_desc'] ? this.dati['msg_desc'] : '';
  var cell = this.dati['cellulare'];

  if(this.generalParams['allow_download']) {
    var download = this.dati['download'] ? this.dati['download'] : '';
    var mp3_url = this.dati['mp3_url'] ? this.dati['mp3_url'] : '';
    if($('#allowdnl').length > 0){
      $('#allowdnl').html(download);		
    }
    if($('#allowdnl_url').length > 0){
      $('#allowdnl_url').val(mp3_url);
    }
  }
  
  this.hideAllMessages();
  this.opCompleted(msg_title, msg_desc);
  if ($('#partner_logo_complete').length > 0){
   if(this.dati['phone_company']=='25'){
    $('#partner_logo_complete').hide();    
   }
  }
  this.elementUpdate('dadanetuser_cell',cell );
  this.elementUpdate('responseTitle',msg_title );
  $('#responseTitle').show();

  this.elementUpdate('responseDesc', msg_desc);
  $('#responseDesc').show();

  if( this.generalParams['registerDoneUri']) {
    this.doRedirect(this.generalParams['registerDoneUri']);
  }
};

registerCell.prototype.doRedirect = function(url_to) {
  if (opener) {
    if(opener.closed) {
      window.setTimeout("window.location.href='"+url_to+"';",5000);
    }else {
      window.setTimeout("opener.focus();window.close();",5000);
      opener.location.href = url_to;
    }
  }else{
    window.setTimeout("window.location.href ='"+url_to+"';",5000);
  }
};

registerCell.prototype.showWaitForConfirmMessage = function() {
  if(this.opInProgressPin) {
    this.opInProgressPin();
    return;
  }
  this.hideAllMessages();
  $('#opInProgressPin').fadeIn("slow");
};

registerCell.prototype.showWaitForPinMessage = function() {
  if( this.opInProgress ) {
    this.opInProgress();
    return;
  }
  this.hideAllMessages();
  if ($('#opInProgress').length > 0) {
    $('#opInProgress').fadeIn("slow");
  }
};

registerCell.prototype.showInsertPinForm = function(title_i, desc) {
  this.hideAllMessages();
  $('#requestPin').hide();
  this.elementUpdate('responseTitle', title_i);
  this.elementUpdate('responseDesc', desc);
  $('#responseTitle').show();
  $('#responseDesc').show();
  $('#not_att_sprint_pin').html(this.stepHeaders.insertPin[this.userCarrier]);
  if ($('#carriers_list_pin').length > 0){
	$("#carriers_list_pin").html(this.miniCarriers[this.userCarrier]);
  }
  $('#insertPin').show("slow");

  this.updateStepHeader(this.stepImages.step3);

  this.startCountDown(30, 1000);

  if ($('#mycarrier').length > 0){
    $('#mycarrier').val(this.dati['phone_company']);
    if(($('#mycarrier').val()=='53') && ($('#device').length > 0)){
      $('#device').show();
    }
  }
  if ($('#partner_logo_pin').length > 0){
    if(this.dati['phone_company']=='25'){
     $('#partner_logo_pin').hide();   
	
    }
  }

 

  if ($('#mycarrier').length > 0){
    $('#mycarrier').val(this.dati['phone_company']);
    $("#disclaimer").show();
    var di = this.disclaimers;
    if (di[this.userCarrier].onOff == "1") {
        $(di[this.userCarrier].showElementID).html(di[this.userCarrier].disclaimerText);
    }
  }
};

registerCell.prototype.elementUpdate = function(elem, conte) {
  var id = '#' + elem;
  if($(id).length > 0) {
    $(id).html(conte);
  }
};

registerCell.prototype.askPinError = function() {
  var msg_title = this.dati['msg_title']?this.dati['msg_title']:'';
  var msg_desc  = this.dati['msg_desc']?this.dati['msg_desc']:'';
  var code      = this.dati['code']?this.dati['code']:'10'; // The generic error
  
  this.hideAllMessages();
  $('#not_att_sprint_cell').html(this.stepHeaders.insertCell[this.userCarrier]);
  $('#insertCell').show("slow");

  this.updateStepHeader(this.stepImages.step2);

  this.opError(msg_title, msg_desc);

  if (code != '500') {
    $('#insertPin').hide();
  }

  if (code == '412') {
	$('#formInsertCell').hide();
	$('#already_subs_error').show();
    $('#errorDesc').hide();
    $('#errorTitle').hide();
  }

 

};

registerCell.prototype.confirmPinError = function() {
  var msg_title= this.dati['msg_title']?this.dati['msg_title']:'';
  var msg_desc= this.dati['msg_desc']?this.dati['msg_desc']:'';
  var code=this.dati['code']?this.dati['code']:'10'; //10 The generic error
  this.hideAllMessages();

  $('#not_att_sprint_pin').html(this.stepHeaders.insertPin[this.userCarrier]);
  if ($('#carriers_list_pin').length > 0){
	$("#carriers_list_pin").html(this.miniCarriers[this.userCarrier]);
  }
  $('#insertPin').show("slow");

  this.updateStepHeader(this.stepImages.step3);

  this.opError( msg_title, msg_desc );
};

registerCell.prototype.Sleep = function(naptime) {
  naptime = naptime * 1000;
  var sleeping = true;
  var now = new Date();
  var alarm;
  var startingMSeconds = now.getTime();
  while(sleeping){
    alarm = new Date();
    alarmMSeconds = alarm.getTime();
    if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
  }
};

registerCell.prototype.CheckNumber = function() {
  var flag = true;
  this.usr = '';

  flag &= this.checkField('#cell');
  flag &= this.checkField('#cell_1');
  flag &= this.checkField('#cell_2');

  if (flag == false){
    alert( "Warning: the number you entered is incorrect, please check and re-enter it." );
    //$('#cell').focus();
    return false;
  }
  return true;
};

registerCell.prototype.checkField = function(field) {
  var f = $(field);
  if(f.length > 0) {
    var maxlength = f.attr('maxlength');
    var reg = new RegExp("^\\d{1,"+maxlength+"}$");
    if(f.val().match(reg)==null) {
      return false;
    }
  }
  
  this.usr += f.val();
  return true;
};

registerCell.prototype.checkNumber2 = function(id) {
  var f = $(id);
  var next_i = "";
  if (id  == "#cell") {
    next_i = "cell_1";
  }else {
    next_i = "cell_2";
  }
  if(f.length > 0) {
    var maxlength = f.attr('maxlength');
    var reg = new RegExp("^\\d{"+maxlength+"}$");
    if(f.val().match(reg)) {
      document.getElementById(next_i).focus();
    }
  }
};

registerCell.prototype.numTyped = function(current_i, next_i, maxlen) {
  if (!($(next_i).length > 0)) {
    alert(next_i+" element doesn't exist! Please check html code");
    return false;
  }
  if (!($(current_i).length > 0)) {
    alert(current_i+" element doesn't exist! Please check html code");
    return false;
  }
};

registerCell.prototype.opCompleted = function(msg_title, msg_desc) {
  $('.to_hide_all').hide();
  $('#not_att_sprint_completed').html(this.stepHeaders.opCompleted[this.userCarrier]);
  if ($('#carriers_list_completed').length > 0){
	  $("#carriers_list_completed").html(this.miniCarriers[this.userCarrier]);
  }
  $('#opCompleted').show("slow");

  this.updateStepHeader(this.stepImages.step4);

  switch (this.step3Display) {
    case 'thanks download':
      $('#step3text2ThanksDownload').show();
      $('#allowdnl').show();
      $('#allowdnl_url').show();
      $('#congrats2').show();
      break;
    case 'email':
      $('#step3text2Email').show();
      $('#search').show();
      $('#congrats').show();
      break;
    default:
      $('#step3text2ThanksDownload').show();
      $('#allowdnl').show();
      $('#allowdnl_url').show();
      $('#congrats2').show();
      break;
  }

  var ipaddress = this.reqUrlParams['ipaddress'];
  var attr_str = this.pixel_attr_str;
  var pixel    = this.pixel_str;  
  if (this.reqUrlParams['artist_name'] != "") {
    pixel = pixel + '&artist=' + this.reqUrlParams['artist_name'].replace(" ","%2b"); 
  }
  if (this.reqUrlParams['song_title'] != "") {
    pixel = pixel + '&title=' + this.reqUrlParams['song_title'].replace(" ","%2b"); 
  }
  if (this.reqUrlParams['partner_id'] != "") {
    pixel = pixel + '&partner=' + this.reqUrlParams['partner_id'];
    attr_str = attr_str + this.reqUrlParams['partner_id'];
  }
  if (this.reqUrlParams['class_i'] != "") {
    pixel = pixel + '&class=' + this.reqUrlParams['class_i']; 
  }

  pixel = pixel + "' width='1' height='1' border='0'/>";  

  if ($('#step3Pixel')) {
    $('#step3Pixel').html(pixel);
  } 
  
  $('#CustomFields_3_5').val(ipaddress);
  if(this.pendingCell){
    $('#CustomFields_1_5').val(this.pendingCell);
  }
  if($('#pin').length > 0){
    $('#CustomFields_7_5').val($('#pin').val());
  }
  if($('#mycarrier').length > 0){
    $('#CustomFields_2_5').val($('#mycarrier').val());
  }
  if($('#idwapldld').length > 0){
    $('#CustomFields_4_5').val($('#idwapldld').val());
  }	
  
  if($('#allowdnl_url').length > 0){		
    $('#allowdnl_url').html("Your download will begin in a moment. If it doesn't, <a href='"+$('#allowdnl_url').val()+"'>click here</a> to try again.");	
  }
  
  ifrm = document.createElement("IFRAME"); 
  ifrm.setAttribute("src", attr_str);
  ifrm.style.width = 1+"px"; 
  ifrm.style.height = 1+"px"; 
  ifrm.style.display ="none"; 
  document.body.appendChild(ifrm);
};

registerCell.prototype.opError = function(msg_title, msg_desc) {
  if ($('#errorTitle').length > 0) { 
    this.elementUpdate('errorTitle', msg_title);
    $('#errorTitle').show(); 
  }
  if ($('#errorDesc').length > 0) { 
    this.elementUpdate('errorDesc', msg_desc);
    $('#errorDesc').show();
  }
};

registerCell.prototype.checkandask = function(id, google, id_wapdld, infoservice, generalParamsRegisterCell) {
  if (!($(id).length > 0)) {
    alert(id+' element doesn\'t exist! Please check html code');
    return false;
  }
  if(!this.CheckNumber()) {
    return false;
  }

  if ((google == "1") ) {
    if(($('#acceptConds').length > 0) && !($('#acceptConds:checked').val() != null)) {
      /*if (this.userCarrier != 16) {
          alert( "Please, confirm you have read and accepted the Subscription Agreement." );
      }else {*/
          alert( "Please accept the Terms and Conditions before proceeding.");
     /* }*/
    //  $('#acceptConds').checked.focus;
      return false;
    }
  }

  var my_wapdld = id_wapdld; //default
	
  if(my_wapdld!="") {
    $('#idwapldld').val(my_wapdld);
  }
  this.initialize(generalParamsRegisterCell);
  this.askForPin();
};

registerCell.prototype.checkPin = function(id, google) {
  if (!($('#pin').length > 0)) {
    alert(id+' element doesn\'t exist! Please check html code');
    return false;
  }
  var maxlength = $('#pin').attr('maxlength');
  var reg = new RegExp("^\\d{"+maxlength+"}$");
  if( !($('#pin').val().match(reg))) {
    alert( "To continue, please enter the 4-digit PIN code we sent to your phone via text message." );
    //$('#pin').focus;
    return false;
  }
  
  if (google != "1") {
    if($('#acceptCondsPin').length > 0) {
      if (!($('#acceptCondsPin:checked').val() != null)) {
        alert( "Please confirm that you have read the Terms and Conditions." );
        //$('#acceptConds').checked.focus;
        return false;
      }
    }
  }
  this.pwd = $('#pin').val();
  this.confirmPin($('#pin').val());
};

registerCell.prototype.startCountDown = function(i,p) {
  $("#countDown").html("30");
  $('#countDown1').show();
  var intervalID = setInterval("doCountdown()", 1000);
  var timeoutID = setTimeout(function() {
                    clearInterval(intervalID);
                    $('#countDown1').hide();
                    $('#requestPin').show();
                    //this.secsCounter = 30;
                  },
                  31000
                  );
};

registerCell.prototype.GoSubmit = function() {
  var GoSubmitUrl   = this.GoSubmitUrlBase + "?username="+this.pendingCell+"&password="+$('#pin').val()+"&act=1&uri=";
  var GoSubmitStore = this.GoSubmitStore;
  var url = GoSubmitUrl + GoSubmitStore;
  window.open( url, "myWindow", "status = 0, scrollbars=1" );
};

function timerDrag() {
  if(this.dragTimer < 100) {
    ++(this.dragTimer);
    setTimeout('timerDrag()',10);
  }
}

function doCountdown() {
  var html = Number($("#countDown").html());
  if (html > 0) {
    $("#countDown").html((html - 1));
  }
}
