/**
 * MARTA Y CARLOS
 * Script creado para poner la accesibilidad de las teclas, hay que incluirlo en el fihcero i_header.asp
 */

/* CARLOS Y MARTA: Para cambiar el tamano de la fuente del contenido de las noticias, A A A  */

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Patrick Hunlock | http://www.hunlock.com */

function getCSSRule(ruleName, deleteFlag) {               // Return requested style obejct
  if (document.styleSheets) {                             // If browser can play with stylesheets
    for (var i=0; i<document.styleSheets.length; i++) {   // For each stylesheet
      var styleSheet=document.styleSheets[i];             // Get the current Stylesheet
      var ii=0;                                           // Initialize subCounter.
      var cssRule=false;                                  // Initialize cssRule. 
      do {                                                // For each rule in stylesheet
        if (styleSheet.cssRules) {                        // Browser uses cssRules?
          cssRule = styleSheet.cssRules[ii];              // Yes -- Mozilla Style
        } else {                                          // Browser usses rules?
          cssRule = styleSheet.rules[ii];                 // Yes IE style. 
        }                                                 // End IE check.
        if (cssRule)  {                                   // If we found a rule...
          if (cssRule.selectorText==ruleName) {           // Does current rule match ruleName?
            if (deleteFlag=='delete') {                   // Yes.  Are we deleteing?
              if (styleSheet.cssRules) {                  // Yes, deleting...
                styleSheet.deleteRule(ii);                // Delete rule, Moz Style
              } else {                                    // Still deleting.
                styleSheet.removeRule(ii);                // Delete rule IE style.
              }                                           // End IE check.
              return true;                                // return true, class deleted.
            } else {                                      // found and not deleting.
              return cssRule;                             // return the style object.
            }                                             // End delete Check
          }                                               // End found rule name
        }                                                 // end found cssRule
        ii++;                                             // Increment sub-counter
      } while (cssRule)                                   // end While loop
    }                                                     // end For loop
  }                                                       // end styleSheet ability check
  return false;                                           // we found NOTHING!
}                                                         // end getCSSRule 

function killCSSRule(ruleName) {                          // Delete a CSS rule   
  return getCSSRule(ruleName,'delete');                   // just call getCSSRule w/delete flag.
}                                                         // end killCSSRule

function addCSSRule(ruleName) {                           // Create a new css rule
  if (document.styleSheets) {                             // Can browser do styleSheets?
    if (!getCSSRule(ruleName)) {                          // if rule doesn't exist...
      if (document.styleSheets[0].addRule) {              // Browser is IE?
        document.styleSheets[0].addRule(ruleName, null,0);      // Yes, add IE style
      } else {                                            // Browser is IE?
        document.styleSheets[0].insertRule(ruleName+' { }', 0); // Yes, add Moz style.
      }                                                   // End browser check
    }                                                     // End already exist check.
  }                                                       // End browser ability check.
  return getCSSRule(ruleName);                            // return rule we just created.
} 




	navegador = navigator.appName;
	versionNav = parseInt(navigator.appVersion);


	/* CARLOS Y MARTA: Función que se llama para hacer el cambio del tamano.
	Lineas 1591 y 2004 de content.asp
	*/
	function cambio_tamano_accesible(tamano) {
		if (versionNav>=4) {
			if (navegador=="Netscape") {
			
				var global = getCSSRule('.ContentTable div');			
				global.style.fontSize=tamano + "px"; 
				global.style.lineHeight=tamano + "pt"; 
				
				var global1 = getCSSRule('.ContentTable p');			
				global1.style.fontSize=tamano + "px"; 
				global1.style.lineHeight=tamano + "pt"; 
				
				var global2 = getCSSRule('.HeaderTitle');			
				global2.style.fontSize=tamano + "px";  
				
			} 
			else if (navegador.indexOf('Explorer') != -1) {			
				document.styleSheets["estilo_portal_css"].addRule(".ContentTable div", "font-size:" + tamano + "px");  
				document.styleSheets["estilo_portal_css"].addRule(".ContentTable div", "line-height:" + tamano + "pt");  
				
				document.styleSheets["estilo_portal_css"].addRule(".ContentTable p", "font-size:" + tamano + "px");  
				document.styleSheets["estilo_portal_css"].addRule(".ContentTable p", "line-height:" + tamano + "pt"); 
				
				document.styleSheets["estilo_portal_css"].addRule(".HeaderTitle", "font-size:" + tamano + "px");  
	 
			}
		}
	}
	
	
	/* CARLOS Y MARTA: Función que se llama para hacer el cambio del tamano.
	Lineas 1591 y 2004 de content.asp
	*/
	
	function contraste_alto(etiqueta, color_fondo, color_texto) {
		todosLosParrafos = document.getElementsByTagName(etiqueta);
		for (i=0; i < todosLosParrafos.length; i++ ) {
		  //  hacer aquí nuestro procesamiento, usando
		  //  "todosLosParrafos[i]" para referenciar
		  //  el elemento actual de la colección.
		  //alert( "Este es el parrafo " + i + "!" );
		  document.getElementsByTagName(etiqueta).item(i).style.color = color_texto
		  document.getElementsByTagName(etiqueta).item(i).style.background = color_fondo	  
		}	
	}
		
	function cambio_contraste() {
				
		cookie_alto=getCookie("cok_alto_cont");
		if (cookie_alto!=null && cookie_alto!="") {
			// coger_valor 
			valor_cok = getCookie("cok_alto_cont")
			if (valor_cok == "SI") {
				setCookie("cok_alto_cont","NO",365);
				
			/*	contraste_alto("div", "", "")
				contraste_alto("p",  "", "")
				contraste_alto("td", "", "")
				contraste_alto("a", "", "")
				contraste_alto("font", "", "")
				contraste_alto("hr", "", "")
				contraste_alto("body", "", "")
				contraste_alto("ul", "", "")
				contraste_alto("li", "", "") */
				
				window.location.href=window.location.href;
			}
			else {
				setCookie("cok_alto_cont","SI",365);
				contraste_alto("div", "#000000", "#FFFFFF")
				contraste_alto("p", "#000000", "#FFFFFF")
				contraste_alto("td", "#000000", "#FFFFFF")
				contraste_alto("a", "#000000", "#FFFFFF")
				contraste_alto("font", "#000000", "#FFFFFF")
				contraste_alto("hr", "#000000", "#FFFFFF")
				contraste_alto("body", "#000000", "#FFFFFF")
				contraste_alto("ul", "#000000", "#FFFFFF")
				contraste_alto("li", "#000000", "#FFFFFF")
				
				document.getElementById("img_cabecera_sup_portal").src = "cabeceras/Cabecera-Superior_negra.jpg"
				document.getElementById("img_menu").src = "banners/banner_izq/menu_negro.jpg"
				document.getElementById("img_pie").src = "styles/pm/images/pie-nav_negro.jpg"
			}
		}
		else  {
			setCookie("cok_alto_cont","SI",365);
			
			contraste_alto("div", "#000000", "#FFFFFF")
			contraste_alto("p", "#000000", "#FFFFFF")
			contraste_alto("td", "#000000", "#FFFFFF")
			contraste_alto("a", "#000000", "#FFFFFF")
			contraste_alto("font", "#000000", "#FFFFFF")
			contraste_alto("hr", "#000000", "#FFFFFF")
			contraste_alto("body", "#000000", "#FFFFFF")
			contraste_alto("ul", "#000000", "#FFFFFF")
			contraste_alto("li", "#000000", "#FFFFFF")
			
			document.getElementById("img_cabecera_sup_portal").src = "cabeceras/Cabecera-Superior_negra.jpg"
			document.getElementById("img_menu").src = "banners/banner_izq/menu_negro.jpg"
			document.getElementById("img_pie").src = "styles/pm/images/pie-nav_negro.jpg"
		}
				
	}
	
	
	function consulta_cambio_contraste() {
		cookie_alto=getCookie("cok_alto_cont");
	//	alert("cc" + cookie_alto)
		if (cookie_alto!=null && cookie_alto!="") {
			// coger_valor 
			valor_cok = getCookie("cok_alto_cont")
			if (valor_cok == "SI") {				
				contraste_alto("div", "#000000", "#FFFFFF")
				contraste_alto("p", "#000000", "#FFFFFF")
				contraste_alto("td", "#000000", "#FFFFFF")
				contraste_alto("a", "#000000", "#FFFFFF")
				contraste_alto("font", "#000000", "#FFFFFF")
				contraste_alto("hr", "#000000", "#FFFFFF")
				contraste_alto("body", "#000000", "#FFFFFF")
				contraste_alto("ul", "#000000", "#FFFFFF")
				contraste_alto("li", "#000000", "#FFFFFF")
				
				document.getElementById("img_cabecera_sup_portal").src = "cabeceras/Cabecera-Superior_negra.jpg"
				document.getElementById("img_menu").src = "banners/banner_izq/menu_negro.jpg"
				document.getElementById("img_pie").src = "styles/pm/images/pie-nav_negro.jpg"
			}
		}
		
	}
	
	
	/** CARLOS Y MARTA: Manejo de COOKIES */
	
	function setCookie(c_name,value,exdays) {
		var exdate=new Date();
		exdate.setDate(exdate.getDate() + exdays);
		var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
		document.cookie=c_name + "=" + c_value;
	}
	
	function getCookie(c_name)	{
		var i,x,y,ARRcookies=document.cookie.split(";");

		for (i=0;i<ARRcookies.length;i++) 	{
			x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
			y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
			x=x.replace(/^\s+|\s+$/g,"");
			if (x==c_name)	{
				return unescape(y);
			}
		}
	}
	
	
