// JavaScript Document
function Actualizar_Recopilacion(){
	if($('upfile_0').style.display == 'block'){
		$('upfile_0').style.display = 'none';
	}else{
		$('upfile_0').style.display = 'block';
	}
}

function Mensaje_Modal(msj){
	Control.Modal.load();
	Control.Modal.open(msj);	
}

function Privacidad(){
	var resultado = true;
	var msg = '';
	if(!$('politica').checked){
		msg = "Debe aceptar la política de privacidad (tratamiento de datos personales) para proceder con su petición."; 
		resultado = false;
	}
	Mensaje_Modal(msg);
	return resultado;
}

function Es_Empresa(es_empresa){
	if(es_empresa){
		Effect.BlindDown('datos_facturacion');
	}else{
		Effect.BlindUp('datos_facturacion');
	}
	
}
NiftyLoad=function(){
	//Nifty('fieldset.uncuarto',"same-height none");								  
	Nifty('h3.heading',"top small");								  
}

function PopUp (pagina) {
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, width=600, height=500,  resizable=no, top=85, left=140";
window.open(pagina,"",opciones);
}

function emailValid(el) { 
	 em=/[\w-\.]+@[\w-\.]+.[a-z]+/i; 
	  if (!em.test(el.value)) { 
		  //alert('Por favor, introduzca un email valido.'); 
		  el.select(); 
		  return false;
	  } 
	  else return true;
} 


function cpValid(cp) {
	var n = Number(cp.value);
	if(isNaN(n) || cp.value.length!=5) {
		//alert("Por favor, introduzca un codigo postal valido.");
		return false;
	}
	else return true;
}

function Input_Filled(nombre, element) {
	if((element.value=='')||(element.value=='nada')) {
		//alert("Por favor, rellene el campo "+nombre+".");
		return false;
	}
	else return true;
}

function tlfValid(tlf){
	var n = Number(tlf.value);
	if(isNaN(n) || tlf.value.length==0){
		//alert("Por favor, introduzca un nmero de telfono vlido.");
		return false;
	}
	else return true;
}



function confirmar_borrado(msg) {
	return(confirm("" + msg));
}



// Funcin que comprueba la entrada de datos
function CompruebaDatos(elCIF) 
{
  var resul = false;
  var temp = elCIF.value.toUpperCase(); // pasar a maysculas

  if (!/^[A-Za-z0-9]{9}$/.test(temp))  // Son 9 dgitos? 

    	resul = "Longitud incorrecta, un CIF consta de 9 dgitos";

  else if (!/^[ABCDEFGHKLMNPQS]/.test(temp)) // Es una letra de las admitidas ?

     resul = "El primer dgito es incorrecto, debe ser una letra de las siguientes: A,B,C,D,E,F,G,H,K,L,M,N,P,Q,S ";

  else 

     resul = true;

  return resul;
}


// Funcin de validacin del CIF, indica el dgito de control.
// La funcin recibe el CIF completo: A58818501
function ValidaCIF(elCIF) 
{

  var v1 = new Array(0,2,4,6,8,1,3,5,7,9); 
  var temp = 0; 
  var temp1;

  
  for( i = 2; i <= 6; i += 2 ) 
    {
      temp = temp + v1[ parseInt(elCIF.value.substr(i-1,1)) ];
      temp = temp + parseInt(elCIF.value.substr(i,1));
    };

  temp = temp + v1[ parseInt(elCIF.value.substr(7,1)) ];

  temp = (10 - ( temp % 10));

  if( temp == 10 )
    alert( "El dgito de control es: J  0" );
  else
    alert( "El dgito de control es: "+temp ); 

  return true;
}
/*
Event.observe(window, 'load', function() {
	xajax.loadingFunction = showLoading;
    xajax.doneLoadingFunction = hideLoading;
});
function espere() {
	Control.Modal.load(); 
	Control.Modal.open("", {containerClassName: 'espere', overlayClassName: 'espere'});
}

showLoading = function() {
	xajax.$('cargando').style.display='inline';
};
hideLoading = function() {
	xajax.$('cargando').style.display = 'none';
}
*/
