var caracter="1234567890";

caracter+="QWERTYUIOPASDFGHJKLÑZXCVÇBNM";

caracter+="qwertyuiopñlkjhçgfdsazxcvbnm";

var numero_caracteres=5;

var total=caracter.length;

var movCapaTexto=2;

var alturaCapaTexto=100;

var estado=true;

var delay=5;

var idInterval1=0;

var idInterval2=0;

function MM_swapImgRestore() { //v3.0



	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;



}



function MM_preloadImages() { //v3.0



	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();



	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)



	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}



}



function MM_findObj(n, d) { //v4.01



  	var p,i,x;  



	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {



		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);



	}



 	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];



  	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);



  	if(!x && d.getElementById) x=d.getElementById(n); return x;



}



function MM_swapImage() { //v3.0



  	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)



   	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}



}



function sabeNavegador () {
	if (BrowserDetect.browser == "Firefox") return "firefox"; 
	else 
    	if (BrowserDetect.browser == "Explorer")
       		if (BrowserDetect.version>=7 && BrowserDetect.version<8) return "ie7";
       		else if (BrowserDetect.version>=8 ) return "ie8";
       		else return "ie6";

}


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(); 



function generaTextoImagen (ancho, alto, texto1, texto2, fuente, tamanioFuente, coorX, coorY, colorR, colorG, colorB, fondoR, fondoG, fondoB, angulo, color2R, color2G, color2B, fondo2R, fondo2G, fondo2B, over, out, onClick, alineacion, alinearVert, alinearHor, efectos) {		



	//generaTextoImagen(50,7,"leer más >", "leer más >", "../fuentes/ARLRDBD.TTF", 7,0, 9, <?php echo $colorR.",".$colorG.",".$colorB; ?>, 300, 300, 300, 0, 51, 51, 51, 300, 300, 300,"", "", "middle", "top", "middle");







		var urlParametros1="generaImagenTexto.php?texto="+texto1;



		var urlParametros2="generaImagenTexto.php?texto="+texto2;



		



		//Ahora vamos componiendo la direccion en funcion de los datos de los que dispongamos



		if (ancho!=0) urlParametros1+="&ancho="+ancho;



		if (alto!=0) urlParametros1+="&alto="+alto;



		if (fuente!="") urlParametros1+="&fuente="+fuente;



		if (coorX!=0) urlParametros1+="&coorX="+coorX;



		if (coorY!=0) urlParametros1+="&coorY="+coorY;



		urlParametros1+="&colorR="+colorR;



		urlParametros1+="&colorG="+colorG;



		urlParametros1+="&colorB="+colorB;



		urlParametros1+="&fondoR="+fondoR;



		urlParametros1+="&fondoG="+fondoG;



		urlParametros1+="&fondoB="+fondoB;



		urlParametros1+="&angulo="+angulo;



		if (tamanioFuente!=0) urlParametros1+="&tamanioFuente="+tamanioFuente;



		urlParametros1+="&alinearVert="+alinearVert;



		urlParametros1+="&alinearHor="+alinearHor;



		



		



		//Ahroa vamos con la imagen de sustitucion, si es que tenemos que hacerla



		if (texto2!="") {



			if (ancho!=0) urlParametros2+="&ancho="+ancho;



			if (alto!=0) urlParametros2+="&alto="+alto;



			if (fuente!="") urlParametros2+="&fuente="+fuente;



			urlParametros2+="&coorX="+coorX;



			urlParametros2+="&coorY="+coorY;



			urlParametros2+="&colorR="+color2R;



			urlParametros2+="&colorG="+color2G;



			urlParametros2+="&colorB="+color2B;



			urlParametros2+="&fondoR="+fondo2R;



			urlParametros2+="&fondoG="+fondo2G;



			urlParametros2+="&fondoB="+fondo2B;			



			urlParametros2+="&angulo="+angulo;



			urlParametros2+="&tamanioFuente="+tamanioFuente;



			urlParametros2+="&alinearVert="+alinearVert;



			urlParametros2+="&alinearHor="+alinearHor;



		}



		//Ahora, en funcion de los parametros construimos



		var orden='<img border="0" src="librerias/'+urlParametros1+'" alt="'+texto1+'" ';



		if (efectos=="alpha") {



			orden+= " style='filter:Alpha(opacity=100)' onmouseover='this.style.filter=\"Alpha(opacity=80)\";' onmouseout='this.style.filter=\"Alpha(opacity=100)\";' ";



		}



		//Si tiene alineacion



		if (alineacion!="") orden+=' align="'+alineacion+'" ';



		if ((onClick!="") || (over!="") || (texto2!="")) orden+=' style="cursor:pointer; border:0" ';



		else orden+=' style="border:0" ';		



		//Si tiene over



		if ((texto2!="") && (over!="")) orden+='onMouseOver="this.src=\'librerias/'+urlParametros2+'\'; '+over+';" onMouseOut="'+out+'; this.src=\'librerias/'+urlParametros1+'\'" ';



		else {



			if (texto2!="") orden+='onMouseOver="this.src=\'librerias/'+urlParametros2+'\';" onMouseOut="this.src=\'librerias/'+urlParametros1+'\'" ';



			if (over!="") orden+='onMouseOver="'+over+'" ';



			if (out!="") orden+='onMouseOut="'+out+'" ';



		}



		//Si tiene onclick		



		if (onClick!="") orden+=' onClick="'+onClick+'"'; 		



		orden+='>';



		document.write (orden);



	}



function iniciaBaja () {

	//Inicia el movimiento de bajada de la capa que contiene el texto
	if (parseInt(document.getElementById("motiongallery").style.top)>((document.getElementById("motiongallery").offsetHeight-alturaCapaTexto)*-1)) {
		document.getElementById("motiongallery").style.top=parseInt(document.getElementById("motiongallery").style.top)-movCapaTexto+'px';	
		estado=true;
	} else {
		clearTimeout(idInterval1);
		estado=false;
		bajamos(true);			
	}
	if (estado) idInterval1=setTimeout("bajamos();",delay);

}

function paraBaja () {
	//Detiene el movimiento de baja de la capa que contiene el texto	
	clearTimeout(idInterval1);
}

function bajamos () {
	if (parseInt(document.getElementById("motiongallery").style.top)>((document.getElementById("motiongallery").offsetHeight-alturaCapaTexto)*-1)) {
		document.getElementById("motiongallery").style.top=parseInt(document.getElementById("motiongallery").style.top)-movCapaTexto+'px';	
		estado=true;
} else {
		clearTimeout(idInterval1);
		estado=false;
	}
	if (estado) idInterval1=setTimeout("bajamos();",delay);
}

function iniciaBaja2 () {

	//Inicia el movimiento de bajada de la capa que contiene el texto



	var alturaCapaTexto=80;



	if (parseInt(document.getElementById("motiongallery").style.top)>((document.getElementById("motiongallery").offsetHeight-alturaCapaTexto)*-1)) {

		document.getElementById("motiongallery").style.top=parseInt(document.getElementById("motiongallery").style.top)-movCapaTexto;	

		estado=true;

	} else {

		clearTimeout(idInterval1);

		estado=false;

		bajamos2(true);			

	}

	if (estado) idInterval1=setTimeout("bajamos2();",delay);

}

function paraBaja2 () {

	//Detiene el movimiento de baja de la capa que contiene el texto	



	clearTimeout(idInterval1);

}

function bajamos2 () {



	var alturaCapaTexto=80;

	if (parseInt(document.getElementById("motiongallery").style.top)>((document.getElementById("motiongallery").offsetHeight-alturaCapaTexto)*-1)) {

		document.getElementById("motiongallery").style.top=parseInt(document.getElementById("motiongallery").style.top)-movCapaTexto;	

		estado=true;

	} else {

		clearTimeout(idInterval1);

		estado=false;

	}

	if (estado) idInterval1=setTimeout("bajamos2();",delay);

}

function iniciaSubida () {
	//Inicia el movimiento de subida de la capa que contiene el texto	
	if (parseInt(document.getElementById("motiongallery").style.top)<0) {
		document.getElementById("motiongallery").style.top=parseInt(document.getElementById("motiongallery").style.top)+movCapaTexto+'px';	
		estado=true;
	} else {
		clearTimeout(idInterval2);
		estado=false;
		bajamos(true);			
	}
	if (estado) idInterval2=setTimeout("subimos();",delay);
}

function paraSubida () {

	//Detiene el movimiento de subida de la capa que contiene el texto		



	clearTimeout(idInterval2);

}

function subimos () {	



	if (parseInt(document.getElementById("motiongallery").style.top)<0) {

		document.getElementById("motiongallery").style.top=parseInt(document.getElementById("motiongallery").style.top)+movCapaTexto+'px';	

		estado=true;

	} else {

		clearTimeout(idInterval2);

		estado=false;

	}

	if (estado) idInterval2=setTimeout("subimos();",delay);

}

function escribeProvincias () {

		//Escribe todas las provincias



		document.write ('<option value="-1">Seleccione Provincia</option>');



		//Vamos escribiendo segun el array



		for (var cont=0; cont<listaNombreProvincias.length; cont++) document.write ('<option value="'+listaIdProvincias[cont]+'">'+listaNombreProvincias[cont]+'</option>');



	}



	function Refrescar (que,precede) {



		//Refrescamos en los campos que afecten a otro



		contador=1;



		idProv=document.getElementById(precede).options[document.getElementById(precede).selectedIndex].value;



		//Ya que tenemos el id provincia, solo tenemos que recorrer las localidades y añadir aquellas con el id provincia igual



		document.getElementById(que).length=0;



		document.getElementById(que).disabled=false;



		temporal=new Option("Seleccione una Localidad","-1");



		document.getElementById(que).options[0]=temporal;



		for (var cont=0; cont<listaIdProvinciaLocalidades.length; cont++)



			if (listaIdProvinciaLocalidades[cont]==idProv) {



				temporal=new Option(listaNombreLocalidades[cont],listaIdLocalidades[cont]);



				document.getElementById(que).options[contador++]=temporal;



			}



	}



	function cargaMunicipios (idProv) {



		//Carga los municipios de la provincia cuyo id se le pase



		document.write ('<option value="-1">Seleccione Municipio</option>');



		//Vamos escribiendo segun el array



		for (var cont=0; cont<listaIdProvinciaLocalidades.length; cont++)



			if (listaIdProvinciaLocalidades[cont]==idProv) document.write ('<option value="'+listaIdLocalidades[cont]+'">'+listaNombreLocalidades[cont]+'</option>');



	}



	function generaClaves (id) {



		//Genera una clave o un usuario.



		



		var clave="";



		for(a=0;a<numero_caracteres;a++) clave+=caracter.charAt(parseInt(total*Math.random(1)));



		document.getElementById(id).value=clave;



	}



	function compruebaNuevoUsuario () {

		

		var valido=true;

		var texto="No ha completado todos los datos. Debe indicar:\n ";

		if (document.getElementById("nombre").value=="") {

			valido=false;

			texto=texto+"\n* Nombre";

		}

		if (document.getElementById("nif").value=="") {

			valido=false;

			texto=texto+"\n* NIF";

		}

		if (document.getElementById("correo").value=="") {

			valido=false;

			texto=texto+"\n* Correo electronico";

		}

		if (document.getElementById("user").value=="") {

			valido=false;

			texto=texto+"\n* Nombre de usuario";

		}

		if (document.getElementById("contrasenia").value=="") {

			valido=false;

			texto=texto+"\n* Clave";

		}

		if (document.getElementById("repitaContrasenia").value=="") {

			valido=false;

			texto=texto+"\n* Debe repetir la clave";

		}

		var valido=true;		

		

		if (texto!="No ha completado todos los datos. Debe indicar:\n "){

			alert (texto);

			return;

		} else {

			if (!validarEmail(document.getElementById("correo").value)){ 

				alert ("El correo electronico que ha indicado no parece valido");

				return;

			}else {

				if (document.getElementById("contrasenia").value!=document.getElementById("repitaContrasenia").value){ 

					alert ("Las claves no coinciden. Por favor, reviselas.");

					return;

				}else {

					if (!document.getElementById("acepto").checked){

						alert ("Debe aceptar la politica sobre el tratamiento de datos personales");

						return;

					}else {

						document.getElementById("guardar").value="si";

						document.registro.submit();

					}

				}

			}

		}

	}

	function validarEmail(valor) {







		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)) return true;



		else return false;



	}
