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.megalatinafm.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('btn_enviar').value="Enviando..";

	

	var id_nota=document.getElementById('id_nota').value;



	peticion.open("POST","http://www.megalatinafm.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) {

   	  alert("Gracias por su comentario. Será publicado a la brevedad");
     document.getElementById('nombre').value=""
	 document.getElementById('mail').value=""
	 document.getElementById('comentario').value=""
	 
	 document.getElementById('btn_enviar').disabled=false;
	 document.getElementById('btn_enviar').value="Enviar"
	 
		
	
		}

	}

}



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 losmas(n){
	var url="http://www.megalatinafm.com.ar/losmas.php?tipo="
	var nocache=parseInt(Math.random()*99999999);

	peticion.open("GET", url + n + "&nocache=" + nocache,true);
	peticion.onreadystatechange = respuestaAjaxLosmas;
	peticion.send(null);
		
		}


function respuestaAjaxLosmas(){
	 if (peticion.readyState == 4) {
     if(peticion.status == 200) {
	 	var resultado = peticion.responseText;
	     document.getElementById('div_losmas').innerHTML=resultado;
		
		}

	}
else
{
	document.getElementById('div_losmas').innerHTML='<img src="http://www.megalatinafm.com.ar/opinion/anim.gif" align="middle" />';	
}

}


// FUNCION PARA CAMBIAR PESTAÑAS DE SERVIOS
function cambiar(id){
var no=2;
var url="http://www.megalatinafm.com.ar/clima/index.php"
var nocache=parseInt(Math.random()*99999999);
if (id==2){
no=1;
url="http://www.megalatinafm.com.ar/horoscopo/index.php"
}
	document.getElementById(id).className='tit-bloques2-activo';
	document.getElementById(no).className='tit-bloques2-no';

	peticion.open("GET", url, true);
	peticion.onreadystatechange = respuestaServicios;
	peticion.send(null);
		
		}


function respuestaServicios(){
	 if (peticion.readyState == 4) {
     if(peticion.status == 200) {
	 	var resultado = peticion.responseText;
	     document.getElementById('servicios').innerHTML=resultado;
		
		}

	}
else
{
	document.getElementById('servicios').innerHTML='<img src="http://www.megalatinafm.com.ar/opinion/anim.gif" align="middle" />';	
}	

}




//CARGA Y EJECUTA FUNCIONES AL INICIO
function primero(){
var nocache=parseInt(Math.random()*9999);
var url ="/opinion/opinion_ajax.php?p=1";
peticion_opi.open("GET", url + "&rand=" + nocache, true);
peticion_opi.onreadystatechange = respuesta_ajax;
peticion_opi.send(null);
cambiar(1);

}


//FUNCIONES PARA CAMBIAR LAS OPINIONES

function sig(){
var u = document.getElementById("u").value;
var nocache=parseInt(Math.random()*9999);
var n = document.getElementById("n").value;
if (u==n){
alert ("NO EXISTEN MAS OPINIONES");
return;
}

var url="/opinion/opinion_ajax.php?p=2&id=" + n;
peticion_opi.open("GET", url + "&rand=" + nocache, true);
peticion_opi.onreadystatechange = respuesta_ajax;
peticion_opi.send(null);

}
function ant(){
var nocache=parseInt(Math.random()*9999);
var n = document.getElementById("n").value;
var pri = document.getElementById("pri").value;

if (pri==n){
alert ("NO EXISTEN MAS OPINIONES");
return;
}

var url="/opinion/opinion_ajax.php?p=3&id=" + n;
peticion_opi.open("GET", url + "&rand=" + nocache, true);
peticion_opi.onreadystatechange = respuesta_ajax;
peticion_opi.send(null);

}

function respuesta_ajax(){
 if (peticion_opi.readyState == 4) {
    if(peticion_opi.status == 200) {
    var resultado = peticion_opi.responseText;
      document.getElementById('div-opinion').innerHTML = resultado;
      }
	 }	  
 else
  {
 document.getElementById('div-opinion').innerHTML = '<div align="center"><img src="/opinion/anim.gif"></div>';
	  }
}


