// DELUQUE - Arconet 2009 

function EmailHTML(usuario,dominio,ancla,clase){
var HTMLContent="";
 if(usuario!=undefined && dominio!=undefined){
  if (ancla!=undefined) { HTMLContent+="<a href=mailto:"+usuario+"@"+dominio; 
  HTMLContent+= (clase!=undefined) ? " class="+clase+">" : ">";}
  HTMLContent+= usuario+"@"+dominio;
  if (ancla!=undefined) { HTMLContent+="</a>"; }
  document.write(HTMLContent)
 }
}

// PARA INSERTAR OBJETOS FLASH Y EVITAR EL PROBLEMA DE SEGURIDAD CON IE
function ObjetoFlash(id,archivo,ancho,alto,bgcolor,clase){
var str1 = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"';
var str2 = 'width='+ ancho +' height='+ alto +' id='+ id +' class="'+ clase +'">';
var str3 = '<param name="movie" value="'+ archivo +'" /><param name="allowFullScreen" value="true"/>';
var str4 = '<param name="quality" value="high" /><param name="menu" value="false" /><param name="allowScriptAccess" value="sameDomain" />';
var str5 = '<param name="bgcolor" value="'+ bgcolor +'"/>';
if (bgcolor=='transparent'){ str5 = '<param name="wmode" value="'+ bgcolor +'"/>'; }
var str6 = '<embed src="'+ archivo +'" quality="high" width="'+ ancho +'" height="'+ alto +'" name="'+ id +'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowFullScreen="true"';
var str7 = ' bgcolor="'+ bgcolor +'" /></object>';
if (bgcolor=='transparent'){ str7 = ' wmode="'+ bgcolor +'" /></object>'; }
document.write(str1+str2+str3+str4+str5+str6+str7);
}


// Funciones para el chequeo del formato del EMAIL ----------------------
function EmailCorrecto(email) {
caracNoValidos = " /:,;";
if(email=="") return false; // debe rellenarse
for(i=0;i<caracNoValidos.length; i++) {
// ¿hay algún carácter no válido ?
	caracMal = caracNoValidos.charAt(i);
	if(email.indexOf(caracMal,0) > -1){ alert('Hay caracteres no v\xE1lidos en el campo Email');return false;}
	}
posArroba = email.indexOf("@",1); // debe haber una arroba
if(posArroba==-1) { alert('Debe haber una ARROBA en el campo Email');return false;}
if (email.indexOf("@",posArroba+1)!= -1){ alert('Hay m\xE1s de una ARROBA en el campo Email');return false;}
// y sólo una arroba
posPunto = email.indexOf(".",posArroba);
if(posPunto == -1){ alert('Debe haber un PUNTO tras la ARROBA en el campo Email');return false;}
// y al menos un punto despues de la arroba
if (posPunto+3 > email.length){ alert('No es una direcci\xF3n de email v\xE1lida'); return false;}
// debe haber al menos 2 caracteres tras el punto
return true;
}

function EsNumerico (valor) { return !(isNaN(valor)); }

// Formatea un numero decimal ------------------------
// Sustituye el punto decimal por coma decimal
// El segundo parametro indica el numero de decimales
function FormatEuro(num,ce) {
	var cad=new String();
	num = num.toString().replace(/\,/,'.');
	num = num.toString().replace(/\$|\,/g,''); 
	pos=Math.pow(10,ce);
	if(isNaN(num)){return('Error')}
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*pos+0.50000000001);
	cents = num%pos;
	num = Math.floor(num/pos).toString();
	if(cents<10) cents = "0" + cents;
// PARA POENR PUNTUACION DE MILLAR
//	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
//	num = num.substring(0,num.length-(4*i+3))+'.'+ num.substring(num.length-(4*i+3));
	cad=((sign)?'':'-') + num.toString() + ((cents=="00")?'':',' +cents.toString());
	return cad;
}

// CHEQUEA LA LONGITUD DEL TEXTAREA
function CheckText(objeto,tope){
var cadena = new String('');
if (objeto.value.length>tope){
	cadena = objeto.value.toString().replace(/\r/,'');
	cadena = cadena.toString().slice(0,parseInt(tope-1));
	objeto.value=cadena;}
}

function CambiaDisplay(idobjeto){
var objeto = document.getElementById(idobjeto);
if (objeto=='[object]'){
if (objeto.style.display == ''){objeto.style.display = 'block';return false}
if (objeto.style.display == 'none'){objeto.style.display = 'block';return false}
if (objeto.style.display == 'block'){objeto.style.display = 'none';return false}
}
return(true)
}

// VALIDACION DEL FORMULARIO DE CONTACTO
function ValidarContacto(elform,idioma) {
var texto1es="Escriba su nombre";
var texto2es="Escriba su mensaje";
var texto1en="Your name";
var texto2en="Your surname";
var texto1fr="Votre nom";
var texto2fr="Votre nom de famille";

if (elform.nombre.value=="" || elform.nombre.value==eval("texto1"+idioma) ){ elform.nombre.value=eval("texto1"+idioma); elform.nombre.className='inputtextko'; elform.nombre.focus(); return (false)}
if (elform.mensaje.value=="" || elform.mensaje.value==eval("texto2"+idioma)){ elform.mensaje.value=eval("texto2"+idioma); elform.mensaje.className='inputtextko'; elform.mensaje.focus(); return (false)}
return true;
}

// VALIDACION DEL FORMULARIO DE ENVIO DE COMENTARIO.
function ValidarComentario(elform) {
var texto1="Escriba el comentario";
if (elform.comentario.value=="" || elform.comentario.value==texto1) {elform.comentario.value=texto1; elform.comentario.className='inputtextko'; elform.comentario.focus(); return (false)}
return true;
}

// VALIDACION DEL FORMULARIO DE ENVIO DE CURRICULUM
function ValidarOferta(elform, idioma) {
var texto1es="Escriba su nombre";
var texto2es="Escriba sus apellidos";
var texto3es="Introduzca su curriculum";
var texto1en="Type your name";
var texto2en="Type your surname";
var texto3en="Type your CV";
var texto1fr="Entrez votre nom";
var texto2fr="Entrez votre nom de famille";
var texto3fr="Entrez votre CV";

if (elform.nombre.value=="" || elform.nombre.value==eval("texto1"+idioma)) { elform.nombre.value=eval("texto1"+idioma); elform.nombre.className='inputtextko'; elform.nombre.focus(); return (false)}
if (elform.apellidos.value=="" || elform.apellidos.value==eval("texto2"+idioma)) { elform.apellidos.value=eval("texto2"+idioma); elform.apellidos.className='inputtextko'; elform.apellidos.focus(); return (false)}
if (elform.curriculum.value=="" || elform.curriculum.value==eval("texto3"+idioma)) {elform.curriculum.value=eval("texto3"+idioma); elform.curriculum.className='inputtextko'; elform.curriculum.focus(); return (false) }
return true;
}

// VALIDACION DEL FORMULARIO DE ENVIO DE CURRICULUM II
function ValidarCurriculum(elform, idioma) {
var texto1es="Escriba su nombre";
var texto2es="Escriba sus apellidos";
var texto3es="Introduzca su curriculum";
var texto1en="Type your name";
var texto2en="Type your surname";
var texto3en="Type your CV";
var texto1fr="Entrez votre nom";
var texto2fr="Entrez votre nom de famille";
var texto3fr="Entrez votre CV";
if (elform.nombre.value=="" || elform.nombre.value==eval("texto1"+idioma)) { elform.nombre.value=eval("texto1"+idioma); elform.nombre.className='inputtextko'; elform.nombre.focus(); return (false)}
if (elform.apellidos.value=="" || elform.apellidos.value==eval("texto2"+idioma)) { elform.apellidos.value=eval("texto2"+idioma); elform.apellidos.className='inputtextko'; elform.apellidos.focus(); return (false)}
if (elform.curriculum.value=="" || elform.curriculum.value==eval("texto3"+idioma)) {elform.curriculum.value=eval("texto3"+idioma); elform.curriculum.className='inputtextko'; elform.curriculum.focus(); return (false) }
return true;
}

// VALIDACION DEL FORMULARIO DE CONTACTO
function ValidarAltaUsuario(elform, idioma) {
var texto1es="Escriba su empresa";
var texto1en="Type your company";
var texto1fr="Tapez votre entreprise";
if (elform.empresa.value=="" || elform.empresa.value==eval("texto1"+idioma) ){ elform.empresa.value=eval("texto1"+idioma); elform.empresa.className='inputtextko'; elform.empresa.focus();  return (false);}
return true;
}

// VALIDACION DEL FORMULARIO DE RECUPERACION DE CONTRASEÑA
function ValidarEnviaPass(elform,idioma) {
var texto1es="Nombre de usuario";
var texto1en="Your name";
var texto1fr="Nom d'utilisateur";

if (elform.nombreRecupera.value=="" || elform.nombreRecupera.value==eval("texto1"+idioma) ){ elform.nombreRecupera.value=eval("texto1"+idioma); elform.nombreRecupera.className='inputtextko'; elform.nombreRecupera.focus();  return (false);}
return true;

}

// VALIDACION DEL FORMULARIO DE REGISTRO
function ValidarLogin(elform){
if (elform.usuario.value==""){elform.usuario.focus(); return (false)}
if (elform.clave.value=="") {elform.clave.focus(); return (false)}
return true;
}


// Anadir la web a Favoritos de IE y Marcadores de FF
function aFavoritos() {
title = "De Luque. Extractos y Aromas desde 1890"; 
url = "http://www.deluque.com";
if (window.sidebar){  // Mozilla Firefox Bookmark
	window.sidebar.addPanel(title, url,"");
} else if( window.external ) { // IE Favorite
	window.external.AddFavorite( url, title);
} else if(window.opera && window.print) { // Opera Hotlist
	return true;
}
}

// Funcion para mostrar y ocultar los textos en la seccion quienes somos.
function oculta(elDiv) {
var obj = document.getElementById(elDiv);
if (obj != undefined) obj.style.display = 'none';
}

function muestra(elDiv) {
var obj = document.getElementById(elDiv);
if (obj != undefined) obj.style.display = 'block';
}

function MuestraTexto(eldiv) {
switch (eldiv) {
	case 'historia': 
		oculta('filosofia'); oculta('politica'); muestra('historia');
		document.getElementById('enlacefilosofia').className='capactiva';
		document.getElementById('enlacepolitica').className='capactiva';
		document.getElementById('enlacehistoria').className='capactiva negrita enlace';
		break;
	case 'filosofia': 
		oculta('politica'); oculta('historia'); muestra('filosofia');
		document.getElementById('enlacefilosofia').className='capactiva negrita enlace';
		document.getElementById('enlacepolitica').className='capactiva';
		document.getElementById('enlacehistoria').className='capactiva';
		break;
	case 'politica':
		oculta('filosofia'); oculta('historia'); muestra('politica');
		document.getElementById('enlacefilosofia').className='capactiva';
		document.getElementById('enlacepolitica').className='capactiva negrita enlace';
		document.getElementById('enlacehistoria').className='capactiva';
		break;
	case 'politicaEN':
		oculta('filosofiaEN'); oculta('historiaEN'); muestra('politicaEN');
		document.getElementById('enlacefilosofiaEN').className='capactiva';
		document.getElementById('enlacepoliticaEN').className='capactiva negrita enlace';
		document.getElementById('enlacehistoriaEN').className='capactiva';
		break;
	case 'historiaEN': 
		oculta('filosofiaEN'); oculta('politicaEN'); muestra('historiaEN');
		document.getElementById('enlacefilosofiaEN').className='capactiva';
		document.getElementById('enlacepoliticaEN').className='capactiva';
		document.getElementById('enlacehistoriaEN').className='capactiva negrita enlace';
		break;
	case 'filosofiaEN': 
		oculta('politicaEN'); oculta('historiaEN'); muestra('filosofiaEN');
		document.getElementById('enlacefilosofiaEN').className='capactiva negrita enlace';
		document.getElementById('enlacepoliticaEN').className='capactiva';
		document.getElementById('enlacehistoriaEN').className='capactiva';
		break;
	case 'politicaFR':
		oculta('filosofiaFR'); oculta('historiaFR'); muestra('politicaFR');
		document.getElementById('enlacefilosofiaFR').className='capactiva';
		document.getElementById('enlacepoliticaFR').className='capactiva negrita enlace';
		document.getElementById('enlacehistoriaFR').className='capactiva';
		break;
	case 'historiaFR': 
		oculta('filosofiaFR'); oculta('politicaFR'); muestra('historiaFR');
		document.getElementById('enlacefilosofiaFR').className='capactiva';
		document.getElementById('enlacepoliticaFR').className='capactiva';
		document.getElementById('enlacehistoriaFR').className='capactiva negrita enlace';
		break;
	case 'filosofiaFR': 
		oculta('politicaFR'); oculta('historiaFR'); muestra('filosofiaFR');
		document.getElementById('enlacefilosofiaFR').className='capactiva negrita enlace';
		document.getElementById('enlacepoliticaFR').className='capactiva';
		document.getElementById('enlacehistoriaFR').className='capactiva';
		break;



	case 'introduccion':
		muestra('introduccion'); oculta('ofertas');
		document.getElementById('enlaceintroduccion').className='capactiva negrita enlace';
		document.getElementById('enlaceofertas').className='capactiva';
		break;
	case 'ofertas':
		oculta('introduccion'); muestra('ofertas'); oculta('introduccionEN'); oculta('introduccionFR');
		
		if (document.getElementById('enlaceofertas') != undefined) {
			// Estamos en idioma español.
			document.getElementById('enlaceofertas').className='capactiva negrita enlace';
			document.getElementById('enlaceintroduccion').className='capactiva';
		} else {
			if (document.getElementById('enlaceofertasEN') != undefined){
				// Estamos en idioma ingles.
				document.getElementById('enlaceofertasEN').className='capactiva negrita enlace';
				document.getElementById('enlaceintroduccionEN').className='capactiva';
			}
			else {
				// Estamos en francés
				document.getElementById('enlaceofertasFR').className='capactiva negrita enlace';
				document.getElementById('enlaceintroduccionFR').className='capactiva';
			}
		}
		
		break;
	case 'introduccionEN':
		muestra('introduccionEN'); oculta('ofertas');
		document.getElementById('enlaceintroduccionEN').className='capactiva negrita enlace';
		document.getElementById('enlaceofertasEN').className='capactiva';
		break;	
	case 'introduccionFR':
		muestra('introduccionFR'); oculta('ofertas');
		document.getElementById('enlaceintroduccionFR').className='capactiva negrita enlace';
		document.getElementById('enlaceofertasFR').className='capactiva';
		break;	
	default:break;
}
}
