  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4555416-1']);
  _gaq.push(['_setDomainName', 'ine.cl']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_trackPageLoadTime']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


$(document).ready(function(){
	$("#menu").dropmenu({});
});





//Funciones para el Popup
//0 means disabled; 1 means enabled;  
var popupStatus = 0;  
var panelpopup = '';

//loading popup with jQuery magic!  
function loadPopup(panel){  
//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({  
		"opacity": "0.2"  
		});  
		$("#backgroundPopup").fadeIn("slow");  
		$(panel).fadeIn("slow");  
		popupStatus = 1;  
	}  
}  

//disabling popup with jQuery magic!  
function disablePopup(panel){  
//disables popup only if it is enabled  
	if(popupStatus==1){  
		$("#backgroundPopup").fadeOut("slow");  
		$(panel).fadeOut("slow");  
		popupStatus = 0;  
	}  
}  

//centering popup  
function centerPopup(panel){  
//request data for centering  
	var windowWidth = document.documentElement.clientWidth;  
	var windowHeight = document.documentElement.clientHeight;  
	var popupHeight = $(panel).height();   
	var popupWidth = $(panel).width();  
	//centering  
	$(panel).css({  
	"position": "fixed",  
	"top": (windowHeight/2)-(popupHeight/2),  
	"left": windowWidth/2-popupWidth/2  
	});  
	//only need force for IE6  
	$("#backgroundPopup").css({  
	"height": windowHeight  
	});  

}  


//CLOSING POPUP  
//Click the x event!  
$("#popupContactClose").click(function(){  
	disablePopup();  
});  



//Press Escape event!  
$(document).keypress(function(e){  
	if(e.keyCode==27 && popupStatus==1){  
		disablePopup(panelpopup);  
	}  
});   

function ShowPanel(panel, url)
{      
	panelpopup = panel;
	//centering with css  
	centerPopup(panel);  
	//load popup  
	loadPopup(panel); 
	$('#graficoIFrame').attr('src', url); 
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


function Click_Buscador(lang) {	
	if (lang == '') lang = 'esp';	
	var fecha = document.getElementById('RdFecha'); //parametro de busqueda
	var texto = document.getElementById('buscar'); //texto a buscar
	var opc='i';
	if (fecha.checked) opc = 'f';
	var URL_response = 'http://' + location.host + '/buscador.php?q=' + texto.value + '&opc=' + opc + '&lang=' + lang;
	//window.alert(URL_response);
	window.location = URL_response;
}


var min=8;
var max=18;
function increaseFontSize() {
	increase_array_FontSize(document.getElementsByTagName('p'));
	increase_array_FontSize(document.getElementsByTagName('h2'));
	increase_array_FontSize(document.getElementsByTagName('h3'));
	increase_array_FontSize(document.getElementsByClassName('texto'));
	increase_array_FontSize(document.getElementsByClassName('DetalleNoticia'));
}

function increase_array_FontSize(p) {
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize(){
	decrease_array_FontSize(document.getElementsByTagName('p'));
	decrease_array_FontSize(document.getElementsByTagName('h2'));
	decrease_array_FontSize(document.getElementsByTagName('h3'));
	decrease_array_FontSize(document.getElementsByClassName('texto'));	
	decrease_array_FontSize(document.getElementsByClassName('DetalleNoticia'));
}

function decrease_array_FontSize(p) {   
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

function Check_Idioma(ruta_actual) {	
	/*alert("hola");*/
	/*alert(ruta_actual.search(/_eng.php/i));*/
	if (ruta_actual.search(/_eng.php/i) >= 0 || ruta_actual.search(/lang=eng/i) >=0) {
		var ruta = ruta_actual.replace("_eng.php", ".php");
		ruta = ruta.replace("?lang=eng","");
		ruta = ruta.replace("lang=eng","");
		/*alert(ruta);*/
		window.location = ruta;
	}	
	else{		
		ruta_ingles = ruta_actual.replace(".php", "_eng.php");
		var car = "?";
		if (ruta_actual.search(/=/i) >= 0) {car = "&";}		
		$.ajax({
			url: ruta_ingles,
			type:'HEAD',
			error:
				function(){					
					var ruta = ruta_actual + car + "lang=eng";
					window.location = ruta.replace("&&", "&");
				},
			success:
				function(){
					window.location = ruta_ingles + car + "lang=eng";
				}
		});
	}
}

