spliurl = document.URL.split('/');
var APP_DIR = spliurl[0]+"/"+spliurl[1]+"/"+spliurl[2]+"/";



/* DEPRECATED - Funcion que realiza el upload de ficheros con el pluguin de uploadify */

function uploadFile(identificador)
{
	if(identificador)
	{
		var msn           = "";
		var div_uploadify = "uploadify_"+identificador;
		var error         = "error_upload_"+identificador;
		var imagen        = "imagen_"+identificador;
		var preview       = "mini_cap_preview_"+identificador;
		var fileQueue			= "fileQueue_"+identificador
		var app_url       = APP_DIR;

		jQuery("[id="+div_uploadify+"]").uploadify({
			'uploader'       : app_url+'media/swf/upload/uploadify.swf',
	    'script'         : app_url+'media/swf/upload/uploadify.php',
	    'cancelImg'      : app_url+'media/img/bg_comunidad_cerrar.gif',
			'folder'         : 'temp/uploads',
			'queueID'        : fileQueue,
			'auto'           : true,
			'multi'          : false,
	    'fileExt'        : '*.jpg;*.jpeg;*.gif',
	    //'buttonText'     : '',
	    'buttonImg'      : app_url+'media/img/bg_comunidad_examinar.gif',
	    'width'          : 79,
	    'height'         : 22,
			'sizeLimit'      : 3145728,
			'method'         : 'POST',
			'onSelect'       : function() {},
	    'onCheck'        : function() {},
	    'onCancel'       : function() {
	    	//console.log("cancelandooo");
					//console.log(error);
	    		jQuery("#"+error).addClass('hidden');


	    	 if( jQuery("#"+error).hasClass('confirmacion')){ jQuery("#"+error).removeClass('confirmacion');}
	    	 if( jQuery("#"+error).hasClass('normal')){jQuery("#"+error).removeClass('normal');}

	    	 if( jQuery("#"+error).hasClass('hidden')){

	    	 }else{
	      	 	jQuery("#"+error).addClass('hidden');
	    	 }


	    },
	    'onError'        : function (a, b, c, d) {

			   if (d.status == 404)
	         msn = 'No ha sido posible encontrar el script';
	       else if (d.type === "HTTP")
	         msn = 'Error '+d.type+": "+d.status;
	       else if (d.type ==="File Size")
	         msn = "El archivo que desea subir es de mayor tama&ntilde;o que lo permitido (3Mb)";
	       else
	         msn = 'Error '+d.type+": "+d.text;

	       jQuery("[id="+error+"]").removeClass('confirmacion hidden').addClass('error').removeClass('normal');
	       jQuery("[id="+error+"]").html(msn);

	    },
	    'onProgress'     : function() {},
			'onComplete'     : function(event, a, b, response, data) {

				jQuery('[id='+imagen+']').attr('value', b.name);

			},
	    'onAllComplete'  : function(event, d) {

	    	if(msn == ""){

	    		jQuery('[id='+error+']').removeClass('normal hidden').addClass('confirmacion');
	    		jQuery('[id='+error+']').html("Se ha adjuntado la imagen correctamente");

	    		var src = jQuery('[id='+imagen+']').attr("value");
					var img = '<img src="'+app_url+'temp/uploads/'+src+'" width="130px" />';

					jQuery('[id='+preview+']').html(img);

	    	}
	    }
		});

	}else{
		//console.log("noooooooooo");
	}

}

/*function anadir_comment_(li_activo){
  $jQ('#comentarios_formulario_tabs li').each(function(){$jQ(this).removeClass('activo')});
  $jQ('#comentarios_formulario_tabs #'+li_activo).addClass('activo');
  $jQ('#comentarios_formulario_tabs #'+li_activo).addClass('activo');
  $jQ('#comentarios_formulario_cajas_content').removeClass().addClass('comentarios_formulario_cajas_content ' + li_activo);
}
*/


function anadir_comment(li_activo, identificador, capa){

	if(capa == '1'){
		jQuery('#form_comment #comentarios_formulario_tabs li').each(function(){jQuery(this).removeClass('activo')});
	  	jQuery('#form_comment #comentarios_formulario_tabs #'+li_activo).addClass('activo');
	  	jQuery('#form_comment #comentarios_formulario_tabs #'+li_activo).addClass('activo');
	  	jQuery('#form_comment #comentarios_formulario_cajas_content').removeClass().addClass('comentarios_formulario_cajas_content ' + li_activo);

	}else{
	  	jQuery('#formanswer_'+identificador+' #comentarios_formulario_tabs li').each(
		   	function(){
		   		jQuery(this).removeClass('activo');
		   	}
	  	);
		jQuery('#formanswer_'+identificador+' #comentarios_formulario_tabs #'+li_activo).addClass('activo');
		jQuery('#formanswer_'+identificador+' #comentarios_formulario_tabs #'+li_activo).addClass('activo');
		jQuery('#formanswer_'+identificador+' #comentarios_formulario_cajas_content').removeClass().addClass('comentarios_formulario_cajas_content ' + li_activo);
	}
}


function answers(item_id)
{
  // inicializamos las variables
	 var url  = APP_URL + 'comunidad/ajaxCommentAnswer';

	 var capa = 'answer_'+ item_id;

	 new Ajax.Request(url , {
			method				: 'post',
			asynchronous	: true,
			encoding			: 'utf-8',
			parameters		: {id  : item_id},
			onCreate			: function(){
				//cargando
				if( !$('list_comment').hasClassName('comentarios_listado_content_cargando') )
					$('list_comment').addClassName('comentarios_listado_content_cargando');
	    },
			onSuccess			: function(transport) {
				var response = transport.responseText;

				if( $('list_comment').hasClassName('comentarios_listado_content_cargando') )
				  $('list_comment').removeClassName('comentarios_listado_content_cargando');

				$(capa).innerHTML = (response == 'ko')
					? "Lo sentimos pero actualmente no podemos mostrarles dicha informaci&oacute;n"
					: response;
			}
	});

}

function pinta_form(datos)
{

	if(datos)
	{

		//cerramos primero todos los formularios abiertos
		close_forms();

		// inicializamos las variables
		var url     = APP_URL + 'comunidad/ajaxPintaFormSextaTv';
		var show_id = $('show_id_form').value;
		var bd_id   = $('bd_id_form').value;

		if( temp = datos.split("_"))
		{
			var capa    = 'formanswer_'+temp[0];

			new Ajax.Request(url , {
					method: 'post',
					asynchronous: false,
					encoding: 'utf-8',
					parameters: {item_id : temp[0], item_type:temp[1], bd_id: bd_id, show_id: show_id},
					onCreate: function(){

						//cargando
						if( !$('list_comment').hasClassName('comentarios_listado_content_cargando') )
						{
							$('list_comment').addClassName('comentarios_listado_content_cargando');
						}

			    },
					onSuccess: function(transport) {
						var response = transport.responseText;

						if( $('list_comment').hasClassName('comentarios_listado_content_cargando') )
						{
						  $('list_comment').removeClassName('comentarios_listado_content_cargando');
						}

						if(response == 'ko')
						{
							 $(capa).innerHTML = "Lo sentimos pero actualmente no podemos mostrarles dicha informaci&oacute;n";
						}else{
							$(capa).innerHTML = response;
						}

					},
					onComplete: function(transport) {
						var parametro = temp[0]+'_'+temp[1];
						uploadFile(parametro);

						//actualizamos el captcha

						jQuery('img[name=captcha_img]').each(function(){
							var src = jQuery(this).attr( 'src' );
							var random = Math.floor( Math.random() * 11 )
							jQuery(this).attr( 'src', jQuery(this).attr( 'src' ) +'/?rnd='+ random );
						});

				    	jQuery("div[class*=box_attach_content]").hide();
				    	jQuery("div[class*=box_attach_content]").hide();

				    	createUploader(parametro);

					}
			});

		}
	}
}


function reload_img(id)
{
  if(id)
  {
    var capa = '#multimedia_'+id;

    var width_img = 0;
    var width_contenedor = 0;

    if($jQ(capa).hasClass('multimedia_resized'))
    {
      width_img = 149;
      width_contenedor = 149;
      $jQ(capa).removeClass('multimedia_resized');
	  	$jQ(capa).find("img").attr('width', width_img);
	  	$jQ(capa).width(width_contenedor);

	  }else{

	    var temp = $jQ(capa).find("img").attr('size').split("_");



	    // caso que sea mayor que el contenedor
	    if( temp[0] >= 755 )
	    {
	      width_img        = 730;
	      width_contenedor = 755;

	      if(temp[2] == 1)
	      {
	      	width_img        = width_img - 30;
	      	width_contenedor = width_contenedor - 30;
	      }

	    }

		//caso q este entre el maximo y 400
	    if(400 <= temp[0] <= 755)
	    {
	      width_img        = 400;
	      width_contenedor = 400;
	    }

		//caso q este entre el maximo y 400
	    if( temp[0] < 400)
	    {
	      width_img        = temp[0];
	      width_contenedor = temp[0];
	    }

	    $jQ(capa).addClass('multimedia_resized');
	    $jQ(capa).find("img").attr('width', width_img);
	    $jQ(capa).find("img").css('float', 'left');
	    $jQ(capa).width(width_contenedor);
	  }


	}

}



function reload_multimedia(id, video, restaurar)
{
		if(id && video){

	  	var capa = 'multimedia_'+id;

	  	if(restaurar == '0'){
	  		var x = 755;
	  		var y = 425;

	  		var temp = '<span class="multimedia_content multimedia_content_resized"><object width="730" height="410"><param name="movie" value="'+'http://www.youtube.com/v/'+ video +'&rel=1"></param><param name="wmode" value="transparent"></param><embed src="'+'http://www.youtube.com/v/'+ video +'&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="730" height="410"></embed></object><a class="multimedia_restore" href="javascript:reload_multimedia('+id+',\''+video+'\',\'1\');">restaurar</a></span>';

	  		$jQ('#'+capa).addClass('multimedia_resized');

	  	}else{
			var x = 149;
	  		var y = 112;

	  		var temp = '<span class="multimedia_content"><img width="'+x+'" height="'+y+'" alt="" title="" src="http://i4.ytimg.com/vi/'+video+'/0.jpg"><a href="javascript:reload_multimedia(1458, \''+video+'\', \'0\');"><img width="'+x+'" height="'+y+'" alt="" title="" class="video_mosca" src="'+APP_DIR+'media/img/1pxtrans.gif"></a></span>';

	  		$jQ('#'+capa).removeClass('multimedia_resized')

	  	}

		  $jQ('#'+capa).width(x);
		  $jQ('#'+capa).height(y);
		  $jQ('#'+capa).html(temp);
	}

}

function cortina(capa)
{
	if ($jQ('#'+capa).is(":hidden")) {
   $jQ('#'+capa).show("slow");
  } else {
   $jQ('#'+capa).slideUp();
  }
}


function mostrar(capa){
	 close_forms();
	 $jQ("#"+capa).toggle();
}


function votar(voto)
{
	if(voto){

		var temp = voto.split('_');

		var points     = temp[0];
		var item_id    = temp[1];
		var item_type  = temp[2];
		var show_id    = temp[3];
		var bd_id      = temp[4];

		var parametro  = '"'+temp[1]+'_'+temp[2]+'"';
		var url        = APP_URL + 'comunidad/ajaxSaveVoteSextaTv';
		var url_pagina =  jQuery('[id=form_comment] input[name=url]').val();
		var capa       = "votar_"+item_id;

		new Ajax.Request(url , {
				method: 'post',
				asynchronous: true,
				encoding: 'utf-8',
				parameters: {item_id:item_id, item_type:item_type, show_id:show_id, bd_id:bd_id, vote:points, url:url_pagina},
				onCreate: function(){
					$(capa).innerHTML = "<span>cargando...</span>";
		    },
			onSuccess: function(transport) {
				var response = transport.responseText;
				var temp =response.split('-');

				$(capa).innerHTML = "<span>"+temp[1]+"</span>";

				if(temp[0] == 'ok')
				{
					pinta_estrellas(item_id,points);
				}else{
					reset_estrellas(item_id,points);
				}

			},
			onComplete: function(transport) {

			}
		});

	}

}

function votar_video_destacado(voto)
{
	if(voto){

		var temp = voto.split('_');

		var points     = temp[0];
		var item_id    = temp[1];
		var item_type  = temp[2];
		var show_id    = temp[3];
		var bd_id      = temp[4];

		var parametro  = '"'+temp[1]+'_'+temp[2]+'"';
		var url        = APP_URL + 'comunidad/ajaxSaveVoteSextaTv';

		var url_pagina = jQuery('input[id=url_vd_'+item_id+']').val();
		var capa       = "votar_"+item_id;

		new Ajax.Request(url , {
				method: 'post',
				asynchronous: true,
				encoding: 'utf-8',
				parameters: {item_id:item_id, item_type:item_type, show_id:show_id, bd_id:bd_id, vote:points, url:url_pagina},
				onCreate: function(){
					$(capa).innerHTML = "<span>cargando...</span>";
		    },
			onSuccess: function(transport) {
				var response = transport.responseText;
				var temp =response.split('-');

				$(capa).innerHTML = "<span>"+temp[1]+"</span>";

				if(temp[0] == 'ok')
				{
					pinta_estrellas(item_id,points);
				}else{
					reset_estrellas(item_id,points);
				}

			},
			onComplete: function(transport) {

			}
		});

	}

}


function pinta_estrellas(id, flag)
{
	var flag = flag -1;
	$jQ( "ul#estrellas_"+ id + " li" ).each(function( i ){
		var link = $jQ(this).find('a');
    if(i <= flag){
    	link.addClass( 'current-rating' );
    }
	});
}

function reset_estrellas(id)
{

	$jQ( "ul#estrellas_"+ id + " li" ).each(function( i ){
		var link = $jQ(this).find('a');
    link.removeClass( 'current-rating' );
	});
}

/*
function clearForm(form) {

  // iterate over all of the inputs for the form
  // element that was passed in
 $jQ(':input', form).each(function() {
 var type = this.type;
 var tag = this.tagName.toLowerCase(); // normalize case
 // it's ok to reset the value attr of text inputs,
 // password inputs, and textareas
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = "";
 // checkboxes and radios need to have their checked state cleared
 // but should *not* have their 'value' changed
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 // select elements need to have their 'selectedIndex' property set to -1
 // (this works for both single and multiple select elements)
 else if (tag == 'select')
   this.selectedIndex = -1;
  });
};
*/

function clearForm(identificador)
{
	// Limipamos el formulario

	// Nombre
	jQuery('form[id=form'+identificador+'] input[id=author_name_'+identificador+']').val("");
	// Email
	jQuery('form[id=form'+identificador+'] input[id=email_'+identificador+']').val("");
	// Website
	jQuery('form[id=form'+identificador+'] input[id=website_'+identificador+']').val("");
	// Comentario
	jQuery('form[id=form'+identificador+'] textarea[id=comment_'+identificador+']').val("");
	// Url Youtube
	jQuery('form[id=form'+identificador+'] input[id=url_youtube_'+identificador+']').val("");
	// Imagen
	jQuery('form[id=form'+identificador+'] input[id=imagen_'+identificador+']').val("");
	// Captcha
	jQuery('form[id=form'+identificador+'] input[id=captcha_'+identificador+']').val("CODIGO");

	// Imagen Previa
	cancel_upload_picture_comment(identificador);
	jQuery('div[id=image_upload_'+identificador+'] div[id=imgPreview] img[id=thumbnail_picture]').attr('src', APP_URL+'media/common/img/1pxtrans.gif');
//	jQuery('div[id=image_upload_'+identificador+'] input[name=imagen_'+identificador+']').val("");
//	jQuery('div[class=qq-upload-list] ul li').remove();
//	jQuery('div[id=image_upload_'+identificador+'] div[id=imgPreview_'+identificador+'] img[id=thumbnail_picture_'+identificador+']').attr('src', APP_URL+'tmp/'+fileName);

	// Ocultamos las vistas y marcarmos el radio button por defecto
   	jQuery("div[class*=box_attach_content]").hide();
   	jQuery("div[class*=box_attach_content]").hide();
   	// Marcamos el radio buttom

	jQuery("label[for=image]").removeClass("selected");
	jQuery("label[for=image]").parent('div.radio').find('input').attr('checked',false);

	jQuery("label[for=video]").removeClass("selected");
	jQuery("label[for=image]").parent('div.radio').find('input').attr('checked',false);

	jQuery("label[for=empty]").addClass("selected");
	jQuery("label[for=image]").parent('div.radio').find('input').attr('checked',true);


	// Por ultimo recargamos el captcha
	reload_captcha('small', 'captcha_img');

};

function subir_youtube(identificador)
{

  if($('urlYoutube_'+identificador).value != "")
  {
    var parte1 = $('urlYoutube_'+identificador).value.split("=");
    if(parte1[1] != ""){$('mini_cap_preview_'+identificador).innerHTML = '<img src="http://i4.ytimg.com/vi/'+parte1[1]+'/default.jpg"/>';}
    $('url_youtube_'+identificador).setAttribute('value', $('urlYoutube_'+identificador).value );
    $('imagen_'+identificador).setAttribute('value', "" );
  }
}

function cancelar(identificador)
{

	if(identificador){

		var imagen = jQuery("#form_comment #imagen_"+identificador).attr('value');
		if( imagen != ''){borrar_imagen_temp(imagen);}

		jQuery("#form_comment #imagen_"+identificador).attr('value', '');
		jQuery("#form_comment #url_youtube_"+identificador).attr('value', '');
		jQuery("#form_comment #urlYoutube_"+identificador).attr('value', 'URL de YouTube...');

		jQuery("#form_comment #error_form_"+identificador).attr('value', 'Recordamos que los comentarios serán moderados.');
		jQuery("#form_comment #error_form_"+identificador).removeClass('confirmacion hidden error normal').addClass('advertencia');

		var img = '<img src="'+APP_DIR+'media/img/1pxtrans.gif" width="100" height="74" alt="" class="nohayfoto" />';
		jQuery("#form_comment #mini_cap_preview_"+identificador).html(img);

		//poner el menu en el primero
		mostrar('form_comment');

	}
}

function cancel_form(identificador)
{
	if(identificador){
		var imagen = jQuery("#imagen_"+identificador).attr('value');
		if(imagen != ''){borrar_imagen_temp(imagen);}
		close_forms();
	}
}

function close_forms(){
	jQuery( 'div[class*=comentarios_item_tofill]' ).empty();
}

function close_answer(identificador){
  jQuery("#answer_"+identificador).attr('value', '');
}

function close_multimedia(){
jQuery( 'div[class*=comentarios_item_tofill]' ).find().each(function(){
		jQuery(this).html('');
	});
}

function borrar_imagen_temp(imagen)
{
	if(imagen){

		var url  = APP_URL + 'comunidad/ajaxDeleteImageSextaTv';

		new Ajax.Request(url , {
				method: 'post',
				asynchronous: true,
				encoding: 'utf-8',
				parameters: {imagen:imagen},
				onCreate: function(){},
				onSuccess: function(transport) {},
				onComplete: function(transport) {}
		});

	}
}

function reload_captcha(type, id)
{
	if (type == '')
		type = 'small';

	var url = APP_URL+'captcha/'+type+'/';
	var randomnumber = Math.floor(Math.random() * 10000000);

	jQuery('img[id=' + id + ']').attr('src', url + randomnumber );

}

function is_array(input){
	return typeof(input)=='object'&&(input instanceof Array);
}

function send_comment(identificador)
{
	if(identificador)
	{
		var url = APP_URL+'comunidad/ajaxSaveCommentSextaTv';

		// Obtenemos los valores del formulario
		emailValue 			= jQuery('input[id=email_'+identificador+']').val();
		urlValue 			= jQuery('input[id=url'+identificador+']').val();
		commentValue 		= jQuery('textarea[id=comment_'+identificador+']').val();
		author_nameValue	= jQuery('input[id=author_name_'+identificador+']').val();
		author_idValue 		= jQuery('input[id=author_id_'+identificador+']').val();
		urlYoutubeValue		= jQuery('input[id=url_youtube_'+identificador+']').val();
		show_idValue		= jQuery('input[id=show_id_'+identificador+']').val();
		bd_idValue			= jQuery('input[id=bd_id_'+identificador+']').val();
		item_idValue		= jQuery('input[id=item_id_'+identificador+']').val();
		item_typeValue		= jQuery('input[id=item_type_'+identificador+']').val();
		// Obtenemos el valor de la previa
		imagenPreview       = jQuery('input[id=image_upload_name_'+identificador+']').val();
		imagenValue			= imagenPreview, // jQuery('input[id=imagen_'+identificador+']').val(),

		captchaValue		= jQuery('input[id=captcha_'+identificador+']').val();
		responseValue		= jQuery('input[id=response_'+identificador+']').val();

		// Limpiamos la capa de informacion general por si se hubiera quedado un error anteriormente
		jQuery('div[id=info_general_'+identificador+']').removeClass('info_ok info_error').addClass('hidden').html();


		var conditionsValue = 0;
		if(jQuery('label[id=LopdLink]'))
		{
			if(jQuery('label[id=LopdLink]').attr("class"))
			{
				if(jQuery('label[id=LopdLink]').hasClass('selected'))
				{
					var conditionsValue = 1;
				}
			}
		}

		jQuery.ajax({
			url:  url,
			type: 'post',
			data: {
				email 		: emailValue,
				url			: urlValue,
				comment		: commentValue,
				author_name : author_nameValue,
				author_id   : author_idValue,
				urlYoutube	: urlYoutubeValue,
				show_id		: show_idValue,
				bd_id		: bd_idValue,
				item_id		: item_idValue,
				item_type	: item_typeValue,
				conditions	: conditionsValue,
				imagen		: imagenValue,
				captcha		: captchaValue,
				response	:responseValue,
			},
			dataType:	'json',
			success:	function (dataResponse, textStatus, XMLHttpRequest) {

				// Esta variable nos indica si se ha producido un error para recargar el captcha
				if (dataResponse)
				{
					if (is_array(dataResponse))
					{
						for (i=0; i < dataResponse.length; i++) {
							var temp = dataResponse[i].split('-');
							if (temp[0] == 'ko')
							{
								// Detecto si es un error normal o es general
								if (temp[2] == 'info_general')
									jQuery('div[id='+temp[2]+'_'+identificador+']').removeClass('hidden').addClass('info_error').slideDown('fast').html(temp[1]);
								else
									jQuery('div[id='+temp[2]+'_'+identificador+']').addClass('info_error').slideDown('fast').html(temp[1]);
							}
						}

						// Si tenemos un array es que hay un error
						reload_captcha('small', 'captcha_img');
						jQuery('input[id=captcha_'+identificador+']').val('');
					}
					else
					{
						var temp = dataResponse.split('-');
						if( temp[0] == 'ok')
						{
							jQuery('div[id=info_general_'+identificador+']').removeClass('hidden').removeClass('info_error').addClass('info_ok').html(temp[1]);

							// Limpiamos el formulario
							clearForm(identificador);
						}
						else
						{
							jQuery('div[id=info_general_'+identificador+']').removeClass('hidden').removeClass('info_ok').addClass('info_error').html(temp[1]);

							// Como tenemos un error recargamos el captcha
							reload_captcha('small', 'captcha_img');
							jQuery('input[id=captcha_'+identificador+']').val('');
						}
					}
				}
			},
			complete: function (dataComplete, textStatus2, XMLHttpRequest)
			{
				var temp2 = dataComplete.responseText.split('-');
				if (temp2[0] == 'ko')
				{
					jQuery('div[id=info_general_'+identificador+']').removeClass('hidden info_ok').addClass('info_error').html(temp2[1]);

					// Como tenemos un error recargamos el captcha
					reload_captcha('small', 'captcha_img');
					jQuery('input[id=captcha_'+identificador+']').val('');
				}
				else
				{
					if (temp2[0] == 'ok')
					{
						jQuery('div[id=info_general_'+identificador+']').removeClass('hidden info_error').addClass('info_ok').html(temp2[1]);

						// Limpiamos el formulario
						clearForm(identificador);
					}
				}
			}
		});
	}
}

function cancel_upload_picture_comment(identificador)
{
	prevImg = jQuery('div[id=image_upload_'+identificador+'] input[name=imagen_'+identificador+']').val();
	if (prevImg != '')
	{
		// Borramos la imagen del temporal
		jQuery('div[class=qq-upload-list] ul:first').remove();
		jQuery('div[id=image_upload_'+identificador+'] input[name=imagen_'+identificador+']').val('');
		jQuery('div[id=image_upload_'+identificador+'] div[id=imgPreview] img[id=thumbnail_picture]').attr('src', APP_URL+'media/common/img/1pxtrans.gif');

		// Llamamos a la funcion que nos elimina el fichero del temporal con prevImg
		jQuery.ajax({
			url:  APP_URL+'comunidad/ajaxDeleteImageCommentGeneric',
			type: 'post',
			data: { imagen : prevImg },
			dataType:	'json',
			success:	function (dataResponse, textStatus, XMLHttpRequest) {}
		});
	}
}

function createUploader(identificador){

	var uploader = new qq.FileUploader({
		element: document.getElementById('picture-uploader-'+identificador),
		action: APP_URL+'media/common/js/upload_file.php',
		allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
		sizeLimit: 1024000,
		multiple: false,
		onComplete: function(id, fileName, responseJSON){
			// Comprobamos que previamente no se haya subido una imagen
			prevImg = jQuery('div[id=image_upload_'+identificador+'] input[name=imagen_'+identificador+']').val();
			if (prevImg != '')
			{
				// Borramos la imagen del temporal
				jQuery('div[class=qq-upload-list] ul:first').remove();
			}

			// Actualizamos el input hidden
			jQuery('div[id=image_upload_'+identificador+'] input[name=imagen_'+identificador+']').val(fileName);

			// Mostramos la vista previa y los datos del fichero
			jQuery('div[id=image_upload_'+identificador+'] div[id=imgPreview_'+identificador+'] img[id=thumbnail_picture_'+identificador+']').attr('src', APP_URL+'temp/'+fileName);
			jQuery('div[id=image_upload_'+identificador+'] div[id=imgPreview_'+identificador+']').show();
		},
		onCancel: function(id, fileName){
		},
		showMessage: function(message){
			jQuery('div[id=info_image_upload_name_'+identificador+']').slideUp('fast');
		}
	});
}

function __initialize()
{
	jQuery(document).find('[class=answer]').empty();
	jQuery(document).find('span[class=status][name=1]').show();
	jQuery(document).find('span[class=status][name=2]').hide();
}

function initialize(identificador)
{
	__initialize();

	jQuery('a[class=responderbox_comments]').toggle(
		function(){
			// Empty previously openened answers
			jQuery(document).find('[class=answer]').empty();

			// Import answers belongs to current item
			answers( jQuery(this).attr( 'item_id' ) );

			__initialize();

			// Toggles text to show close link
			jQuery(this).find('span').toggle();
		},
		function(){
			// Empty previously openened answers
			jQuery(document).find('[class=answer]').empty();
			__initialize();
		}
	);
}

