////////////////////////////////////
function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}
//////////////////////////////////////
function SlideShow(slideList, image, speed, name)          
{
  this.slideList = slideList;
  this.image = image;
  this.speed = speed;
  this.name = name;
  this.current = 0;
  this.timer = 0;
}
//////////////////////////////////////
function SlideShow_play()       
{
  with(this)
  {
    if(current++ == slideList.length-1) current = 0;
    switchImage(image, slideList[current]);
    clearTimeout(timer);
    timer = setTimeout(name+'.play()', speed);
  }
}
/////////////////////////////////////
function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}
/***********************************************************/
function Hide(d) 
{
	if(document.getElementById(d).style.display != null)
	{document.getElementById(d).style.display = "none";}
}
////////////////////////////////////////////////////////////
function Show(d) 
{
	if(document.getElementById(d).style.display != null)
	{document.getElementById(d).style.display = "block";}
}
/***********************************************************/
function validateForm1()
{
	if(document.form1.Nom.value.length<3 )
	{ 
		alert("Votre nom SVP !");
		return false; 
	}
	else if(document.form1.Prenom.value.length<3 )
	{ 
		alert("Votre prénom SVP !");
		return false; 
	}
	else if(document.form1.Phone.value.length<4)
	{ 
		alert("Votre numero de téléphone SVP !");
		return false; 
	}
	else if (!isAValidEmail(document.form1.Email.value))
	{
		alert("Desolé mais votre email n'est pas valide !");
		return false;
	}
	else if(document.form1.Pays.value.length<1)
	{ 
		alert("Votre pays de residensce SVP !");
		return false; 
	}	
	else 
	{
		return true;
	}
}
function validateForm2()
	{
	if(document.form2.LastName.value.length<3 )
	{ 
		alert("Please enter your family name !");
		return false; 
	}
	else if(document.form2.FirstName.value.length<3 )
	{ 
		alert("Your first name is short !");
		return false; 
	}
	else if(document.form2.Phone.value.length<4)
	{ 
		alert("Please give us your phone number !");
		return false; 
	}
	else if (!isAValidEmail(document.form2.Email.value))
	{
		alert("Sorry, you entered an invalid e-mail address.  Please try again.");
		return false;
	}
	else if(document.form2.Country.value.length<1)
	{ 
		alert("Your actual country of residence please !");
		return false; 
	}	
	else 
	{
		return true;
	}
}
function isAValidEmail(inputValue) {
    var foundAt = false
    var foundDot = false
    var atPosition = -1
    var dotPosition = -1

    for (var i=0; i<=inputValue.length; i++) 
	{
    	if (inputValue.charAt(i) == "@" ) 
		{
        	foundAt = true
        	atPosition = i
    	}
    	else if (inputValue.charAt(i) == ".") 
		{
          foundDot = true
          dotPosition = i
      	}
    }
    if (!((foundAt && foundDot) && (atPosition < dotPosition-1))) 
	{
 		return false;
    }
	else
	{
		return true;
	}
}
