function opinion(nombre, texto, fecha, img_name, img_small_name){
	
	this.nombre = nombre;
	this.texto = texto;
	this.fecha = fecha;
	this.img = new Image();
	this.img.src = img_name;
	this.img_small = new Image();
	this.img_small.src = img_small_name;
	

}

var array_comentarios = new Array();


var num_previews = 3;
var actual_offset;
var bgColor_selectedStyle = "#00A994";



function img_preload(){

	actual_offset = 0;
	
	load_img(array_comentarios[1], document.getElementById("prev_01"));
	

}

function load_img(comentario, img_obj) {

	var imgLat = document.getElementById("img_ppal");
	imgLat.src = comentario.img.src;
	
	var div_fecha = document.getElementById("fecha_opinion");
	div_fecha.innerHTML = comentario.fecha;
	
	var div_nombre = document.getElementById("nombre_opinion");
	div_nombre.innerHTML = comentario.nombre;
	
	var div_texto = document.getElementById("texto_opinion");
	div_texto.innerHTML = comentario.texto;
	
	
	img_obj.parentNode.style.backgroundColor = bgColor_selectedStyle;

}

function select_image(img_nro){
	for(i=0; i<num_previews; i++){
		var celdilla = document.getElementById("prev_" + pad(i));
		celdilla.parentNode.style.backgroundColor = "";
		
	}
	
	celdilla = document.getElementById("prev_" + pad(img_nro));
	
	load_img(array_comentarios[(parseInt(img_nro)+actual_offset) % array_comentarios.length], celdilla);
}

function scroll_imgBrowser(cant){
	
	var posicion, pev_img;
	
	actual_offset = (actual_offset + cant) % array_comentarios.length;
	
	actual_offset = (actual_offset < 0) ? actual_offset + array_comentarios.length : actual_offset;  
	
	for(i=0; i<num_previews; i++){
		posicion = (actual_offset + i) % array_comentarios.length;
		pev_img = document.getElementById("prev_" + pad(i));

		pev_img.src = array_comentarios[posicion].img_small.src;
		
		/*probando*/
		//pev_img.onclick = select_image(i);
		
		if(pev_img.parentNode.style.backgroundColor != ""){
			load_img(array_comentarios[posicion], pev_img);
		}
			
	}
}

function pad(entero){
      return entero<10 ? "0"+entero : entero;
}



