
/*
Global Risk Consulting
www.globalrisconsulting.es

By Space Bits
www.spacebits.es
*/

function foto_novedad(archivo){
	document.getElementById('foto').src="fotos/novedades/"+archivo;
	initImage('foto');
}

function initImage(imageId) {
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 20;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

function preload_images(images) {
	var preImages = new Array()
	for(i=0; i<images.length; i++){
		preImages[i] = new Image()
		preImages[i].src = images[i];
	}
} 



function canvia_foto(foto,actual){
	var proxima = parseInt(actual) + 1;
	if(proxima==images.length)proxima=0;	
	
	if(foto=="foto1") document.getElementById(foto).src=images[actual];
	if(foto=="foto2") document.getElementById(foto).src=images2[actual];
	if(foto=="foto3") document.getElementById(foto).src=images3[actual];
	
	initImage(foto);
	window.setTimeout("canvia_foto('"+foto+"','"+proxima+"')", 3000);
}

function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function enviar_contactar(){
	f=document.formcontactar;
	if(f.nombre.value.length<3) { alert("Introduce tu nombre"); f.nombre.focus(); }
	else if(f.empresa.value.length==0)  { alert("Introduce el nombre de tu empresa"); f.empresa.focus(); }
	else if(f.telefono.value.length<9)  { alert("Introduce el teéfono de contacto"); f.telefono.focus(); }
	else if(f.email.value.length==0)  { alert("Introduce tu e-mail"); f.email.focus(); }
	else if(!isValidEmail(f.email.value))  { alert("El e-mail introducido no es correcto"); f.email.focus(); }
	else if(f.repeteix_codi.value.length<5)  { alert("Introduce el código de seguridad"); f.repeteix_codi.focus(); }
	else f.submit();
	
}



function aviso_legal(){
	window.open('aviso_legal.php','globalrisk_legal','left=300,top=100,width=400,height=285,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no');
}
