/*Animar hacia Abajo*/
function doheightChangeMem(elem,startheight,endheight,steps,intervals,powr) { 
    if (elem.heightChangeMemInt)
	window.clearInterval(elem.heightChangeMemInt);
    var actStep = 0;
    elem.heightChangeMemInt = window.setInterval(
	function() { 
	  elem.currentheight = easeInOut(startheight,endheight,steps,actStep,powr);
	  elem.style.height = elem.currentheight + "px"; 
	  actStep++;
	  if (actStep > steps) window.clearInterval(elem.heightChangeMemInt);
	} 
	,intervals);
}
/*Amplia y Reduce*/
function heightChange(altura,iframe_ident) { 
    if (!this.currentheight) this.currentheight = 25; 
	//if no memory is set, set it first;
    doheightChangeMem(document.getElementById(iframe_ident),this.currentheight,altura,10,10,0.5);
    } 
function heightRestore(iframe_ident) { 
    if (!this.currentheight) return; 
    doheightChangeMem(document.getElementById(iframe_ident),this.currentheight,0,10,10,0.5);
    }

function heightChangeFromChild(altura,iframe_ident) { 
	//if no memory is set, set it first;
	var alturaFinal = Number(document.getElementById(iframe_ident).currentheight)+Number(altura);
    doheightChangeMem(document.getElementById(iframe_ident),document.getElementById(iframe_ident).currentheight,alturaFinal,10,10,0);
    } 
	
function heightRestoreFromChild(altura,iframe_ident) { 
	//if no memory is set, set it first;
	
	var alturaFinal = Number(document.getElementById(iframe_ident).currentheight)-Number(altura);

    doheightChangeMem(document.getElementById(iframe_ident),document.getElementById(iframe_ident).currentheight,alturaFinal,10,10,0);
    } 

/* Easing */
function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) { 
//Generic Animation Step Value Generator By www.hesido.com 
    var delta = maxValue - minValue; 
    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
    return Math.ceil(stepp)
    } 

/*Setts The iframe Data status to OPEN or CLOSE*/

var iframe_open=false;


function servicios_open() {
	if (iframe_open==false){
		heightChange("355","contenido_servicios");
		iframe_open=true;
		document.getElementById("contenido_servicios").style.display="block";
	} else {
	}
}
function servicios_close() {
	heightRestore("contenido_servicios");
	document.getElementById("contenido_servicios").style.display="none";
	document.frames['servicios_content'].location.href='blank.php';
	iframe_open=false;
}

function abrir_expandible(height,id,linkid){
	heightChange(height,id);
	document.getElementById(linkid).className='entidad_expanded';
	document.getElementById(id).className='explandible_extendido';
	document.getElementById('stretch').style.height='100%';
	document.getElementById(linkid).onclick=function(){
		cerrar_expandible(height,id,linkid);
	}; 
}
function cerrar_expandible(height,id,linkid) {
	heightRestore(id);
	document.getElementById(linkid).className='entidad';
	document.getElementById(id).className='explandible';
	document.getElementById(linkid).onclick=function(){
		abrir_expandible(height,id,linkid);
	}; 
}
/*Enxpande y contrae INTERNO */

function abrir_historico(height,id,linkid,parent_id){
	heightChange(height,id);

	document.getElementById(linkid).className='historico_icon_expanded';
	document.getElementById(id).className='historico_expanded';
		parent.heightChangeFromChild(height,parent_id);	
	document.getElementById(linkid).onclick=function(){
		cerrar_historico(height,id,linkid,parent_id);
	};
}
function cerrar_historico(height,id,linkid,parent_id) {
	heightRestore(id);
	document.getElementById(linkid).className='historico_icon';
	document.getElementById(id).className='historico_unexpanded';
	
			parent.heightRestoreFromChild(height,parent_id);
			
	document.getElementById(linkid).onclick=function(){
		abrir_historico(height,id,linkid,parent_id);
	}; 
}

/* --------- MAP LINKS --------- */

/* GUATEMALA */
function GoGuatemala() {
	location.href='noticias.php?id_pais=5&id_sector=1';
	};

/* El SALVADOR */

function GoSalvador(){
	location.href='noticias.php?id_pais=3&id_sector=1';
	};

/* BELIZE */
function GoBelize(){
	location.href='noticias.php?id_pais=4&id_sector=1';
	};

/* HONDURAS */
function GoHonduras(){
	location.href='noticias.php?id_pais=8&id_sector=1';
	};

/* NICARAGUA */
function GoNicaragua(){
	location.href='noticias.php?id_pais=6&id_sector=1';
	};
	
/* COSTARICA */
function GoCostaRica(){
	location.href='noticias.php?id_pais=2&id_sector=1';
	};
	
/* PANAMA */
function GoPanama(){
	location.href='noticias.php?id_pais=7&id_sector=1';
	};

/* R DOMINICANA */
function GoRepublicaDominicana(){
	location.href='noticias.php?id_pais=9&id_sector=1';
	};

/* itsmo */
function GoItsmo(){
	location.href='index.php';
	};


/* ------ POP UP MENU ------ */
function show_pop_menu(popup_id) {
	document.getElementById(popup_id).style.display='block';
}
function hide_pop_menu(popup_id) {
	document.getElementById(popup_id).style.display='none';
}


function OpenPopup(url, winname,w,h){
	openCenteredWindow(url,winname,w,h,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=yes,resizable=no');
}
function openCenteredWindow(mypage,myname,w,h,features) {
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{winl = 0;wint =0;}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}

/* POP UPS de ESCALAS */
function OpenPopupScrollBars(url, winname,w,h){
	openCenteredWindow(url,winname,w,h,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes');
}

/*POP UPS de BIBLIOTECA */
function LaunchBibliotecaPopup($StringFilter){
	OpenPopup('biblioteca_popup.php?searchstring='+$StringFilter,'biblioteca',621,441);
}
function LaunchEscalasPopup($StringFilter){
	OpenPopupScrollBars('escalas_popup.php?'+$StringFilter,'escalas',621,421);
}
/*POP UPS de Registro */
function LaunchRegistroPopup(){
	OpenPopup('lists/?p=subscribe&id=2','registrese',400,380);
}
