function iniciarDinImgs(tabla, tablaRel, valores, dirDestino, campos, campoUrl, campoId, valorId, multiples){
	var clase = this;
	new AjaxUpload('#btn_imagen', {
  		action: 'sistema/cmworks/herramientas/imagenDinamica.php',
  		onSubmit: function(file, extension) {
			this.setData({
				tabla : tabla,
				tablaRel : tablaRel,
				valores : valores,
				dirDestino : dirDestino,				
				campos : campos,				
				accion : 'subirImgJ'
  			})
			$('#cmwDivMagia').html("<img src='"+clase.dirImg+"cargando.gif'> Subiendo imagen...");
		},
  		onComplete: function(file, response) {
			$('#cmwDivMagia').html("<img src='"+clase.dirImg+"ok.png'> Imagen "+file+" subida. Cargando Miniaturas");
			clase.imgsMostrarMinis(tabla, tablaRel, campoUrl, campoId, valorId);
			if(!multiples){
				$("#btn_imagen").attr("enabled","false");
			}
		}
	});
	clase.imgsMostrarMinis(tabla, tablaRel, campoUrl, campoId, valorId);
}

function imgsMostrarMinis(tabla, tablaRel, campoUrl, campoId, valorId){
	$.post('sistema/cmworks/herramientas/imagenDinamica.php',{
		tabla : tabla,
		tablaRel : tablaRel,
		campoUrl : campoUrl,
		campoId : campoId,
		valorId : valorId,
		accion : 'mostrarImgJ'
		},function(html){
			$('#cmwDivMagia').html(html);
			$('.redondeado').corner();
			$('.herrMiniHerrfondo').fadeTo(0,.5)
			$('.herrMiniHerr').slideUp(0);
			$('.herrMiniCont').hover(
				function(){
					$(this).children(".herrMiniHerr").slideDown(200);
				},
				function(){
					$(this).children(".herrMiniHerr").slideUp(200);
				}
			);
		}
	);	
}

function imgsBorrar(divCont, url, tabla, tablaRel, campoRel){
	//alert(divCont + url + tabla + tablaRel + campoRel);
	$(divCont).fadeTo(200,.5);
	$.post('sistema/cmworks/herramientas/imagenDinamica.php',{
		url : url,
		tabla : tabla,
		tablaRel : tablaRel,
		campoRel: campoRel,
		accion : 'borrarImgJ'
	},function(html){
		switch (html){
			case 'ok': $(divCont).hide(200); break;	
			case 'ko': alert("No se pudo borrar la imagen "+url); $(divCont).fadeTo(200,1); break;	
			default : alert("Se produjo un error: " + html);	
		} 
	})
}

function imgsMostrar(url){
	alert("voy a mostrar "+url);	
}
