// JavaScript Document


function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}

function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}


function muestraSubmenu(id) {

	

	if (document.getElementById(id).style.display == 'block')

		document.getElementById(id).style.display = 'none';

	else 

		document.getElementById(id).style.display = 'block';

}



function confirmar(accion) {

	return confirm ('¿Estás seguro de que deseas '+accion+'?');	

}



function createCalendar (input_id, button_id) {

	if(Calendar)

		Calendar.setup({

			inputField     :    input_id,      // id of the input field

			ifFormat       :    "%d/%m/%Y",       // format of the input field

			showsTime      :    false,            // will display a time selector

			button         :    button_id,   // trigger for the calendar (button ID)

			singleClick    :    false,           // double-click mode

			step           :    1                // show all years in drop-down boxes (instead of every other year as default)

		});

}



function createTimeCalendar (input_id, button_id) {

	if(Calendar)

		Calendar.setup({

			inputField     :    input_id,      // id of the input field

			ifFormat       :    "%d/%m/%Y %H:%M",       // format of the input field

			showsTime      :    true,            // will display a time selector

			button         :    button_id,   // trigger for the calendar (button ID)

			singleClick    :    false,           // double-click mode

			step           :    1                // show all years in drop-down boxes (instead of every other year as default)

		});

}



function addElemento(origen,destino) {

// Mueve elemento seleccionado de un select multiple a otro



	var listaO = document.getElementById(origen);

	var listaD = document.getElementById(destino);

	var lonO = listaO.options.length;

	var lonD = listaD.options.length;

	

	for (i = 0; i < lonO; i++) {

		if (listaO.options[i].selected) {	// Opcion seleccionada. La pasamos

			listaD.options[lonD++] = new Option (listaO.options[i].innerHTML,listaO.options[i].value);

			listaO.options[i] = null;

			i = i - 1; lonO = lonO - 1;

		}	

	}

}





function addElementos (origen, destino) {

// Mueve todos los elementos de un select multiple a otro

	var selectO = document.getElementById(origen);

	var lonO = selectO.options.length;

	

	for(i = 0; i < lonO; i++) {

		selectO.options[i].selected = true;

	}

	

	addElemento(origen,destino);

}



function selectAll(origen) {

// Selecciona todos los objetos de un select multiple

	var selectO = document.getElementById(origen);

	var lonO = selectO.options.length;

	for(i = 0; i < lonO; i++) {

		selectO.options[i].selected = true;

	}

}



function controlMay(e,id) {

	// Esto es para IE porque no necesita el evento como parametro, si no que lo coge del window

	kc = e.keyCode ? e.keyCode : e.which;

    sk = e.shiftKey ? e.shiftKey : ((kc == 16) ? true : false);

	var nombre = "caplock"+id;

  	if (((kc >= 65 && kc <= 90) && !sk) || ((kc >= 97 && kc <= 122) && sk))

    	document.getElementById(nombre).style.display = 'block';

  	else document.getElementById(nombre).style.display = 'none';

}



//Funcion que muestra el div en la posicion del mouse

function showdiv(event,msj,div)

{

	//determina un margen de pixels del div al raton

	margin=5;



	//La variable IE determina si estamos utilizando IE

	var IE = document.all?true:false;

	//Si no utilizamos IE capturamos el evento del mouse

	if (!IE) document.captureEvents(Event.MOUSEMOVE)



	var tempX = 0;

	var tempY = 0;



	tempX = event.clientX + document.documentElement.scrollLeft;

	tempY = event.clientY + document.documentElement.scrollTop;

	

	if (tempX < 0){tempX = 0;}

	if (tempY < 0){tempY = 0;}



	if (msj.length > 0) { document.getElementById('div-info').innerHTML = msj; }

	document.getElementById(div).style.top = (tempY+margin)+"px";

	document.getElementById(div).style.left = (tempX+margin)+"px";

	document.getElementById(div).style.display = 'block';

	return;

}



function ocultar(id) {

	document.getElementById(id).style.display = 'none';

}

//Abrir en nueva ventana

function ventanaSecundaria (URL){

window.open(URL,"ventana1","width=650, height=400, scrollbars=yes, menubar=no, location=no, resizable=no")

}





/*//Detección del navegador 



var BrowserDetect = {

       init: function () {

          this.browser = this.searchString(this.dataBrowser) || "An unknown browser";

          this.version = this.searchVersion(navigator.userAgent)

             || this.searchVersion(navigator.appVersion)

             || "an unknown version";

          this.OS = this.searchString(this.dataOS) || "an unknown OS";

       },

    searchString: function (data) {

       for (var i=0;i<data.length;i++) {

          var dataString = data[i].string;

          var dataProp = data[i].prop;

          this.versionSearchString = data[i].versionSearch || data[i].identity;

          if (dataString) {

             if (dataString.indexOf(data[i].subString) != -1)

                return data[i].identity;

          }

          else if (dataProp)

          return data[i].identity;

       }

    },

    searchVersion: function (dataString) {

       var index = dataString.indexOf(this.versionSearchString);

       if (index == -1) return;

       return parseFloat(dataString.substring(index+this.versionSearchString.length+1));

    },

    dataBrowser: [

       { string: navigator.userAgent,

          subString: "OmniWeb",

          versionSearch: "OmniWeb/",

          identity: "OmniWeb"

       },

    {

       string: navigator.vendor,

       subString: "Apple",

       identity: "Safari"

    },

    {

       prop: window.opera,

       identity: "Opera"

    },

    {

       string: navigator.vendor,

       subString: "iCab",

       identity: "iCab"

    },

    {

       string: navigator.vendor,

       subString: "KDE",

       identity: "Konqueror"

    },

    {

       string: navigator.userAgent,

       subString: "Firefox",

       identity: "Firefox"

    },

    {

       string: navigator.vendor,

       subString: "Camino",

       identity: "Camino"

    },

    { // for newer Netscapes (6+)

       string: navigator.userAgent,

       subString: "Netscape",

       identity: "Netscape"

    },

    {

       string: navigator.userAgent,

       subString: "MSIE",

       identity: "Explorer",

       versionSearch: "MSIE"

    },

    {

       string: navigator.userAgent,

       subString: "Gecko",

       identity: "Mozilla",

       versionSearch: "rv"

    },

    { // for older Netscapes (4-)

       string: navigator.userAgent,

       subString: "Mozilla",

       identity: "Netscape",

       versionSearch: "Mozilla"

    }

    ],

    dataOS : [

    {

       string: navigator.platform,

       subString: "Win",

       identity: "Windows"

    },

    {

       string: navigator.platform,

       subString: "Mac",

       identity: "Mac"

    },

    {

       string: navigator.platform,

       subString: "Linux",

       identity: "Linux"

    }

]



};

BrowserDetect.init();



//script para poner estilos distintos para cada navegador

if (BrowserDetect.browser == "Firefox") {

    document.write("<LINK REL='stylesheet' HREF='estilo_firefox.css' TYPE='text/css'>");

}

else {

    if (BrowserDetect.browser == "Explorer"){

       if (BrowserDetect.version>=7){

          document.write("<LINK REL='stylesheet' HREF='estilo_ie7.css' TYPE='text/css'>");

       }else{

          document.write("<LINK REL='stylesheet' HREF='estilo_ie6.css' TYPE='text/css'>");

       }

    }else{

       if (BrowserDetect.browser == "Opera"){

          if (BrowserDetect.version<9){

             document.write("<LINK REL='stylesheet' HREF='estilo_opera.css' TYPE='text/css'>");

          }else{

             document.write("<LINK REL='stylesheet' HREF='estilo_opera9.css' TYPE='text/css'>");

          }

       }else{

          document.write("<LINK REL='stylesheet' HREF='estilo_otros.css' TYPE='text/css'>");

       }

    }

} */