// JavaScript Document

function objetus() {
			 try {
					 objeto = new ActiveXObject("Msxml2.XMLHTTP");
			} catch ( e) {
					 try {
							 objeto= new ActiveXObject (" Microsoft.XMLHTTP");
					 } catch (E) {
							  objeto= false;
					}
			}
			if (! objeto && typeof XMLHttpRequest!= 'undefined') {
					 objeto = new XMLHttpRequest();
			}
			return objeto;
}


function anadir_entrada_blog(seccion) {
	  
		var aleatorio=Math.random();
		var cod_admin = document.getElementById('cod_admin').value;
		var fecha = document.getElementById('fecha').value;
		var titulo = document.getElementById('titulo').value;
		var descripcion = document.getElementById('descripcion').value;
		var seccion = seccion;
		
		var url = "anadir_entrada_blog.php?";
		var params = "cod_admin="+cod_admin+"&fecha="+fecha+"&seccion="+seccion+"&titulo="+titulo+"&descripcion="+descripcion+"&nocache="+aleatorio+"";
		
		var http = objetus();
		http.open("POST", url, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				/*document.getElementById("flecha-dia-menos-aqua").style.display ='none';
				document.getElementById("flecha-dia-mas-aqua").style.display ='none';
				document.getElementById("texto_dia_horario-aqua").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';*/
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('contenido-blog').innerHTML = http.responseText;
				
			}
		}
		http.send(params);		
}

function borrar_entrada_blog(cod_blog , seccion)
{
	var aleatorio=Math.random();
	
	var cod_blog = cod_blog;
	var seccion = seccion;
	
	var url = "borrar_entrada_blog.php?";
	var params = "cod_blog="+cod_blog+"&seccion="+seccion+"&nocache="+aleatorio+"";
	
	var http = objetus();
	http.open("POST", url, true);
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
			/*document.getElementById("flecha-dia-menos-aqua").style.display ='none';
			document.getElementById("flecha-dia-mas-aqua").style.display ='none';
			document.getElementById("texto_dia_horario-aqua").style.display ='none';
			document.getElementById("loadingdiv").style.display ='block';*/
		}
		if(http.readyState == 4 && http.status == 200) {
			document.getElementById('contenido-blog').innerHTML = http.responseText;
			
		}
	}
	http.send(params);		
	
}

function guardar_comentario(cod_blog, cod_usu, seccion) {
	  
		var aleatorio=Math.random();
		
		var comentario = document.getElementById('comentario'+cod_blog).value;
		var fecha2 = document.getElementById('fecha2').value;
		
		var cod_blog = cod_blog;
		var cod_usu = cod_usu;
		var seccion = seccion;
		
		var url = "anyadir_comentario_blog.php?";
		var params = "cod_blog="+cod_blog+"&fecha2="+fecha2+"&cod_usu="+cod_usu+"&seccion="+seccion+"&comentario="+comentario+"&nocache="+aleatorio+"";
		
		var http = objetus();
		http.open("POST", url, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				/*document.getElementById("flecha-dia-menos-aqua").style.display ='none';
				document.getElementById("flecha-dia-mas-aqua").style.display ='none';
				document.getElementById("texto_dia_horario-aqua").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';*/
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('contenido-blog').innerHTML = http.responseText;
				
			}
		}
		http.send(params);		
}

function borrar_comentario(cod_coment, cod_blog, cod_usu, seccion )
{
	var aleatorio=Math.random();
		
	var cod_coment = cod_coment;
	var cod_blog = cod_blog;
	var cod_usu = cod_usu;
	var seccion = seccion;
	
		
		var url = "borrar_comentario_blog.php?";
		var params = "cod_blog="+cod_blog+"&cod_coment="+cod_coment+"&cod_usu="+cod_usu+"&seccion="+seccion+"&nocache="+aleatorio+"";
		
		var http = objetus();
		http.open("POST", url, true);
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{//Call a function when the state changes.
			if (http.readyState == 1) { // Cargando...
				/*document.getElementById("flecha-dia-menos-aqua").style.display ='none';
				document.getElementById("flecha-dia-mas-aqua").style.display ='none';
				document.getElementById("texto_dia_horario-aqua").style.display ='none';
				document.getElementById("loadingdiv").style.display ='block';*/
			}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('contenido-blog').innerHTML = http.responseText;
				
			}
		}
		http.send(params);		
}


