function getXMLHTTPRequest() {



try {



req = new XMLHttpRequest();



} catch(err1) {



  try {



  req = new ActiveXObject("Msxml2.XMLHTTP");



  } catch (err2) {



    try {



    req = new ActiveXObject("Microsoft.XMLHTTP");



    } catch (err3) {



      req = false;



    }



  }



}



return req;



}



var peticion = getXMLHTTPRequest();



///PETICION PARA LA OPINION

function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}

var peticion_opi = getXMLHTTPRequest();













function eliminar_vid(id) {



	var url ="usr_eliminar_vid.php?opcion=1";



	peticion.open("GET", url+ "&id=" + id, true);



	peticion.onreadystatechange = respuestaAjaxElim;



	peticion.send(null);



	}



	



function respuestaAjaxElim() {



	 if (peticion.readyState == 4) {



    if(peticion.status == 200) {






	  //document.getElementById('videos').innerHTML = "VIDEO ELIMINADO";



	 location.href="http://www.fmimpacto107.com.ar/usuario/comentarios/listar.php"
	


	        

		} 



	}



}



function cargaXML(url) {



	//	Primero vamos a ver si la URL es una URL :)



	if(url==''){



		return;



	}



	//	Usuario inteligente...



	if (window.XMLHttpRequest) {



		peticion = new XMLHttpRequest();



		peticion.onreadystatechange = processReqChange;



		var nocache=parseInt(Math.random()*99999999);



		peticion.open("GET", url + "?rand=" + nocache, true);



		peticion.send(null);



	//	...y usuario de Internet Explorer Windows



	} else if (window.ActiveXObject) {



		isIE = true;



		peticion = new ActiveXObject("Microsoft.XMLHTTP");



		var nocache=parseInt(Math.random()*99999999);



		if (peticion) {



			peticion.onreadystatechange = processReqChange;



			peticion.open("GET", url + "?rand=" + nocache, true);



			peticion.send();



		}



	}



}







//	Funcion que se llama cada vez que se dispara el evento onreadystatechange



//	del objeto XMLHttpRequest



function processReqChange(){



	var detalles = document.getElementById("videos");



	if(peticion.readyState == 4){



		detalles.innerHTML = peticion.responseText;



	} else {



		detalles.innerHTML = '<img src="img/cargador.gif" align="middle" /> Cargando...';



	}



}











function enviando(){
var enviaok=1;
var titulo_vid=document.getElementById('tit_vid').value;
var desc_vid=document.getElementById('desc_vid').value;
var img_vid=document.getElementById('archivoimagen').value;
var vid_vid=document.getElementById('archivovideo').value;

if (titulo_vid==""){
	alert ("El video debe tener un titulo");
	enviaok=0;
}
if (desc_vid==""){
	alert ("El video debe tener alguna descripcion");
	enviaok=0;
}
if (img_vid==""){
	alert ("Elegi alguna foto para el video");
	enviaok=0;
}	
if (vid_vid==""){
	alert ("Falta el video FLV");
	enviaok=0;
}	

if (enviaok==1){
document.getElementById('divEnviar').submit();



document.getElementById('divEnviar').style.visibility="hidden";



document.getElementById('divCargando').style.visibility="visible";		
}


}







function advertencia(id, tit){



var	titulo = '"' + tit + '"';



if (confirm ("Esta seguro de borrar: " + titulo)){



	eliminar_vid(id);



	}



}



function verificarmail(){
var s = document.getElementById('mail').value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 ) enviarCom();
if (filter.test(s))
enviarCom();
else
alert("Ingrese una dirección de correo válida");
document.getElementById('mail').focus();
return false;
}


function enviarCom(){

var nombre = document.getElementById('nombre').value;

var mail = document.getElementById('mail').value;

var comentario = document.getElementById('comentario').value;

	

if (nombre!=="" & mail!=="" & comentario!==""){	

	document.getElementById('btn_enviar').disabled=true;
	document.getElementById('nombre').disubled=true;
	document.getElementById('mail').disubled=true;
	document.getElementById('comentario').disubled=true;


	document.getElementById('btn_enviar').value="Enviando..";

	

	var id_nota=document.getElementById('id_nota').value;



	peticion.open("POST","http://www.fmimpacto107.com.ar/noticias/insertarcom.php", true);



	peticion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");



	peticion.send("nombre="+nombre+"&mail="+mail+"&comentario="+comentario+"&id_nota="+id_nota);
	


	peticion.onreadystatechange=respuestaAjaxInsert;

}

	else

	{

		alert ("DEBE COMPLETAR TODOS LOS DATOS PARA PODER ENVIAR SU COMENTARIO");

	}

		



}



function respuestaAjaxInsert() {

	 if (peticion.readyState == 4) {

    if(peticion.status == 200) {
	 document.getElementById('nombre').value=""
	 document.getElementById('mail').value=""
	 document.getElementById('comentario').value=""
	 document.getElementById('btn_enviar').disabled=false;
	 document.getElementById('btn_enviar').value="Enviar"
document.getElementById('div_mensaje_comentario').style.visibility="visible";		 
		
	
		}

	}

}


function rechazarCom(id){

if (confirm ("SEGURO QUE DESEA ELIMINAR EL COMENTARIO?")){

	

	var url ="abm_comentarios.php?opcion=2";
	var nocache=parseInt(Math.random()*99999999);



	peticion.open("GET", url+ "&id=" + id + "&nocache=" + nocache, true);



	peticion.onreadystatechange = respuestaAjaxElim;



	peticion.send(null);

}

}



function aprobarCom(id){

if (confirm ("SEGURO QUE DESEA PUBLICAR EL COMENTARIO?")){

	

	var url ="abm_comentarios.php?opcion=3";
	var nocache=parseInt(Math.random()*99999999);


	peticion.open("GET", url+ "&id=" + id + "&nocache=" + nocache, true);



	peticion.onreadystatechange = respuestaAjaxElim;



	peticion.send(null);

}

}







function paginar(p){



s=document.getElementById('s').value;

divContenido = document.getElementById('contenido');

 



 //uso del medoto GET

 //indicamos el archivo que realizará el proceso de paginar

 //junto con un valor que representa el nro de pagina

 peticion.open("GET", "paginador.php?p="+p+"&s="+s, true);

 //divContenido.innerHTML= '<img src="anim.gif">';

 peticion.onreadystatechange=function() {

  if (peticion.readyState==4) {

   //mostrar resultados en esta capa

   divContenido.innerHTML = peticion.responseText;

  }

 }

 //como hacemos uso del metodo GET

 //colocamos null ya que enviamos 

 //el valor por la url ?pag=nropagina

 peticion.send(null);

}

function editar(id){
	
	var url ='usr_form_cargavideo.php?id_vid=' + id;
	var nocache=parseInt(Math.random()*99999999);
	
	peticion.open("GET", url + "&nocache=" + nocache,true);
	peticion.onreadystatechange = respuestaAjaxElim;
	peticion.send(null);
	
}

function getXMLHTTPRequest() {
var req;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        req = new XMLHttpRequest();

}
return req
}



peticion= getXMLHTTPRequest();
num_tipo=1;



function cargar_losmas(){

	if (num_tipo==1){
		num_tipo=2;
		}
		else
		{
			num_tipo=1;
			}
			
	var nocache=parseInt(Math.random()*9999);
	var url = "losmas.php?tipo="+ num_tipo;
	peticion.open("GET", url+ "&rand=" + nocache, true);
	peticion.onreadystatechange = respuesta_ajax_losmas;
	peticion.send(null);	

	
}
function respuesta_ajax_losmas() {
		if (peticion.readyState == 4) {
    if(peticion.status == 200) {
	var browser = navigator.appName;
 
 document.getElementById('div_losmas').innerHTML = peticion.responseText;
setTimeout('cargar_losmas()', 8000);

		
	  }
	  	else
		{
			document.getElementById('div_losmas').innerHTML='<div align="center"><img src="http://www.fmimpacto107.com.ar/opinion/anim.gif"></div>';
		}

	 }	  
	
}

function ocultar_losmas(){
	var fx = new Fx.Slide('div_losmas', {mode:'horizontal'});
	fx.toggle();
	setTimeout('cargar_losmas()', 500);
}








