if( typeof( api ) == "undefined" ){ api = {}; api.ns = 'api'; };


/**
 * Review model
 */
api.Review = function( review_dictionary ){
    attributes = ['prid',
		  'permission',
		  'stars',
		  'mugshot_thumb_url',
		  'user_link',
		  'user',
		  'time_created',
		  'message'
		  ];

  this.id = attributes['prid'];
  for( var i = 0; i < attributes.length; i++ ){
    this[attributes[i]] = review_dictionary[attributes[i]];
  }
  this.user = new api.User( this.user );
};

/** Max length of a review. Character input beyond this is limited in the UI */
api.Review.max_length = 100;

/**
 * Creates a new review
 */
api.Review.create = function(nxuid, channel_id, message, star_rating, on_create){



  var params = { 'xaction'    : 'create_review',
		 'channel_id' : channel_id,
		 'nxuid'      : nxuid,
		 'message'    : message,
		 'stars'      : star_rating
	       };

  AppBase.post(
    '/reviews',
    params,
    function(response){ api.Review._on_create( response, on_create ); }
  );

};

api.Review._on_create = function( response, on_create ){
    on_create( response );
};

/**
 * Creates a new review, logging on the user or creating an account if needed
 */
api.Review.create_login = function(credentials, channel_id, message, star_rating, on_create){
  var params = { 'xaction'     : 'create_review_login',
	       'channel_id'    : channel_id,
	       'email'         : credentials.email,
	       'password'      : credentials.password,
	       'create_account': credentials.create_account,
	       'message'       : message,
	       'stars'         : star_rating
    };

    AppBase.post(
		 '/reviews',
		 params,
		   function(response){ api.Review._on_create( response, on_create ); }
		 );
};


api.Review._on_create_login = function( response, on_create ){
//    on_create( response );
};


/**
 * Fetches up to LIMIT reviews for the specified CHANNEL_ID.
 * on_fetch is passed an array of reviews
 */
api.Review.fetch = function( channel_id, limit, on_fetch ){

    params = { 'xaction'    : 'get_reviews_for_channel',
	       'channel_id' : channel_id,
	       'limit'      : limit
    };

    AppBase.post(
		 '/reviews',
		 params,
		 function(response){ api.Review._on_fetch( response, on_fetch, channel_id ); }
		);
};

api.Review._on_fetch = function( response, on_fetch, channel_id ){
  var reviews = [];
  var mock_channel = new api.Channel( response );

  api.Channel.channels[channel_id]['reviews'] = mock_channel['reviews'];
  api.Channel.channels[channel_id]['ratings'] = mock_channel['ratings'];
  api.Channel.channels[channel_id]['total_review_count'] = mock_channel['total_review_count'];
  api.Channel.channels[channel_id]['latest_review'] = mock_channel['latest_review'];

  for( var i = 0; i < response['reviews'].length; i++ ){
    reviews[i] = new api.Review( response['reviews'][i]);
    api.Channel.review_channel[reviews[i]['prid']] = api.Channel.channels[channel_id];
  }
  on_fetch( reviews, response['total_review_count'], channel_id );
};


/**
 * Destroys the specified review
 */
api.Review.destroy = function(prid, permission_token, on_destroy) {

    AppBase.post(
		 '/reviews',
                 {
		   'xaction' : 'delete_review',
		   'permission_token' : permission_token,
		   'prid' : prid
		 },
		 function( response ){ api.Review._on_destroy( response, on_destroy ); }
		);
};

api.Review._on_destroy = function( response, on_destroy ){
    on_destroy( response );
};


api.ns_id = function( old_id ){
    return ' id="'+api.ns+'_'+old_id+'" ';
};


// --------
// TEMPLATE - responsible for rendering and updating the view of reviews.
//
// Usage: rt = new api.Review.Template( li_nxuid );
//        reviewsDiv = rt.render_review_section( reviews, total_review_count, channel_id );
// --------


api.Review.Template = function(li_nxuid){
    api.Review.templateInstance = this;
    this.li_nxuid = li_nxuid;
};

/**
 * Updates the review section using the review data attached to the specified channel
 */
api.Review.Template.update_reviews_section = function(reviews, total_review_count, channel_id){

  $('#'+api.ns+'_channel_'+channel_id+'_reviews_list')[0].appendChild(api.Review.templateInstance.render_reviews_list(reviews, total_review_count, channel_id));
    if( parseInt(total_review_count) > reviews.length ){
	$('#'+api.ns+'_read_all_'+channel_id).show();
    }else{
	$('#'+api.ns+'_read_all_'+channel_id).hide();
    }
};

/**
 * Resets the review form to blank defaults
 */
api.Review.Template.reset_review_form = function( channel_id ){
    $("#"+api.ns+"_real_input_textbox_"+channel_id)[0].value = '';
    $("#"+api.ns+"_real_input_counter_"+channel_id)[0].innerHTML = translate( "Character_count", api.Review.max_length );
    $("#"+api.ns+"_star_rating_"+channel_id)[0].value = 0;
    api.Review.Template.update_review_form_stars( channel_id );
};

/**
 * Attempts to submit the review form for logged in and anonymous users.
 * Anonymous users will either:
 * 1. log on with an existing account
 * 2. create an account (and log in with it)
 * 3. fail to post because of an error condition
 * @param channel_id String ID of the channel whose reviews are being processed.
 * @return Boolean indicator of attempt being made
 */
api.Review.Template.submit_review_form = function( channel_id ){
    api.Review.Template.alert(channel_id);
    r_form = $("#"+api.ns+"_irf_"+channel_id)[0];

    trim_msg = r_form.message.value.replace(/^\s*/, '').replace(/\s*$/, '');

    if( trim_msg != '' || parseInt(r_form.star_rating.value) > 0 ){
      if( api.Review.templateInstance.li_nxuid ){
	api.Review.create(r_form.nxuid.value,
			  channel_id,
			  r_form.message.value,
			  r_form.star_rating.value,
			  api.Review.Template.on_submit_review_form);

      }else{
	var email_input = $('#'+api.ns+'_review_login_'+channel_id);
	var pw_input = $('#'+api.ns+'_review_pw_'+channel_id);
	var create_input = $('#'+api.ns+'_review_create_account_'+channel_id);
	var credentials = {
			    'email':email_input.val(),
			    'password':pw_input.val(),
			    'create_account':create_input[0].checked
			  };
	if( !AppBase.is_legal_email(credentials.email) ){
	  api.Review.Template.alert(channel_id, translate('api_review_invalid_email'));
	  email_input.focus();
	  email_input.select();
	  return false;
	}
	if( credentials.password.length < 4 || !AppBase.is_legal_password( credentials.password ) ){
	  api.Review.Template.alert(channel_id, translate('api_review_invalid_pass'));
	  pw_input[0].focus();
	  pw_input[0].select();
	  return false;
	}
	api.Review.create_login(credentials,
				channel_id,
				r_form.message.value,
				r_form.star_rating.value,
				api.Review.Template.on_submit_review_form_login);
	return true;
      }
    }else{
	api.Review.Template.alert(channel_id, translate("reviews_no_content"));
	return false;
    }
};

api.Review.Template.on_submit_review_form_login = function(msg){
  if( msg['outcome'] == 'success' ){
    window.location.reload(false);
  }else{
    if( msg['fail_reason'] == 'NO_USER' ){
      appendObj = translate('account_no_email');
    }else{
      var appendObj = SPAN({},
	                      translate('account_bad_pw'),
			      BR(),
			      A({'href':Serdes.make_command_url('/forgot',{}), 'target':'_new'}, translate('account_pw_reset'))
			  );
    }
    api.Review.Template.alert(msg['channel_id'], appendObj);
  }

};

api.Review.Template.on_submit_review_form = function(msg){
  if( msg['error'] ){
    if( msg['error'] == 'blocked' ){
      api.Review.Template.alert( msg['channel_id'], translate( 'api_review_blocked_review_deny' ) );
    }
  }else{
    api.Review.Template.review_form_hide(msg['channel_id']);
    api.Review.fetch( msg['channel_id'],
		      3,
		      api.Review.Template.on_submit_review_form_response
		      );
  }
};

api.Review.Template.on_submit_review_form_response = function(reviews, total_review_count, channel_id){
  var channel = api.Channel.channels[channel_id];
  channel.reviews = reviews;
  channel.total_review_count = total_review_count;

  api.Review.Template.update_reviews_section(reviews, total_review_count, channel_id);
  api.Review.Template.reset_review_form(channel_id);
  api.Review.Template.review_form_hide(channel_id);
};

api.Review.Template.on_destroy_response = function(msg){
    var r_channel = api.Channel.review_channel[ msg['prid'] ];
    r_channel['total_review_count'] = parseInt( r_channel['total_review_count'] ) - 1;
    var channel_id = r_channel['channel_id'];
    //    api.Review.Template.update_reviews_read_all( channel_id, r_channel['total_review_count']);
    api.Review.Template.on_submit_review_form({'channel_id' : channel_id});
    $("#"+api.ns+"_review_"+msg['prid']).fadeOut();
};

/**
 * Updates the character count based on the number of characters in the input box
 */
api.Review.Template.update_review_form_count = function( channel_id ){
    textbox = $("#"+api.ns+"_real_input_textbox_"+channel_id)[0];
    counter = $("#"+api.ns+"_real_input_counter_"+channel_id)[0];
    my_length = textbox.value.length;

    legal_count = Math.max( api.Review.max_length - my_length, 0);
    counter.innerHTML = translate( "Character_count", legal_count );
    if( my_length > api.Review.max_length ){
	$("#"+api.ns+"_real_input_textbox_"+channel_id)[0].value = $("#"+api.ns+"_real_input_textbox_"+channel_id)[0].value.substr(0, api.Review.max_length);
	counter.style.color = "#FF0000";
	counter.style.fontWeight = "bolder";
    }else{
	counter.style.color = "#000000";
	counter.style.fontWeight = "normal";
    }
};

/**
 * Updates the number of stars and stars message ("awesome!!!", etc) based on the number of stars set in the form
 */
api.Review.Template.update_review_form_stars = function(channel_id){
	star_count = $("#"+api.ns+"_star_rating_"+channel_id)[0].value;
	api.Review.Template.highlight_review_form_stars( channel_id, star_count );
};

api.Review.Template.update_reviews_read_all = function( channel_id, total_review_count ){
    if( total_review_count <= 3 ){
	$('#'+api.ns+'_read_all_'+channel_id).hide();
    }else{
	$('#'+api.ns+'_read_all_'+channel_id).show();
	$('#'+api.ns+'_read_all_'+channel_id+'_text')[0].innerHTML = translate('Show_All_Reviews', total_review_count);
    }
};

/**
 * In the review form of the specified channel id, this Highlights the specified number of stars
 */
api.Review.Template.highlight_review_form_stars = function(channel_id, star_count){
    i = 1;
    review_stars_list = $("."+api.ns+"_"+channel_id+"_irfs");
    if( star_count > 0 ){
	for( ; i <= star_count; i++){
	    review_stars_list[i].style.backgroundPosition = "0 -40px";
	}
    }
    for( ; i < 6; i++){
	review_stars_list[i].style.backgroundPosition = "0 -20px";
    }
    api.Review.Template.update_review_form_default_text(channel_id, star_count );
};

api.Review.Template.highlight_review_form_stars_e = function( e ){
    api.Review.Template.highlight_review_form_stars( e.data.channel_id, e.data.star_count );
};


/**
 * In the review form of the specified channel id, this sets the specified number of stars and updates
 * the star_count value in the form.
 */
api.Review.Template.select_review_form_stars = function(channel_id, star_count){
	$("#"+api.ns+"_"+"star_rating_"+channel_id)[0].value = star_count;
	api.Review.Template.update_review_form_stars( channel_id );
};

api.Review.Template.select_review_form_stars_e = function(e){
    api.Review.Template.select_review_form_stars( e.data.channel_id, e.data.star_count );
};

/**
 * Updates the review form with the appropriate default text for the specified star count
 */
api.Review.Template.update_review_form_default_text = function(channel_id, star_count){
	wordbank = ["", "poor", "nothing special", "worth watching", "pretty cool", "awesome!!!"];
	legend = $("#"+api.ns+"_star_rating_legend_"+channel_id)[0];
	legend.innerHTML = wordbank[star_count];
};

/**
 * Shows the full review form, hides the dummy input element
 */
api.Review.Template.review_form_show = function(channel_id){
	for(var i = 0; i < 6; i++){
	    $("."+api.ns+"_"+channel_id+"_irfs:eq("+i+")").bind("mouseover", {'channel_id' : channel_id, 'star_count' : i }, api.Review.Template.highlight_review_form_stars_e);
	    $("."+api.ns+"_"+channel_id+"_irfs:eq("+i+")").bind("click", {'channel_id' : channel_id, 'star_count' : i }, api.Review.Template.select_review_form_stars_e);
	}
	$("#"+api.ns+"_dummy_input_"+channel_id+"_container").hide(); $("#"+api.ns+"_real_input_"+channel_id+"_container").fadeIn(); $("#"+api.ns+"_real_input_textbox_"+channel_id).focus();
};

/**
 * Hides the full review form, shows the dummy input element.
 */
api.Review.Template.review_form_hide = function(channel_id){
	for(var i = 0; i < 6; i++){
	    $("."+api.ns+"_"+channel_id+"_irfs:eq("+i+")").unbind("mouseover", api.Review.Template.highlight_review_form_stars_e);
	    $("."+api.ns+"_"+channel_id+"_irfs:eq("+i+")").unbind("onclick", api.Review.Template.select_review_form_stars_e);
	}
	$("#"+api.ns+"_real_input_"+channel_id+"_container").hide(); $("#"+api.ns+"_dummy_input_"+channel_id+"_container").fadeIn(); //$("#real_input_textbox_"+channel_id).focus();
};

api.Review.Template.displayable_name = function( display_name ){
  if( display_name.length == 0 ){
    return 'anonymous';
  }else{
    return display_name;
  }
};

api.Review.Template.alert = function( channel_id, message ){
  if( message ){
    $("#"+api.ns+"_warning_message_"+channel_id).show();
    if( typeof( message ) == "string" ){
      $("#"+api.ns+"_warning_message_"+channel_id).html(message);
    }else{
      $("#"+api.ns+"_warning_message_"+channel_id).empty().append(message);
    }
  }else{
    $("#"+api.ns+"_warning_message_"+channel_id).hide();
  }
};

api.Review.Template.update_rate_big = function( channel_id, reviews ){
  var scoreCount = api.Channel.channels[channel_id]['ratings']['count'];
  var score = api.Channel.channels[channel_id]['ratings']['average'];
  api.Review.Template.update_rate_outside( score );
  $("#ratings_total_"+channel_id).html('<a href="#">'+scoreCount + ' ' + translate('rating(s)')+'</a>');
  if( scoreCount > 0 ){
    $("#ratings_total_"+channel_id).css("display", "block");
  }else{
    $("#ratings_total_"+channel_id).css("display", "none");
  }

  $("#rate_big_"+channel_id).removeClass("ratings_1 ratings_2 ratings_3 ratings_4 ratings_5");
  var stars_display_class = 'ratings_stars ' + api.Review.Template._get_ratings_display(score);
  $("#rate_big_"+channel_id).addClass( stars_display_class );
  if( parseInt(score) == 0 ){
    //$("#channel_"+channel_id+"_review_container .rate_me_box").css("display", "block");
  }
};

api.Review.Template._get_ratings_display = function(average_rating) {
  if ((average_rating >= 20) && (average_rating < 40)) {
    return "ratings_1";
  } else if ((average_rating >= 40) && (average_rating < 60)) {
    return "ratings_2";
  } else if ((average_rating >= 60) && (average_rating < 80)) {
    return "ratings_3";
  } else if (average_rating >= 80 && (average_rating < 100)) {
    return "ratings_4";
  } else if (average_rating == 100) {
    return "ratings_5";
  } else {
    return " ";
  }
};

api.Review.Template.update_rate_outside = function(new_average){};

api.Review.Template.prototype = {


    /**
     * Create a functional review section for the specified channel,
     * allowing for listing, creating, and deleting reviews
     */
  render_review_section : function(reviews, total_review_count, channel_id){
    list_id = api.ns+'_channel_'+channel_id+'_reviews_list';
    var reviewsDiv = DIV({});
    reviewsDiv.appendChild(this.render_review_form(channel_id));
    reviewsDiv.appendChild(DIV({'id': list_id, 'class':'reviews_list'},this.render_reviews_list(reviews, total_review_count, channel_id)));
    return reviewsDiv;
  },

  render_reviews_list : function(reviews, total_review_count, channel_id){
    inner_id = api.ns+'_channel_'+channel_id+'_reviews_inner';
    $('#'+inner_id).remove();
    api.Review.Template.update_rate_big( channel_id, reviews );
    var reviewsDiv = DIV({'id': inner_id});
    for (var i=0; i<reviews.length; i++){
      reviewsDiv.appendChild(this.render_review(reviews[i]));
    }

    if( total_review_count > reviews.length ){
      reviewsDiv.appendChild(this.render_reviews_read_all( channel_id, total_review_count ));
    }
    return reviewsDiv;
  },

    render_rate_big : function( channel_id ){
      var channel = api.Channel.channels[channel_id];
      var stars_display_class = 'ratings_stars ' + api.Review.Template._get_ratings_display(channel['ratings']['average']);
      if( parseInt(channel['ratings']['count']) > 0 ){
	var ratings_total_style = {'class':'ratings_total', 'id':'ratings_total_'+channel_id};
      }else{
	var ratings_total_style = {'class':'ratings_total', 'id':'ratings_total_'+channel_id, 'style':'display:none'};
      }

      var ratings_box = DIV({'class':'rate_me_box'},
	      DIV({'class':'ratings', 'onclick':function(){ api.Review.Template.review_form_show(channel_id); return false;}},'',
		DIV({'class': stars_display_class, 'id':'rate_big_'+channel_id},''),
			DIV(ratings_total_style, A({'href':'#'},channel['ratings']['count'] + ' ' + translate('rating(s)')))
	      )
	);
      return ratings_box;
    },

    /**
     * Render a single review in the inline format.
     * @returns A Div element containing the review
     */
    render_review : function(review) {

      var reviewDivID = 'review_'+review['prid'];
      var reviewDiv = DIV({'class':'review review_div', 'id':api.ns+'_review_'+review['prid']});
      var starsDiv = DIV({'style':'float:right;'},'');

      if (review.stars != '0') {
	for (var i=0; i < Number(review.stars); i++) {
	  starsDiv.appendChild(SPAN({},
	    IMG({'src':Serdes.make_static_url('/images/slidecom/staron_small.gif'), 'width':'11', 'height':'10'})
	  ));
	}
	for (;i<5;i++) {
          starsDiv.appendChild(SPAN({},
	    IMG({'src':Serdes.make_static_url('/images/slidecom/staroff_small.gif'), 'width':'11', 'height':'10'}
 	  )));
	}
      }else{
	starsDiv.style.height = '12px';
      }

      reviewDiv.on_delete = function( response ){
	if( response == "PASS" ){
	  this.fadeOut();
	}
      };

      reviewDiv.appendChild( DIV({'style':'float:left; margin-right: 5px;'},
				   IMG({'src' : review.mugshot_thumb_url}, null)
      ));

      reviewDiv.appendChild( starsDiv );
      reviewDiv.appendChild(DIV({},
                                DIV({'class':'small'},
				      A({'href':review.user_link}, review.user.display_name),
				      '&nbsp;'+Mu.datestring(review.time_created)
				      )
				   ));

      reviewDiv.appendChild( DIV({'style':'clear:right;width:1px;line-height:0px;height:0px'}) );

      	if( review['permission'] != null ){
	    var onclick_call = 'api.Review.destroy(\''+review['prid']+'\',\''+review['permission']+'\'\,api.Review.Template.on_destroy_response); return false;';
	    reviewDiv.appendChild(DIV({'style':'float:right;width:50px;'},
				      A({'href':'#',
					 'onclick':onclick_call,
					 'class':'remove_review_button',
					 'onmouseout' : '$(this).removeClass("remove_review_button_hover")'
					},'(delete)')
				     ));
	}

	if( review.message.length > 0){
	  var reviewChunks = [];
	  reviewChunks = review.message.split("<br/>");
	  var newDiv = DIV({'class':'api_review_message','style':'margin-right:50px; margin-left:35px; overflow: hidden;'},''); 
	  for( var i=0; i < reviewChunks.length; i++){
	    newDiv.appendChild(SPAN({},reviewChunks[i]));
	    if( i+1 < reviewChunks.length ){
	      newDiv.appendChild(BR({}));
	    }
	  }
	  reviewDiv.appendChild(newDiv);
	}
        reviewDiv.appendChild( DIV({'style':'clear:both;width:0px;line-height:0px;'}) );
	return reviewDiv;
    },

    render_reviews_read_all : function( channel_id, total_review_count ){
      return DIV({'class':'review_div review_notice', 'id':api.ns+'_read_all_'+channel_id},
		   A({'href':'#', 'id':api.ns+'_read_all_'+channel_id+'_text', 'onclick':'api.Review.fetch("'+channel_id+'",0,api.Review.Template.update_reviews_section); return false;'}, translate('Show_All_Reviews', total_review_count)));
    },


    render_review_form : function(channel_id){
      toRet = DIV({'class':'review_shrinkwrap'});
      var dummy_form = DIV({'id':api.ns+'_dummy_input_'+channel_id+'_container'},
			   this.render_rate_big(channel_id),
			   INPUT({'class':'dummy_input',
				   'size':'20',
				   'onfocus':"api.Review.Template.review_form_show(\""+channel_id+"\")",
				   'value':translate("leave_comment")
				 }),
                           DIV({'style':'clear:both;'},'')
			   );

      var real_form = $(
			"<form "+api.ns_id("irf_"+channel_id)+" onsubmit='return false' >"+
	  	"<div style='float: left;'>"+
	"    <div style='display:inline'><textarea rows='4' cols='40' name='message' "+api.ns_id('real_input_textbox_'+channel_id)+" onkeyup='api.Review.Template.update_review_form_count(\""+channel_id+"\")' onblur='api.Review.Template.update_review_form_count(\""+channel_id+"\")' onchange='api.Review.Template.update_review_form_count(\""+channel_id+"\")'></textarea></div>"+
	"  <span "+api.ns_id('real_input_counter_'+channel_id)+">"+translate("Character_count", api.Review.max_length)+"</span>"+
	    "<input type='hidden' name='star_rating' id='"+api.ns+"_star_rating_"+channel_id+"' value='0' />"+
	    "<input type='hidden' name='nxuid' id='"+api.ns+"_irf_nxuid' value='"+this.li_nxuid+"' />"+
	    "<div id='"+api.ns+"_warning_message_"+channel_id+"' class='message_warning'></div>"+
	"    <br style='clear:left;' />"+
	"</div>"+
	"<div style='float: right; text-align:right; width: 131px;'>"+this.render_review_form_stars( channel_id )+
	"<br/>"+
	"    <input type='submit' value='"+translate('submit')+"' class='slide_button' style='width:110px' onclick='api.Review.Template.submit_review_form(\""+channel_id+"\");' /><br/>&nbsp;"+translate('or_')+"&nbsp;<a href='#' onclick='api.Review.Template.review_form_hide(\""+channel_id+"\");return false;'>"+translate('cancel')+"</a>"+
	"<br/><br style='clear:right;'/></div>"+
	"  </form>");

      var edit_form = DIV({'id':api.ns+'_real_input_'+channel_id+'_container', 'class':'review_real_input', 'style':'display:none'});
      edit_form.appendChild( real_form[0] );
      //edit_form.appendChild( $("<br style='clear:right;'/>")[0] );
      if(!this.li_nxuid){
	var email_input = $('#'+api.ns+'_review_login_'+channel_id, edit_form);
	var pw_input = $('#'+api.ns+'_review_pw_'+channel_id, edit_form);
	bu.hinted({'hint':translate('email')}, email_input);
	bu.hinted({'hint':translate('password')}, pw_input);
      }
      toRet.appendChild(dummy_form);
      toRet.appendChild(edit_form);
      return toRet;
    },

    render_review_form_stars : function(channel_id){
	var to_ret = "<div "+api.ns_id('irfs_'+channel_id)+" style='float:right; width: 131px;' onmouseout='api.Review.Template.update_review_form_stars(\""+channel_id+"\")' >"+
	"<span style=\"display:inline-block;\" class='"+api.ns+"_"+channel_id+"_irfs reviewtip_text'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
	for(var i = 1;i<6;i++) {
	    to_ret += "<span class='"+api.ns+'_'+channel_id+"_irfs ratings_star_small'></span>";
	}
	to_ret += "<br/><div class='small reviewtip reviewtip_text'><span "+api.ns_id("star_rating_legend_"+channel_id)+" style=''></span></div>";
	if( !this.li_nxuid ){
	  to_ret += "<br style='clear:both'/><div style='float:left;'>"+translate('login_to_review')+"</div><input type='text' "+api.ns_id("review_login_"+channel_id)+" style='width:128px; margin-bottom:5px;'/><br/><input type='password' "+api.ns_id("review_pw_"+channel_id)+" style='width:128px;'/><br/><input type='checkbox' name='create_account' value='create_account' "+api.ns_id("review_create_account_"+channel_id)+" checked style='margin-bottom:5px;'><label for='"+api.ns+"_review_create_account_"+channel_id+"'>"+translate('create_account')+"</label><br/>";
	}
	return to_ret+"</div>";
    }

};





