function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
function Ir_a_Buscador()
{
	document.buscador.buscador10.value='bGoogle';	
	var palabra = document.buscador.buscador1.value;
	if(palabra=="" || palabra=="Buscador")
	{	literalNoSeleccion = unescape("Introduzca una cadena de b%FAsqueda");
		alert( literalNoSeleccion );
	} 
	else { 
		document.buscador.buscador1.value = trim(palabra);
		//variable urlBuscador proviene de la pŠna cabecera.jsp		
		document.buscador.action = urlBuscador;		
		document.buscador.submit(); 
	}
}


var indTop = 1;///Indice control boton subir
function openWin(qURL,w,h,l,t)
{	
	wWidth = "width="+w;
	hHeight = ",height="+h;
	lLeft = ",left="+l;
	tTop = ",top="+t;
	 rResizable = ",resizable=yes";     
	parameters = wWidth+hHeight+lLeft+tTop + rResizable + ",scrollbars=yes";
	ventana = window.open(qURL,"_blank",parameters);
	ventana.focus();
}

function irAccesoDirecto()
{	enlace = document.fAccesosDirectos.accesoDirect.options[document.fAccesosDirectos.accesoDirect.selectedIndex].value;
	if (enlace=="0")
	{	// variable literalNoSeleccion proviene de la pŠna accesosDirectos.jsp
		alert( literalNoSeleccionAccesos );
	} else {
		if (enlace.indexOf("www")!= -1){
			var windowWidth = (document.all)?screen.width:window.innerWidth;
            var windowHeight = (document.all)?(screen.height):window.innerHeight
            if (windowWidth > 800)
            {           distMaxWidth = (document.all)?1004:1024;
                        distMaxHeight = (document.all)?(768-altHeight):593;
            }
            wWidth = "width="+distMaxWidth;
            hHeight = ",height="+distMaxHeight;
            lLeft = ",left="+0;
            tTop = ",top="+0;
            mMenubar = ",menubar=yes";
            lLocation = ",location=yes";
            lLocationBar = ",locationbar=yes";
            tToolbar = ",toolbar=yes";
            sStatusbar = ",status=yes";
            sScrollbars = ",scrollbars=yes";
            pPersonalbar = ",personalbar=yes";
            rResizable = ",resizable=yes";     
            parameters = wWidth+hHeight+lLeft+tTop
            parameters += mMenubar+lLocation+lLocationBar+tToolbar+sStatusbar+sScrollbars+pPersonalbar+rResizable;
            ventana = window.open(enlace,'madridorg',parameters);
		}
		else{
			window.parent.location.href = enlace;
		}
	}
}
	
var altHeight = 200;
function resize(url,target){
       var windowWidth = (document.all)?screen.width:window.innerWidth;
       var windowHeight = (document.all)?(screen.height):window.innerHeight
       if (windowWidth > 800)
       {           distMaxWidth = (document.all)?1004:1024;
                   distMaxHeight = (document.all)?(768-altHeight):593;
       }
       wWidth = "width="+distMaxWidth;
       hHeight = ",height="+distMaxHeight;
       lLeft = ",left="+0;
       tTop = ",top="+0;
       mMenubar = ",menubar=yes";
       lLocation = ",location=yes";
       lLocationBar = ",locationbar=yes";
       tToolbar = ",toolbar=yes";
       sStatusbar = ",status=yes";
       sScrollbars = ",scrollbars=yes";
       pPersonalbar = ",personalbar=yes";
       rResizable = ",resizable=yes";     
       parameters = wWidth+hHeight+lLeft+tTop
       parameters += mMenubar+lLocation+lLocationBar+tToolbar+sStatusbar+sScrollbars+pPersonalbar+rResizable;
       ventana = window.open(url,target,parameters);
}

var ICajaOro = new Image(); 
var ICajaRoja = new Image();

function cambio_caja_roja()
{   
	txtCajaRoja = '<DIV class="caja_oro2">';
	if (aCajaRoja[cont_rojo][1]!="null"){
		/*txtCajaRoja += '<a href="'+aCajaRoja[cont_rojo][1]+'"';
		if (aCajaRoja[cont_rojo][0]!="true"){
			txtCajaRoja += ' target="_blank">';
		}else{
			txtCajaRoja += '>';
		}*/		
		if (aCajaRoja[cont_rojo][0]=="false"){
			txtCajaRoja += '<a href="'+aCajaRoja[cont_rojo][1]+'" target="_blank">';
		}
		else if (aCajaRoja[cont_rojo][0]=="falseIntermedia"){
			txtCajaRoja += '<a href="#" onclick="javascript:openWin(\''+aCajaRoja[cont_rojo][1]+'\',685,600,50,50);return false;">';
		}
		else{
			txtCajaRoja += '<a href="'+aCajaRoja[cont_rojo][1]+'">';
		}		
		
	}
	txtCajaRoja += '<IMG alt="'+aCajaRoja[cont_rojo][3]+'" title="'+aCajaRoja[cont_rojo][3]+'" src="'+aCajaRoja[cont_rojo][2]+'" width="477" height="188"/>';
	if (aCajaRoja[cont_rojo][1]!="null"){
		txtCajaRoja += '</a>';
	}
	txtCajaRoja += '</DIV>';
	document.getElementById("caja_roja").innerHTML = txtCajaRoja;	
	setTimeout("cambio_caja_roja()",aCajaRoja[cont_rojo][4]);
	if (cont_rojo == num_caja_roja) { 
		cont_rojo = 1; 
	} else { 
		cont_rojo++; 
	}
	ICajaRoja.src = aCajaRoja[cont_rojo][2];	
	
}	
	
function cambio_caja_oro()
{	txtCajaOro = '<DIV class="caja_oro2">';
	if (aCajaOro[cont_oro][1]!="null"){
		//txtCajaOro += '<a href="'+aCajaOro[cont_oro][1]+'"';
		if (aCajaOro[cont_oro][0]=="false"){
			txtCajaOro += '<a href="'+aCajaOro[cont_oro][1]+'" target="_blank">';
		}
		else if (aCajaOro[cont_oro][0]=="falseIntermedia"){
			txtCajaOro += '<a href="#" onclick="javascript:openWin(\''+aCajaOro[cont_oro][1]+'\',685,600,50,50);return false;">';
		}
		else{
			txtCajaOro += '<a href="'+aCajaOro[cont_oro][1]+'">';
		}
	}
	txtCajaOro += '<IMG alt="'+aCajaOro[cont_oro][3]+'" title="'+aCajaOro[cont_oro][3]+'" src="'+aCajaOro[cont_oro][2]+'" width="263" height="92"/>';
	if (aCajaOro[cont_oro][1]!="null"){
		txtCajaOro += '</a>';
	}
	txtCajaOro += '</DIV>';
	document.getElementById("caja_oro").innerHTML = txtCajaOro;
	setTimeout("cambio_caja_oro()",aCajaOro[cont_oro][4]);
	if (cont_oro == num_caja_oro) { 
			cont_oro = 1; 
	} else { 
			cont_oro++; 
	}
	ICajaOro.src = aCajaOro[cont_oro][2]; 
}

function AbrirConsejeria()
{	enlace = document.fConsejerias.accesoDirect.options[document.fConsejerias.accesoDirect.selectedIndex].value;
	if(enlace=="0")
	{	
		alert( literalNoSeleccion2 );
	}
	else
	{	window.parent.location.href = enlace; }
}

function rs_click(rs_click_cid,rs_click_url,rs_click_dest)
{
	rs_pixel = new Image();
	strCURL = window.document.location.toString();
	intLen = rs_click_url.indexOf('filename');
	rs_click_url = rs_click_url.substring(intLen);
	rs_click_url = strCURL+"&"+rs_click_url;	
	rs_pixel.src = "http://secure-uk.imrworldwide.com/cgi-bin/m?cid="+rs_click_cid+"&url="+rs_click_url;
}
function enlacePaginaIntermedia (enlace){
	window.parent.location.href = enlace;
}
function etiquetasFlash (enlace, identificador, codebaseflash, widthflash, heightflash){
	document.write('<object classid="' + identificador + '" c="' + codebaseflash + '" width="' + widthflash + '" height="' + heightflash + '">\n');
    document.write('<param name="movie" value="' + enlace + '"/>\n');
	document.write('<param name="quality" value="high"/>\n');
	document.write('<param name="bgcolor" value="#FFFFFF"/>\n');
	document.write('<param name="allowScriptAccess" value="sameDomain"/>\n');
	document.write('<embed src="' + enlace + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + widthflash + '" height="' + heightflash + '"></embed>\n');
    document.write('</object>\n');	
}

function validarBuscador(formulario){
  var palabra = document.buscador.buscador1.value;
  document.buscador.buscador10.value='bGoogle';	
  if(palabra=="" || palabra=="Buscador"){ 
    literalNoSeleccion = unescape("Introduzca una cadena de b%FAsqueda");
    
    alert(literalNoSeleccion);
    
    return false;
  } 
}
	function imprimirGrafico(parametros)
	{	var LaUrl = "Satellite?pagename=ComunidadMadrid/Page/grafico_Consejeria";
		LaUrl = LaUrl+"&"+ parametros;
		var properties = "left=100,top=100,width=667,height=400,scrollbars=yes,resizable=yes";
		window.open (LaUrl, "winInfo", properties);
	}
	function fichaConsejeria(parametros, elto)
	{	var LaUrl = "Satellite?pagename=" + elto;
		LaUrl = LaUrl+"&"+ parametros;		
		var properties = "left=100,top=100,width=610,height=614,scrollbars=yes,resizable=yes";
		window.open (LaUrl, "winInfo", properties);
	}	
	var dHeader = "titPrint";
	var dBody = "bodyPrint";
	


function VaciarBuscador(buscador)
{
 var palabra = document.buscador.buscador1.value;
 if(palabra=="Buscador"){ 
 
	buscador.value = "";
 }	
}	