function $(idObject){
    return document.getElementById(idObject);
  }

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function trim(valor){
	var re = /^(\s)*|(\s)*$/;
	var str = (valor ? valor : this);
	return str.replace(re,'');
}
String.prototype.trim = trim;

function checkLetras(){
  document.getElementById('texto').value = document.getElementById('texto').value.trim();
  if (document.getElementById('texto').value.length < 3) {
  	alert("Ingrese por favor al menos 3 letras.");
    return false;
  }
  return true;
}

function Radio10enVivo() {
      if (navigator.appName.indexOf("Microsoft")!=-1) {
      	window.open("../herramientas/radio10envivo.php","radio10envivo","width=320,height=335,top=50,left=50");
      }
      else {
      	window.location = "mms://200.43.193.143/radio10";
      }
}

function Mega983enVivo() {
	window.open("../herramientas/mega983envivo.php","mega983envivo","width=320,height=235,top=50,left=50");
}

function RadioPopenVivo() {
  if (navigator.appName.indexOf("Microsoft")!=-1) {
  	window.open("../herramientas/radiopopenvivo.php","radiopopenvivo","width=320,height=335,top=50,left=50");
  }
  else {
  	window.location = "http://pop.telecomdatacenter.com.ar/pop";
  }
}

function RadioVale() {
  window.open("../herramientas/radiovaleenvivo.php","radiovaleenvivo","width=320,height=335,top=50,left=50");

}

function RadioTkm() {
	window.open("http://www.mundotkm.com/radiotkm/player/radiotkm.php","amadeusenvivo","width=320,height=235,top=50,left=50");
}

function Canal9enVivo() {
  window.open("../canal9/tv/ubicaciones.php?calidad=1","Canal9EnVivo","width=280,height=205,top=201,left=322");
}


function ingresasPOP( url  , url_redirectto  )
{
  url_redirectto = (typeof(url_redirectto) != "undefined")  ? url_redirectto : "" ;
  window.open("../interior/login_pop.php?returnto=" + url + "&redirectto=" + url_redirectto,"Ingresar","width=380, height=400, scrollbars=no");

}


function noticiasfotoPopUp(idxNota, idxSeccion, opcion, layout) {
    window.location = '../interior/fotos.php?idxNota=' + idxNota + '&idxSeccion=' + idxSeccion + '&opcion=' + opcion + '&layout=' + layout;
}



function runSWF(archivo, ancho, alto, version, bgcolor, id,idm, menu, FlashVars, quality, allowScriptAccess , wmode) {
if(version!=""){
	var version_data=version;
}else{
	var version_data="6,0,0,0";
}
if(menu!=""){
	menu_data=menu;
}else{
	menu_data=false;
}
if(bgcolor!=""){
	var bgcolor_data=bgcolor;
}else{
	var bgcolor_data="#FFFFFF";
}
if(id!=""){
	id_data=id;
}else{
	id_data="flashMovie";
}
if(quality!=""){
	quality_data=quality;
}else{
	quality_data="high";
}
if(allowScriptAccess!=""){
	allowScriptAccess_data=allowScriptAccess;
}else{
	allowScriptAccess_data="always";
}
var quality="high"; // calidad de visualización de la peli

if(typeof(wmode)!="undefined"){
	wmode_data=wmode;
}else{
	wmode_data="transparent";
}


var agt=navigator.userAgent.toLowerCase();
  if((navigator.appName == "Microsoft Internet Explorer") ||
  ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1)))
  {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
    document.write('<param name="movie" value='+archivo+'>\n');
    document.write('<param name="allowScriptAccess" value='+allowScriptAccess_data+'>\n');
    document.write('<param name="quality" value='+quality_data+'>\n');
    document.write('<param name="wmode" value='+wmode_data+'>\n');
    //document.write('<param name="FlashVars" value='+FlashVars+'>\n');
    document.write('<param name="bgcolor" value='+bgcolor_data+'>\n');
    //document.write('<param name="menu" value='+menu_data+' >\n');
    document.write('<param name="allowFullScreen" value=true >\n');
    //FlashVars='+FlashVars+' menu='+menu_data+' swLiveConnect=true
    document.write('</object>\n');
  }
  else
  {
    document.write('<embed src='+archivo+' bgcolor='+bgcolor_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' id='+idm+' wmode='+wmode_data+' allowFullScreen=true></embed>');
  }
}

function Votar(idx,cantidad) {
	var check = false;
	for (i=0;i<cantidad;i++) {
		if (document.frmPrincipal.rEncuesta[i].checked) {
			window.open("../herramientas/check_cookies.php?IdxEncuesta="+idx+"&IdxOpcion="+document.frmPrincipal.rEncuesta[i].value,"Votar","width=387,height=290,top=150,left=150");
			var check = true;
		}
	}
	if( check == false ) alert('Para votar debe seleccionar una opción');
}

/*
function popupGaleria(idGaleria, opcion, seccion , mostrarCombo) {
  window.location = '../interior/fotos.php?idSeccion='+seccion+'&idGaleria='+idGaleria+"&opcion="+opcion+"&mostrarCombo="+mostrarCombo;
}
*/
function popupGaleria(idGaleria, tipo, titulo) {
  window.location = '../imagenes/'+idGaleria+'-'+tipo+'-'+titulo;
}


function isMSIE()
{
	return (navigator.appName == "Microsoft Internet Explorer");
}

function isSafari()
{
	var agt=navigator.userAgent.toLowerCase();
	return ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;;
}

function IframeSetReloj(){
  document.write("<iframe style='display:none' src='../interior/setdatareloj.php'></iframe>");
}

function VotarColCentral(objeto,idx) {
	var check = false;
		if (document.getElementById(objeto).value!="") {
			window.open("../herramientas/check_cookies.php?IdxEncuesta="+idx+"&IdxOpcion="+objeto,"Votar","width=387,height=290,top=150,left=150");
			var check = true;
		}
	if( check == false ) alert('Para votar debe seleccionar una opción');
}


tamanio0=43;
tamanio1=14;
tamanio2=14;

function setTamFuente(nodo,tamanio)
{
	// nodo actual
	if(nodo && nodo.style)
	nodo.style.fontSize = tamanio;

	// tiene hijos?
	if(nodo.childNodes.length)
	{
		nodo = nodo.firstChild;

		// primer hijo
		if(nodo.style) nodo.style.fontSize = tamanio;
		setTamFuente(nodo,tamanio);

		// resto de los hijos
		while(nodo = nodo.nextSibling)
		{
			if(nodo.style) nodo.style.fontSize = tamanio;
			setTamFuente(nodo,tamanio);
		}
	}
}

function tamFuente(operacion)
{

    if (operacion == 0)
    {
      if (tamanio0 > 43) tamanio0=tamanio0 - 1;
      if (tamanio1 > 14) tamanio1=tamanio1 - 1;
      if (tamanio2 > 14) tamanio2=tamanio2 - 1;

    }
    else
    {
      if (tamanio0 < 50) tamanio0=tamanio0 + 1;
      if (tamanio1 < 20) tamanio1=tamanio1 + 1;
      if (tamanio2 < 20) tamanio2=tamanio2 + 1;
    }

  setTamFuente(document.getElementById('tituloNota'),tamanio0);
	setTamFuente(document.getElementById('copeteNota'),tamanio1);
	setTamFuente(document.getElementById('cuerpoNota'),tamanio2);

}


/* bloque el scroll de la pag. principal*/
function block() {
		document.body.scroll         = "no";
		document.body.style.overflow = "hidden";
	//document.body.appendChild(objBlock);
}


/* desbloque el scroll de la pag. principal*/
function unblock() {
		document.body.scroll = "yes";
		document.body.style.overflow = "auto";
}

function muestraPopUp(sUrl,overflow,showElement,zIndexElement)
{
	var overflow        = overflow      || "hidden" ;
  var showElement     = showElement   || "" ;
  var zIndexElement   = zIndexElement || 99999999;
	var objDivBackground;
	var objDivContenedor;
	var objIframe;
	var appendBackground  = false;
	var appendContenedor  = false;
	var appendIframe      = false;


	if( ! (objDivBackground = document.getElementById('divBackground')) ){
		objDivBackground	  = document.createElement('DIV');
		appendBackground = true;
	}

	objDivBackground.id 									 = "divBackground";
	objDivBackground.style.top 						 = "0px";
	objDivBackground.style.left 					 = "0px";
	objDivBackground.style.position 			 = "absolute";
	objDivBackground.style.backgroundColor = "#000000";
	objDivBackground.style.background 		 = "#000000"
	objDivBackground.style.filter 				 = "alpha (opacity=60);"; //ie
	objDivBackground.style.MozOpacity 		 = ".6";  //ff
	objDivBackground.style.opacity 		     = ".6";  //chrome
	objDivBackground.style.width 					 = "100%";
	objDivBackground.style.width 					 = document.body.offsetWidth+'px';
	objDivBackground.style.height 				 = document.body.offsetHeight+'px';
	objDivBackground.style.display         = "block";


	sUrl = sUrl.trim();
  if(sUrl.trim()){
	  if( !(objDivContenedor = document.getElementById('DivContenedor')) ){
      objDivContenedor 	= document.createElement('DIV');
      appendContenedor  = true;
	  }

    objDivContenedor.id 									 = "DivContenedor";
    objDivContenedor.style.backgroundColor = "#FFFFFF";
    objDivContenedor.style.border 				 = "0px none";
    objDivContenedor.style.position        = 'absolute';
    /*objDivContenedor.style.top	 					 = "80px";*/
    if(typeof(window.pageYOffset) != 'undefined') { //ff - chrome
      objDivContenedor.style.top             = window.pageYOffset+"px" || "80px";
    }else{
      objDivContenedor.style.top             = document.documentElement.scrollTop || "80px";
    }
    objDivContenedor.style.left 					 = "350px";
    objDivContenedor.style.width 					 = "520px";
    objDivContenedor.style.height 				 = "615px";
    objDivContenedor.style.overflow 			 = "hidden";
    objDivContenedor.style.display         = 'block';


    if( !(objIframe = document.getElementById('iFrameContenedor')) ){
      objIframe = document.createElement('IFRAME');
      appendIframe = true;
    }

  	objIframe.name 						= "iFrameContenedor";
  	objIframe.id	 						= "iFrameContenedor";
  	objIframe.src 						= sUrl
  	objIframe.width 					= "100%";
  	objIframe.height					= "100%";
  	objIframe.overflow 				= overflow;
  	objIframe.style.overflow 	= overflow;
  	objIframe.style.display   = 'block';
  	objIframe.style.position  = 'relative';
  	objIframe.border				  = "0";
  }

  if(appendBackground){
	  document.body.appendChild(objDivBackground);
	}


	if(sUrl && appendContenedor){
	  document.body.appendChild(objDivContenedor);
	}

	if(sUrl && appendIframe){
	  document.getElementById('DivContenedor').appendChild(objIframe);
	}

	if(!sUrl && showElement){
	  document.getElementById(showElement).style.display = "block";
	  document.getElementById(showElement).style.zIndex  = zIndexElement;
	}
  //block();
	//window.scrollBy(0,-1000);
}



function resizePopUp(width,height,centrar)
{
	if(typeof(window.pageYOffset) != 'undefined') { //ff - chrome
		var topFinal = window.pageYOffset || 0;
	}else { //ie
		var topFinal = document.documentElement.scrollTop || 0;
	}

  if(width > 420){
    document.getElementById('DivContenedor').style.left = 280+"px";
  }
  else{
    document.getElementById('DivContenedor').style.left = 380+"px";
  }

  if(centrar==1){
    window.document.getElementById('DivContenedor').style.top = topFinal+200+"px";
  }

	window.document.getElementById('DivContenedor').style.width = width+"px";
	window.document.getElementById('DivContenedor').style.height = height+"px";
}

function ocultaPopUp() {
	if(document.getElementById('divBackground')   ) { document.getElementById('divBackground').style.display = 'none';    }
	if(document.getElementById('DivContenedor')   ) { document.getElementById('DivContenedor').style.display = 'none';    }
	if(document.getElementById('iFrameContenedor')) { document.getElementById('iFrameContenedor').style.display = 'none'; }
	//unblock();
}


function ingresasPOP( url  , url_redirectto  )
{
  url_redirectto = (typeof(url_redirectto) != "undefined")  ? url_redirectto : "" ;
  muestraPopUp("../interior/login_pop.php?returnto=" + url + "&redirectto=" + url_redirectto);
}

function checkCaracteres( inputElement, cantidad ) {
	if( inputElement.value.length > cantidad ) {
		inputElement.value = inputElement.value.substr(0, cantidad);
	}
	document.frmPrincipal.lcomentario.value = inputElement.value.length;
}

function ingresasPOPComentario( url ){
	muestraPopUp("../interior/login_pop.php?submitTo=" + url);
}

function NombreUsuario(){
	return getCookie("InfobaeLogin[user]");
}
/*
function checkLoging(user){

  var user = user || NombreUsuario() ;
  if (user){
    //None
    if(document.getElementById('headerLogin')){
      document.getElementById('headerLogin').style.display = 'none';
      document.getElementById('headerRegistracion').style.display = 'none';
      //Block
      document.getElementById('headerPerfil').style.display = '';
      document.getElementById('headerLogout').style.display = '';
      document.getElementById('headerPerfil').innerHTML = user;
      if(document.getElementById('userLog')){
        document.getElementById('userLog').innerHTML = user;
      }
      //Clima
      document.getElementById('headerClima').style.marginLeft = '3px';
    }
  }else{
    if(document.getElementById('headerLogin')){
      //Block
      document.getElementById('headerLogin').style.display = '';
      document.getElementById('headerRegistracion').style.display = '';
      //None
      document.getElementById('headerPerfil').style.display = 'none';
      document.getElementById('headerLogout').style.display = 'none';
      //Clima
      document.getElementById('headerClima').style.marginLeft = '12px';
    }
  }

}
*/

var oldInfoSelected = null;
function viewInfoUser(value){
  document.getElementById(value).style.display = (document.getElementById(value).style.display == "") ? "none" : "";
  if(oldInfoSelected && oldInfoSelected != value){
    document.getElementById(oldInfoSelected).style.display = "none";
  }
  oldInfoSelected = value;
}

function VotarInterior(idx,cantidad, tipo){
	var check = false, frm;
	switch (tipo){
	  case 0: //encuesta desde columna central
	    frm = "frmEncuestaCentral";
	  break;
	  case 1: //encuesta desde columna derecha
	    frm = "frmEncuestaColRight";
	  break;
	  case 2: //encuesta desde interior
	    frm = "frmEncuesta";
	  break;
	}
	for (i=0;i<cantidad;i++){
		if (document.forms[frm].rEncuesta[i].checked == true ){
			window.open("../herramientas/check_cookies.php?IdxEncuesta="+idx+"&IdxOpcion="+document.forms[frm].rEncuesta[i].value+"&tipoEncuesta="+tipo,"Votar","width=387,height=290,top=150,left=150");
			var check = true;
		}
	}
	if( check == false ) alert('Para votar debe seleccionar una opción');
}

function checkCaracteres( inputElement, cantidad ) {
	if( inputElement.value.length > cantidad ) {
		inputElement.value = inputElement.value.substr(0, cantidad);
	}
	//document.frmPrincipal.lcomentario.value = inputElement.value.length;
}

function openWin(url){
	window.open('../interior/'+url,'privacidad','toolbars=no,scrollbars=yes,width=600,height=450');
}

function EncuestasResultados(idx) {
	document.frmEncuesta.IdxEncuesta.value = idx;
	document.frmEncuesta.submit();
}

function MostrarNota(idx,IdxSeccion) {
	document.frmNota.Idx.value = idx;
	document.frmNota.IdxSeccion.value = IdxSeccion;
	document.frmNota.submit();
}

function VotarComentario(votar,comentario){
  window.open("../herramientas/genera_clave_votoscomentarios.php?votar="+votar+"&comentario="+comentario,"Votar","width=387,height=290,top=150,left=150");
}


function consultaPadronElec(){
  var msg = "";
	var consulta = document.forms["consultaPadron"];
	var dni		= consulta.dni.value;
	var sexo	= consulta.sexo;
	if(dni == ""){
    msg ="Debe ingresar un DNI, LE o LC Válido! \n";
	}
	if(sexo[0].checked == false && sexo[1].checked == false){
	  msg +="Debe seleccionar el sexo! \n";
  }
/*
  if( !(/^\d{8}$/.test(dni)) ) {
    msg +="Debe ingresar 8 digitos! \n";
  }
*/
  if(msg != ""){
    alert(msg);
  }else{
  	if ( sexo[0].checked == true ){
  		sexo = 2;
  	} else {
  		sexo = 1;
  	}
    muestraPopUp('../interior/verdatos.php?matricula='+dni+'&sexo='+sexo);
  }
}

  function imprimir() {
		window.print();
	}


function checkLoging(user){
  var user = user || NombreUsuario() ;
  if (user){
    //None
    if(document.getElementById('headerLogin')){
      document.getElementById('headerLogin').style.display = 'none';
      document.getElementById('headerRegistracion').style.display = 'none';
    }
    if(document.getElementById('miinfo_login')){
      document.getElementById('miinfo_login').style.display = '';
      document.getElementById('userLog').innerHTML = user;
    }
  if(document.getElementById('iFrameDatosUsuario')){
    document.getElementById('iFrameDatosUsuario').src = "../interior/iFrameDatosUsuario.php";
  }
  }else{
    //block
    if(document.getElementById('headerLogin')){
      document.getElementById('headerLogin').style.display = '';
      document.getElementById('headerRegistracion').style.display = '';
    }
    if(document.getElementById('miinfo_login')){
      document.getElementById('miinfo_login').style.display = 'none';
      document.getElementById('userLog').innerHTML = "";
    }
  }
}


var oldRespondSelected = null;
function RespondUser(value){
  var height = 0;
  document.getElementById(value).style.display = (document.getElementById(value).style.display == "") ? "none" : "";
  if(oldRespondSelected && oldRespondSelected != value){
    document.getElementById(oldRespondSelected).style.display = "none";
  }
  oldRespondSelected = value;
  if ( document.getElementById("divComentarios") != null ) {
  	height = document.getElementById("divComentarios").offsetHeight;
  }

  if ( parent.document.getElementById("iFrameComentarios") != null ) {
  	parent.document.getElementById("iFrameComentarios").style.height = (parseInt(height) + parseInt(10)) + "px";
  }
}



var oldViewAnswersSelected = null;
var oldViewLink            = null;
var oldidC                 = null;
function ViewAnswers(value, idLink, idC){
  var height = 0;
  document.getElementById(value).style.display = (document.getElementById(value).style.display == "") ? "none" : "";
  if(document.getElementById('paginador_'+idC))
    document.getElementById('paginador_'+idC).style.display = (document.getElementById('paginador_'+idC).style.display == "none") ? "" : "none";
  document.getElementById('ver_resp_'+idLink).innerHTML = (document.getElementById(value).style.display == "none")? "Mostrar" : "Ocultar";
  document.getElementById('ver_img_'+idLink).src = (document.getElementById(value).style.display == "none")? "../img/ver-respuestas.gif" : "../img/ocultar-respuestas.gif";
  if(oldViewAnswersSelected && oldViewAnswersSelected != value){
    document.getElementById(oldViewAnswersSelected).style.display = "none";
    if(document.getElementById('paginador_'+oldidC))
      document.getElementById('paginador_'+oldidC).style.display = "none";
    document.getElementById('ver_resp_'+oldViewLink).innerHTML = "Mostrar";
    document.getElementById('ver_img_'+oldViewLink).src = "../img/ver-respuestas.gif";
  }
  oldidC = idC;
  oldViewLink = idLink;
  oldViewAnswersSelected = value;

  if ( document.getElementById("divComentarios") != null ) {
  	height = document.getElementById("divComentarios").offsetHeight;
  }

  if ( parent.document.getElementById("iFrameComentarios") != null ) {
  	parent.document.getElementById("iFrameComentarios").style.height = (parseInt(height) + parseInt(10)) + "px";
  }
}

function showAudio(idAudio)
{
	var div = document.getElementById('audio_'+idAudio);
	var img = document.getElementById('showaudio_'+idAudio);
	
	if ( img.src.indexOf('/btn2.gif') >= 0 )
	{
		div.style.display = 'block';
		img.src = '../img/btn.gif';
	}
	else
	{
		div.style.display = 'none';
		img.src = '../img/btn2.gif';
	}
}
