// JavaScript Document
/*
	File: comunidad-profesionales-home.js
	Path: http://demo.brandigital.com/ga.ma/institucional/sitio/regionales/es-AR/js/comunidad-profesionales-home.js
	Autor: Manuel Avalos
	Fecha Inicio: 23-03-2009
	Fecha Fin:
	Version: 1.0
	Modificacion 1: 23-03-2009 por Manuel Avalos.
	Modificacion 2: 
	Modificacion 3: 
*/


$().ready(function(){		   
	
	$("#tapa_ventana_inicial").hide();
	
	$("#carga_comunidad_mensaje").click(function(){
		mostrar_alerta("Debes estar logueado para cargar tu propuesta.",0);
	});
	
	$.ajax({
		url: config['controller'],
		dataType: "xml",
		type: "POST",
		data: {paiId:config_codigo_paises[config['idioma']],pagnum:1,status:1,cantpag:2,orden:"DESC",acoid:config['acoid'],action:"multimedia.multimediasgetpag"},
		success:function envia_datos(xml){
			var res = "";
			var imagen_redimencionada = ""
			$('status',xml).each(function(i) {
				
				if($(this).attr("code")==0){
					$('tema',xml).each(function(i) {
						//PROPIEDADES DE LA FOTO
						var propiedades_foto="&w=150&h=150";
						
						
						if($(this).find("imagen").text()!=""){
							imagen_redimencionada=config['servicio_redimencionar_imagen']+trim($(this).find("imagen").text())+propiedades_foto;
							//$("#cph_imagen_"+(i+1)).attr({src:config['servicio_redimencionar_imagen']+trim($(this).find("imagen").text())+propiedades_foto});							
						}else{
							imagen_redimencionada=config['servicio_redimencionar_imagen']+trim($(this).find("imgyt").text())+propiedades_foto;
							//$("#cph_imagen_"+(i+1)).attr({src:config['servicio_redimencionar_imagen']+trim($(this).find("imgyt").text())+propiedades_foto});							
						}

						res +='<div>';
						res +='  <p><img id="cph_imagen_" src="'+imagen_redimencionada+'" alt="propuestas" /><a href="/'+config['pais_url']+'/propuestadetalle/'+$(this).attr("id")+'"> <strong class="txBlack">Propuesta realizada por:</strong> <br />';
						res +='	<strong id="cph_nombre_">'+$(this).find("nombre").text()+'</strong></a>';
						res +='	<br /><br />';
						res +='	<p id="cph_contenido_">'+$(this).find("descripcion").text();
						res +='</p>';
						res +='	<br />';
						res +='	<a id="cph_link_" href="/'+config['pais_url']+'/propuestadetalle/'+$(this).attr("id")+'" class="lComentarios">'+$(this).attr("comentarios")+' Comentarios</a> </p>';
						res +='</div>';

						
						/*//PROPIEDADES DE LA FOTO
						var propiedades_foto="&w=150&h=150";
						
						$("#cph_nombre_"+(i+1)).html($(this).find("nombre").text());
						$("#cph_contenido_"+(i+1)).html($(this).find("descripcion").text());
						$("#cph_link_"+(i+1)).attr({href:"comunidad-profesionales-detalle.php?post="+$(this).attr("id")});
						$("#cph_link_"+(i+1)).html($(this).attr("comentarios")+" Comentarios");
						
						
						
						
						if($(this).find("imagen").text()!=""){
							$("#cph_imagen_"+(i+1)).attr({src:config['servicio_redimencionar_imagen']+trim($(this).find("imagen").text())+propiedades_foto});							
						}else{
							$("#cph_imagen_"+(i+1)).attr({src:config['servicio_redimencionar_imagen']+trim($(this).find("imgyt").text())+propiedades_foto});							
						}*/
						
					})
					$("#propuestas-box").html(res);
					links("#propuestas-box");
				}else{
					mostrar_alerta(""+$(this).attr("code")+" - "+$(this).attr("descripcion"),0);	
				}
				
			})
			
			
			
			
			
			
			
		},
		error:function manejo_error(error){
			//mostrar_alerta("Error al cargar la informaci&oacute;n.",0);
		}
	});
});	
	