// JavaScript Document
//Insertado para mantener UTF-8 en Dreamweaver: æø

function __envComm(ia){
	
	__opnPrModWin('eComm',null,ia);
	
}

function __realEnvCom(idArt, forma){
	
	comentarito	=	document.getElementById('rsb_com').value;
	
	if(document.getElementById('genModalStatus')){
		
		
		statusCont					=	document.getElementById('genModalStatus');
		
		if(comentarito.length >= 2){




			statusCont.innerHTML		=	mensajeCargando('Enviando comentario...');
			
			conexion					=	new __invokeGuruAjax();
			conexion.url				=	_siteRoot + 'etc/ajax/ed/actions/comment.do';
			conexion.method				=	'POST';
			conexion.postData			=	'&art='+idArt+'&c=' + comentarito;
			conexion.onComplete			=	function(){
				
				if(conexion.fResponse[0]){
					
					if(conexion.fResponse[1] == 'si'){
						
						
						mensaje			=	crearEspacioMensaje('ok','Hemos recibido tu comentario. Esta ventana se actualizará en unos segudos, si no se actualiza, haz <a href="javascript:;" onclick="window.location.reload()">click aquí</a>.');
							setTimeout("window.location.reload()",2000);
												
					} else {
						mensaje			=	crearEspacioMensaje('warning','No pudimos recibir tu mensaje. ' + conexion.fResponse[1]);
					}
					
				} else {
					mensaje				=	crearEspacioMensaje('warning','No pudimos recibir tu mensaje. ' + conexion.fResponse[1]);
				}
				
				statusCont.innerHTML 	=	'';
				statusCont.appendChild(mensaje);
				
			}
			conexion.callRequest();








		} else {
			
			
			mensaje					=	crearEspacioMensaje('warning','Úps, tu comentario es muy corto');
			statusCont.innerHTML	=	'';
			statusCont.appendChild(mensaje);
			
		}
		
		
	}
	
	
	
	return false;
}


function __votarComentario(cid,mo,vo){
	
	if(mo == 'mas' || mo == 'menos' && vo.parentNode.getAttribute('enviando') != 'simon'){
		
		botones						=	vo.parentNode.getElementsByTagName('img');
		
		botones[0].style.opacity		=	0.5;
		botones[0].style.MozOpacity		=	0.5;
		botones[0].style.KhtmlOpacity	=	0.5;
		botones[0].style.filter			=	'alpha(opacity=50)';
		
		botones[1].style.opacity		=	0.5;
		botones[1].style.MozOpacity		=	0.5;
		botones[1].style.KhtmlOpacity	=	0.5;
		botones[1].style.filter			=	'alpha(opacity=50)';
		
		vo.parentNode.setAttribute('enviando','simon');
		
		conexion					=	new __invokeGuruAjax();
		conexion.url				=	_siteRoot + 'etc/ajax/ed/actions/comment-vote.do';
		conexion.method				=	'POST';
		conexion.postData			=	'&c='+cid+'&a='+mo;
		conexion.onComplete			=	function(){
			
			if(conexion.fResponse[0]){
				
				regreso	=	conexion.fResponse[1].split('_RASEP_');
				if(regreso[0] == '1'){
					
					if(regreso[1].match(/[\-]?[\d]{1,255}/)){
						
						convoto	=	'lnrVcm_' + cid;
						if(document.getElementById(convoto)){
							
							document.getElementById(convoto).innerHTML	=	regreso[1];
							
						}
						
					} else {
						
						window.location.reload();
						
					}
					
											
				} else {
					
								
					if(document.getElementById('genPerfilModal')){
						document.body.removeChild(document.getElementById('genPerfilModal'));
					}
					
					
					var ventanaModal			=	new radioAlternativaModal();
					ventanaModal.nombre			=	'genPerfilModal';
					ventanaModal.crearVentana();
					
					if(regreso[1].indexOf('loginForm')){
						
						ventanaModal.contenido		=	regreso[1];
						
					} else {
						
						mensaje						=	crearEspacioMensaje('warning', regreso[1]);				
						ventanaModal.contenido		=	mensaje.innerHTML;;
						
					}
					

					
					
					ventanaModal.llenarVentana();					
					
					
				}
				
			} else {
				alert('Error temporal al intentar registrar el voto. Por favor intenta nuevamente.');
			}


			botones[0].style.cssText		=	'';
			botones[1].style.cssText		=	'';
			
			vo.parentNode.setAttribute('enviando','nel');
			
		}
		conexion.callRequest();

		
		
	}
	
	
}




function comToggle(ln){
	
	objeto	=	ln.parentNode.parentNode;
	
	if(objeto.className == 'rComen ahogado'){
		
		ln.innerHTML		=	'Ya no lo quiero ver';
		ln.style.color		=	'#f00';
		objeto.className	=	'rComen';	
		
	} else {
		
		ln.innerHTML		=	'No importa, quiero verlo';
		ln.style.cssText	=	'';
		objeto.className	=	'rComen ahogado';	
		
	}
	
}



function __reordenarComentarios(cli,ida){
	
	
	if(document.getElementById('listaRealDeComentarios')){
		
		cli.disabled				=	true;
		tron						=	document.getElementById('listaRealDeComentarios');
		tron.innerHTML				=	mensajeCargando('Ok, ok... estamos ordenando los comentarios');
	
		conexion					=	new __invokeGuruAjax();
		conexion.url				=	_siteRoot + 'etc/ajax/ed/actions/comments-order.do?a='+ida+'&o='+cli.value;;
		conexion.onComplete			=	function(){
			
			if(conexion.fResponse[0]){
				
				tron.innerHTML		=	conexion.fResponse[1];
				ejecutarScripts(tron);
				
			} else {
				alert('Error temporal al intentar registrar el voto. Por favor intenta nuevamente.');
			}
			
			cli.disabled			=	false;
	

			
		}
		conexion.callRequest();	
		
		
	}
	
	
	
	
}














function __calavera(mo,ida,rf){
	
	
	votador	=	'conVotos_' + ida;
	
	if(document.getElementById(votador)){
		
		votador	=	document.getElementById(votador);
	
		
		if(mo == 'votar' || mo == 'ahogar' && votador.getAttribute('enviando') != 'simon'){
			
			valorTemporal		=	votador.innerHTML;
			votador.innerHTML	=	'<img src="'+_siteRoot+'media/generico/wait_16.gif" width="16" height="16" />';
			votador.setAttribute('enviando','simon');
			
			conexion					=	new __invokeGuruAjax();
			conexion.url				=	_siteRoot + 'etc/ajax/ed/actions/articulo-votar.do?&a='+ida+'&f='+mo+'&r='+rf;
			conexion.onComplete			=	function(){
				
				if(conexion.fResponse[0]){
					
					regreso	=	conexion.fResponse[1].split('_RASEP_');
					if(regreso[0] == '1'){
						
						if(regreso[1].match(/[\-]?[\d]{1,255}/)){
							
						
							votador.innerHTML	=	regreso[1];
							
						} else {
							
							window.location.reload();
							
						}
						
												
					} else {
						
									
						if(document.getElementById('genPerfilModal')){
							document.body.removeChild(document.getElementById('genPerfilModal'));
						}
						
	
						var ventanaModal			=	new radioAlternativaModal();
						ventanaModal.nombre			=	'genPerfilModal';
						ventanaModal.crearVentana();
						
						if(regreso[1].indexOf('loginForm') > 10){
							
							ventanaModal.contenido		=	regreso[1];
							
						} else {
							
							mensaje						=	crearEspacioMensaje('warning', regreso[1]);				
							ventanaModal.contenido		=	mensaje.innerHTML;;
							
						}
						
	
						
						
						ventanaModal.llenarVentana();
						
						votador.innerHTML	=	valorTemporal;
						
						
					}
					
				} else {
					alert('Error temporal al intentar registrar el voto. Por favor intenta nuevamente.');
					votador.innerHTML	=	valorTemporal;
				}
	
				
				votador.setAttribute('enviando','nel');
				
			}
			conexion.callRequest();
	
			
			
		}
		
		
	}
	
	
	
}











