
/*pone div con el nombre*/
function divNombre(ini) {
	document.write('<DIV id="');
  	if (ini == null){
  	document.write(document.title.substring(16,20));
  	//alert(document.title.substring(16,20));
  	}else{
  	document.write(document.title.substring(ini,ini+4));
  	//alert(document.title.substring(val,val+4));return;
  	}
	document.write('">');
}

/*marca el menu activo*/
function menuOn(ini) {
var miColor
if (parent.contenido.document.getElementById('sidebarLeft').currentStyle.backgroundColor =='#333333'){
miColor="#444";
}else{
miColor="#cde";
}
parent.contenido.document.getElementById('LProd').style.backgroundColor  ="";
parent.contenido.document.getElementById('LServ').style.backgroundColor  ="";
parent.contenido.document.getElementById('LNove').style.backgroundColor  ="";
parent.contenido.document.getElementById('Links5').style.backgroundColor  ="";
parent.contenido.document.getElementById('LNues').style.backgroundColor  ="";
parent.contenido.document.getElementById('LInfo').style.backgroundColor  ="";
parent.contenido.document.getElementById('LDise').style.backgroundColor  ="";
  	if (ini == null){
parent.contenido.document.getElementById('L'+document.title.substring(16,20)).style.backgroundColor  =miColor;
  	}else{
parent.contenido.document.getElementById('L'+document.title.substring(ini,ini+4)).style.backgroundColor  =miColor;
}
}


function poneVersion() {
	var currentValor = "2010.09.01";
	var str = currentValor.substring(0,3);
	var t_y = '(versión '+currentValor+'):';
	if (str != 'xxx') {
	document.write(t_y);
	}
}
//start colour picker
//setCookie("design", newtitle, 365, false); 
//para poner diseño 0=normal 1=oscuro

function estilos(web) {
/*setCookie("estilo", '2', 365, false); /*esto quitarlo*/
//setCookie("design", 1, 365, false); //quitar
var favorite =  getCookie( 'estilo' );
var miEstilo = '';
changeSheets(3);/*necesario para poner en disable los css*/
if (favorite != null) {
	changeSheets(favorite);
		if (web == 'w'){//es el caso web cargo las alturas de cajas para letra grande
		//alert(favorite);
		}
}
favorite =  getCookie( 'design' );
if (favorite != null) {
	if (favorite == 1) {//cambia a oscuro
	var t_y = '<link rel="stylesheet" href="';
	  	if (web == null){//si no pone nada es el caso informatica
  			t_y = t_y+'miestiloBlack.css';
  			//alert(t_y);
  		}else{
					if (web == 'w'){//es el caso web
					t_y = t_y+'miestiloBlackW.css';
					}
  		}
	t_y = t_y+'" type="text/css">';
	document.write(t_y);
	}
}
}
function estilos2F() {
var favorite =  getCookie( 'design' );
if (favorite != null) {
	if (favorite == 1) {//cambia a oscuro
	var t_y = '<link rel="stylesheet" href="miestiloBlackF.css" type="text/css">';
	document.write(t_y);
	}
}
}


function SetStyleSheet(newtitle) 
{
    setCookie("estilo", newtitle, 365, false);
	//window.location.reload()  esto funcionaba bien para recargar la pg que es otra forma de cambiar estilos
}
//end colour picker


function poneTit(t_e)
{
var t_y = '<DIV  CLASS="boxSombraie"><DIV  CLASS="boxSombra"><DIV  CLASS="sombra">'+t_e+'</DIV><DIV  CLASS="pisaSombra">'+t_e+'</DIV></DIV></DIV>';
document.write(t_y);
return;
}

function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  document.cookie = name+"="+escape( value ) +
    ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

/*
http://www.dustindiaz.com/top-ten-javascript/
*/
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}





//------------------------------------ok cambio de estilo-------------------//
//var doAlerts=false;
function changeSheets(whichSheet){
//  whichSheet=whichSheet-1;
  if(document.styleSheets){
    var c = document.styleSheets.length;
    //if (doAlerts) alert('Change to Style '+(whichSheet+1));
    for(var i=1;i<7;i++){//pongo 1 en vez de 0 para conservar el básico
		//pongo c-1 ya que decido por seguridad poner el ultimo estilo el normal
		//pongo 7=c para poder añadir mas css de otras cosas
		//como los añado al principio paso de 1/7 a 2/8 c-6/c...1=c-6
      if(i!=whichSheet){
        document.styleSheets[i].disabled=true;
				//alert('Analizo Style disabled '+(i));
      }else{
        document.styleSheets[i].disabled=false;
				//alert('Analizo Style enabled '+(i));
      }
    }
  }
	
}
function subeSheets(){
//  whichSheet=whichSheet-1;
  if(document.styleSheets){
    var c = document.styleSheets.length;
    for(var i=1;i<5;i++){//poner c-1-x x=nº estilos que añada detras
		//if (doAlerts) alert('Analizo Style '+(i+1));
		//c-2=5
      if(document.styleSheets[i].disabled==false){
					         // if (doAlerts) alert('entra en '+(i+1));
        document.styleSheets[i].disabled=true;
        document.styleSheets[i+1].disabled=false;
				SetStyleSheet(i+1) //grabo la cookie
				break;
      }
    }
  }
}
function bajaSheets(){
//  whichSheet=whichSheet-1;
  if(document.styleSheets){
    var c = document.styleSheets.length;
    for(var i=2;i<6;i++){//c-1=6  2=c-5
      if(document.styleSheets[i].disabled==false){
        document.styleSheets[i].disabled=true;
        document.styleSheets[i-1].disabled=false;
				SetStyleSheet(i-1) //grabo la cookie
				break;
      }
    }
  }
}


