// JavaScript Document

<!--
<!--
function dynAnimation() {}
function clickSwapImg() {}
//-->


var sError = '';


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_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
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_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 LoadImages_Index()
{
	images/home/HG_Start_1_summer.jpg
	
	}
	
 function Validate_Fields()
  {
	  var bIsValid = false;
	  //alert(IsNull("Name"));
	  //alert(document.getElementById("Name").length);
	if ( document.getElementById("Province").value != -1 && !IsNull("Name") && !IsNull("Email") && !IsNull("City") && !IsNull("Mobil") && !IsNull("First_Surname") && isValidEmail("Email") == true)
	{
		// submit the form with the minimun fields.
	  	bIsValid = true;
		
		document.getElementById("Name").style.backgroundColor = "white";
		document.getElementById("Email").style.backgroundColor = "white";
		document.getElementById("Mobil").style.backgroundColor = "white";
		document.getElementById("First_Surname").style.backgroundColor = "white";
		document.getElementById("Province").style.backgroundColor = "white";
		document.getElementById("City").style.backgroundColor = "white";
	  }
	  else
	  {
		  if (document.getElementById("Province").value == -1)
		  	{
				document.getElementById("Province").style.backgroundColor = "red";
				}
				else
					document.getElementById("Province").style.backgroundColor = "white";
		  
		if (IsNull("Name"))
		  	{
				document.getElementById("Name").style.backgroundColor = "red";
				}
				else
					document.getElementById("Name").style.backgroundColor = "white";
					
				
		if (IsNull("Email"))
		  	{
				document.getElementById("Email").style.backgroundColor = "red";
				}
				else
					document.getElementById("Email").style.backgroundColor = "white";
			
		if (isValidEmail("Email") == false)
		  	{
				document.getElementById("Email").style.backgroundColor = "red";
				}
				else
					document.getElementById("Email").style.backgroundColor = "white";
					
		if (IsNull("City"))
		  	{
				document.getElementById("City").style.backgroundColor = "red";
				}
				else
					document.getElementById("City").style.backgroundColor = "white";
					
		if (IsNull("Mobil"))
		  	{
				document.getElementById("Mobil").style.backgroundColor = "red";
				}
				else
					document.getElementById("Mobil").style.backgroundColor = "white";
				
		if (IsNull("First_Surname"))
		  	{
				document.getElementById("First_Surname").style.backgroundColor = "red";
				}
				else
					document.getElementById("First_Surname").style.backgroundColor = "white";
				
		  //
		  }
		
		return bIsValid;
	}
	
	
	function Validate_FieldsWWF()
  {
	  var bIsValid = false;
	  //alert(IsNull("Name"));
	  //alert(document.getElementById("Name").length);
	if ( document.getElementById("Province").value != -1 && !IsNull("Name") && !IsNull("Email") && !IsNull("Mobil") && !IsNull("First_Surname") && isValidEmail("Email") == true)
	{
		// submit the form with the minimun fields.
	  	bIsValid = true;
		
		document.getElementById("Name").style.backgroundColor = "white";
		document.getElementById("Email").style.backgroundColor = "white";
		document.getElementById("Mobil").style.backgroundColor = "white";
		document.getElementById("First_Surname").style.backgroundColor = "white";
		document.getElementById("Province").style.backgroundColor = "white";
	  }
	  else
	  {
		  if (document.getElementById("Province").value == -1)
		  	{
				document.getElementById("Province").style.backgroundColor = "red";
				}
				else
					document.getElementById("Province").style.backgroundColor = "white";
		  
		if (IsNull("Name"))
		  	{
				document.getElementById("Name").style.backgroundColor = "red";
				}
				else
					document.getElementById("Name").style.backgroundColor = "white";
					
				
		if (IsNull("Email"))
		  	{
				document.getElementById("Email").style.backgroundColor = "red";
				}
				else
					document.getElementById("Email").style.backgroundColor = "white";
			
		if (isValidEmail("Email") == false)
		  	{
				document.getElementById("Email").style.backgroundColor = "red";
				}
				else
					document.getElementById("Email").style.backgroundColor = "white";
					
					
		if (IsNull("Mobil"))
		  	{
				document.getElementById("Mobil").style.backgroundColor = "red";
				}
				else
					document.getElementById("Mobil").style.backgroundColor = "white";
				
		if (IsNull("First_Surname"))
		  	{
				document.getElementById("First_Surname").style.backgroundColor = "red";
				}
				else
					document.getElementById("First_Surname").style.backgroundColor = "white";
				
		  //
		  }
		
		return bIsValid;
	}


	
	/*
			Validate if the field is null or empty
	*/
 function IsNull(sFieldId)
  {
	  var field = document.getElementById(sFieldId);
	  //alert(field.value.length);
	  if (field != 'undefined' && field != "undefined" && field.value.length > 0)
	  	{
			return false;
			}
	  else
		{
			return true;
			}
	  }
	  
 function isValidEmail(sEmail) {

	var str = document.getElementById(sEmail).value;

	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 

}
	  
	  function show_map_details(iArea)
{
	// iArea = 1, Galicia 
	// iArea = 2, Leoz Zamora
	// iArea = 3, Pais VAsco
	// iArea = 4, Madrid
	// iArea = 5, Caceeres Toledo
	// iArea = 6, Huesca Treual
	// iArea = 7, BCN
	// iArea = 8, Andacluia
	// iArea = 9, Tenerife
	var email = document.getElementById('company_detail.email');
	var name = document.getElementById('company_detail.name');
	var position = document.getElementById('company_detail.position');
	
	if (iArea == 1)
		{
			name.innerHTML = "Rodrigo Cerda.";
			email.innerHTML = "rodrigo.cerda@wesser.es.";
			position.innerHTML = "Puesto";
		}
	if (iArea == 2)
		{
			name.innerHTML = "Nicolás Perdomo.";
			email.innerHTML = "nicolas.perdomo@wesser.es";
			position.innerHTML = "Puesto";
		}
	if (iArea == 3)
		{
			name.innerHTML = "Simo Iben.";ç
			email.innerHTML = "simo.iben@wesser.es";
			position.innerHTML = "Puesto";
		}
	if (iArea == 4)
		{
			name.innerHTML = "Simo Iben.";
			email.innerHTML = "simo.iben@wesser.es";
			position.innerHTML = "Puesto";
		}
	if (iArea == 5)
		{
			name.innerHTML = "Simo Iben. / Roberto Navarro.";
			email.innerHTML = "simo.iben@wesser.es / roberto.navarro@wesser.es";
			position.innerHTML = "Puesto";
		}
	if (iArea == 6)
		{
			name.innerHTML = "Andrés Pérez.";
			email.innerHTML = "andres.perez@wesser.es";
			position.innerHTML = "Puesto";
		}
	if (iArea == 7)
		{
			name.innerHTML = "María Rodriguez.";
			email.innerHTML = "maria.rodriguez@wesser.es";
			position.innerHTML = "Puesto";
		}
	if (iArea == 8)
		{
			name.innerHTML = "Roberto Navarro.";
			email.innerHTML = "roberto.navarro@wesser.es";
			position.innerHTML = "Puesto";
		}	
	if (iArea == 9)
		{
			name.innerHTML = "Daniel Marrero. ";
			email.innerHTML = "daniel.marrero@wesser.es";
			position.innerHTML = "Puesto";
		}
		
	//$('company_detail').morph('background:#e50b0d; width:300px;'); 
	
	Effect.Grow('company_detail','bottom-right');

	return false;
	
	}
	
	
	function show_iFrame_RedCross(source)
	{
		var iframe = document.getElementById('iFrame_RedCross');
		
		iframe.src = '';
		iframe.src = source;
		
		return true;
		
		}
		
		
	function check_killer(KillerName)
	{
		var Killer = document.getElementsByName(KillerName);
		var bError = false;
		
		if (Validate_Fields() != true)
			{
				return false;
				}
		
		//alert('');
		if (Killer.length > 0)
		{
			for(var i = 0; i < Killer.length; i++) 
			{
				//alert(Killer[i].checked);
				if(Killer[i].checked  == true) 
					{bError = true;}
			}
		}
		else
			{bError = false;}
			
			
		return bError;
				
	}
	
	function check_killerWWF(KillerName)
	{
		var Killer = document.getElementsByName(KillerName);
		var bError = false;
		
		if (Validate_FieldsWWF() != true)
			{
				return false;
				}
		
		//alert('');
		if (Killer.length > 0)
		{
			for(var i = 0; i < Killer.length; i++) 
			{
				//alert(Killer[i].checked);
				if(Killer[i].checked  == true) 
					{bError = true;}
			}
		}
		else
			{bError = false;}
			
			
		return bError;
				
	}
		
		
