	function AbreCentrada(url,nombre,ancho,alto)
	{
		mgtop = ((screen.height / 2) - (alto/2))-10
		mgleft = (screen.width / 2) - (ancho/2)
		
		window.open(url,nombre,'width='+ancho+',height='+alto+',top='+mgtop+',left='+mgleft+',scrollbars=yes,resizable=yes,status=no');

//		window.ventana.moveTo(ancho,alto);
	}
	
// Determine browser and version.
function Browser() {
	var ua, s, i;  
	this.isIE = false;
	this.isNS = false;
	this.version = null;
	ua = navigator.userAgent;
	s = "MSIE";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	s = "Netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
// Treat any other "Gecko" browser as NS 6.1.  
	s = "Gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = 6.1;
		return;
	}
}
var browser = new Browser();


// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;



function dragStart(event, id) {
	var el;
	var x, y;
	// If an element id was given, find it. Otherwise use the element being  // clicked on.
	if (id) dragObj.elNode = document.getElementById(id);
	else{
		if (browser.isIE) dragObj.elNode = window.event.srcElement;
		if (browser.isNS) dragObj.elNode = event.target;
	// If this is a text node, use its parent element.
		if (dragObj.elNode.nodeType == 3) dragObj.elNode = dragObj.elNode.parentNode;  
	}
	
// Get cursor position with respect to the page.  
	if (browser.isIE) {
		x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop;
	}
	if (browser.isNS) {
		x = event.clientX + window.scrollX;    
		y = event.clientY + window.scrollY;
	} 
// Save starting positions of cursor and element.  

	dragObj.cursorStartX = x;
	dragObj.cursorStartY = y;
	dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
	dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);
	if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
	if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;
	
// Update element's z-index.
	dragObj.elNode.style.zIndex = ++dragObj.zIndex;

// Capture mousemove and mouseup events on the page.  
	if (browser.isIE) {
		document.attachEvent("onmousemove", dragGo);
		document.attachEvent("onmouseup",   dragStop);
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}
	if (browser.isNS) {
		document.addEventListener("mousemove", dragGo,   true);
		document.addEventListener("mouseup",   dragStop, true);
		event.preventDefault();  
	}
}
function dragGo(event) {
	var x, y;
// Get cursor position with respect to the page.  
	if (browser.isIE) {
	x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
	y = window.event.clientY + document.documentElement.scrollTop  + document.body.scrollTop;
	}
	if (browser.isNS) {
	x = event.clientX + window.scrollX;    y = event.clientY + window.scrollY;  
	}
	
// Move drag element by the same amount the cursor has moved.  
	dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
	dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";
	
if (browser.isIE) {
	window.event.cancelBubble = true;
	window.event.returnValue = false;
}
if (browser.isNS)
	event.preventDefault();
}	
function dragStop(event) {
	// Stop capturing mousemove and mouseup events.
	if (browser.isIE) {
		document.detachEvent("onmousemove", dragGo);
		document.detachEvent("onmouseup",   dragStop);
	}
	if (browser.isNS) {
		document.removeEventListener("mousemove", dragGo, true);
		document.removeEventListener("mouseup", dragStop, true);  
	}
}	




	function ValidarDocIdentificacion(pTipo,pValor){
		if (pValor==""){
			return false
		}
		if (pTipo=="0"){
			return ValidarDNI(pValor);
		}else{
			if (pTipo=="1"){			
				return ValidarCIF(pValor);
			}else{
				if(pTipo=="2"){
					return true;
				}else{
					//alert("El tipo de documento de identificación debe estar informado.");
					return false;
				}
			}
		}		
	}
	
	
	function ValidarCIF(texto){    
		try{      
			var pares = 0; 
			var impares = 0; 
			var suma; 
			var ultima; 
			var unumero; 
			var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I"); 
			var xxx; 
			 
			texto = texto.toUpperCase(); 
			 
			var regular =/^[ABCDEFGHKLMNPQS]\d\d\d\d\d\d\d[0-9,A-J]$/g; 
			 if (!regular.exec(texto)) {
				document.getElementById('avisocif').style.display='';
//				alert("El C.I.F. es incorrecto"); 
				return false; 
			}
				  
			 ultima = texto.substr(8,1); 
		
			 for (var cont = 1 ; cont < 7 ; cont ++){ 
				 xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0"; 
				 impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
				 pares += parseInt(texto.substr(cont,1)); 
			 } 
			 xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0"; 
			 impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
			  
			 suma = (pares + impares).toString(); 
			 unumero = parseInt(suma.substr(suma.length - 1, 1)); 
			 unumero = (10 - unumero).toString(); 
			 if(unumero == 10) unumero = 0; 
			  
			 if ((ultima == unumero) || (ultima == uletra[unumero])) {
				 return true; 
			 }else{
				 //alert("El C.I.F. es incorrecto"); 
				 return false;
			 }
		}catch(e){
			//alert("Error en el ValidarCIF");			
		}
	} 
		
	function ValidarDNI (pDNI) 
	{
		var pNum, pLetra, cadena, posicion, letra
	
		// Validar la longitud.
		if(pDNI.length!=9) {
			document.getElementById('avisodni').style.display='';			
			return false;
		}
		
		pNum = pDNI.substring(0,8)
		pLetra = pDNI.substring(8,9)
		pLetra = pLetra.toUpperCase();
	
		cadena="TRWAGMYFPDXBNJZSQVHLCKET"
		posicion = parseFloat(pDNI) % 23
		letra = cadena.substring(posicion,posicion+1)
	
		if(letra != pLetra){
			document.getElementById('avisodni').style.display='';
			return false;
		}else{
			return true;
		}
	} 	


	function ValidarEmail(emailStr) {
		/* The following pattern is used to check if the entered e-mail address fits the user@domain format.  It also is used to separate the username from the domain. */
		var emailPat=/^(.+)@(.+)$/
		/* The following string represents the pattern for matching all special characters.  We don't want to allow special characters in the address. These characters include ( ) < > @ , ; : \ " . [ ]    */
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		/* The following string represents the range of characters allowed in a username or domainname.  It really states which chars aren't allowed. */
		var validChars="\[^\\s" + specialChars + "\]"
		/* The following pattern applies if the "user" is a quoted string (in which case, there are no rules about which characters are allowed and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")"
		/* The following pattern applies for domains that are IP addresses, rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		/* The following string represents an atom (basically a series of non-special characters.) */
		var atom=validChars + '+'
		/* The following string represents one word in the typical username. For example, in john.doe@somewhere.com, john and doe are words. Basically, a word is either an atom or quoted string. */
		var word="(" + atom + "|" + quotedUser + ")"
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		/* The following pattern describes the structure of a normal symbolic domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
		/* Finally, let's start trying to figure out if the supplied address is valid. */
	
		/* Begin with the coarse pattern to simply break up user@domain into different ??4??pieces that are easy to analyze. */
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
			/* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */
		document.getElementById('avisomail').style.display='';
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]
	
		// See if "user" is valid 
		if (user.match(userPat)==null) {
			// user is not valid
		document.getElementById('avisomail').style.display='';
			return false
		}
	
		/* if the e-mail address is at an IP address (as opposed to a symbolic host name) make sure the IP address is valid. */
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			// this is an IP address
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
				document.getElementById('avisomail').style.display='';
					return false
				}
			}
			return true
		}
		
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			document.getElementById('avisomail').style.display='';
			return false
		}
	
		/* domain name seems valid, but now make sure that it ends in a three-letter word (like com, edu, gov) or a two-letter word, representing country (uk, nl), and that there's a hostname preceding the domain or country. */
	
		/* Now we need to break up the domain to get a count of how many atoms it consists of. */
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) {
			// the address must end in a two letter or three letter word.
			//alert("La dirección de email debe acabar en 3 letras de dominio o 2 de un país.")
			return false;
		}
	
		// Make sure there's a host name preceding the domain.
		if (len<2) {
			var errStr="El dominio introducido en la dirección de email es incorrecto."
			document.getElementById('avisomail').style.display='';
			return false;
		}
	
		// If we've gotten this far, everything's valid!
		return true
	}

	function Enviar()
	{
		var hayerror = false;
		// deshactivar mensajes.
		document.getElementById('avisoempresa').style.display='none';
		document.getElementById('avisodnicif').style.display='none';
		document.getElementById('avisodni').style.display='none';
		document.getElementById('avisocif').style.display='none';
		document.getElementById('avisodireccion').style.display='none';
		document.getElementById('avisocodpost').style.display='none';
		document.getElementById('avisopoblac').style.display='none';
		document.getElementById('avisoprovin').style.display='none';
		document.getElementById('avisopercon').style.display='none';
		document.getElementById('avisomail').style.display='none';
		document.getElementById('avisotelefono').style.display='none';
		
        lNomEmp = document.forms.frmFormulario.nomemp.value;
		if (lNomEmp == ''){
//			alert("Debe indicar el nombre de su empresa, por favor.");
			document.getElementById('avisoempresa').style.display='';
			hayerror = true;
		}
		
        pTipo = document.forms.frmFormulario.tipoid.options[document.forms.frmFormulario.tipoid.selectedIndex].value;
		if (pTipo == ''){
			//alert("Indique su tipo de identificación, por favor.");
			hayerror = true;
		}


        lCifDni = document.forms.frmFormulario.cifdni.value;
		if (lCifDni == ''){
//			alert("Indique su C.I.F o D.N.I, por favor");
//			document.getElementById('avisodnicif').style.display='';
			hayerror = true;
		}else{
	    	if(!ValidarDocIdentificacion(pTipo,lCifDni)){
	    		hayerror = true;
	    	}
		}


        lDirecc = document.forms.frmFormulario.direcc.value;
		if (lDirecc == ''){
//			alert("Indique su dirección, por favor");
			document.getElementById('avisodireccion').style.display='';
			hayerror = true;
		}

        lCodPos = document.forms.frmFormulario.codpos.value;
		if (lCodPos == ''){
//			alert("Debe indicar el Código Postal, por favor");
			document.getElementById('avisocodpost').style.display='';
			hayerror = true;

		}

        lPoblac = document.forms.frmFormulario.poblac.value;
		if (lPoblac == ''){
//			alert("Indique la población de su empresa, por favor");
			document.getElementById('avisopoblac').style.display='';
			hayerror = true;
		}

        lProvin = document.forms.frmFormulario.provin.value;
		if (lProvin == ''){
			//alert("Indique la provincia de su empresa, por favor");
			document.getElementById('avisoprovin').style.display='';
			hayerror = true;
		}

        lPerCon = document.forms.frmFormulario.percon.value;
		if (lPerCon == ''){
			//alert("Indique su nombre o el de una persona de contacto, por favor");
			document.getElementById('avisopercon').style.display='';
			hayerror = true;
		}

        lMailUsu = document.forms.frmFormulario.mailusu.value;
		if (lMailUsu == ''){
			//alert("Indique una dirección de correo electrónico, por favor");
			document.getElementById('avisomail').style.display='';
			hayerror = true;
		}else{
	    	if(!ValidarEmail(lMailUsu)){
	    		hayerror = true;
	    	}
		}


        lTelUsu = document.forms.frmFormulario.telusu.value;
		if (lTelUsu == ''){
			//alert("Indique un numero de teléfono, por favor");
			document.getElementById('avisotelefono').style.display='';
			hayerror = true;
		}

        lFaxUsu = document.forms.frmFormulario.faxusu.value;

        lMovil = document.forms.frmFormulario.movil.value;
		
        lComentUsu = document.forms.frmFormulario.comentusu.value;
		if (lTelUsu == ''){
			//alert("Indique un numero de teléfono, por favor");
			hayerror = true;
		}

		if(hayerror) {
			return;
		}
		else {
			document.forms.frmFormulario.submit();
		}
		
	}
	
	function ValidarDocIdentificacion(pTipo,pValor){
		if (pValor==""){
			return false
		}
		if (pTipo=="0"){
			return ValidarDNI(pValor);
		}else{
			if (pTipo=="1"){			
				return ValidarCIF(pValor);
			}else{
				if(pTipo=="2"){
					return true;
				}else{
					//alert("El tipo de documento de identificación debe estar informado.");
					return false;
				}
			}
		}
	}
	
	function SaltoLinea(pValor){
	
		if (pValor!="0")
		{
			document.forms.frmFormulario.comentusu.value= (document.forms.frmFormulario.comentusu.value+"</br>");
		}
	}

