// JavaScript Document

function is_valid_email (email)
        {
         return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email);
        }
		
function valida()
		{
			var form = document.forms['Contact'];
			var span = document.getElementById('error');
			var errors = 0;
			if ((form.name.value == "") || (form.name.value == null) ) 
			{
				span.style.color='#FF9999';				
				span.innerHTML='';
				span.innerHTML=' | Füllen Sie die Felder in rot';				
				form.name.className ='input-text-error';
				errors++;
			}else
			{
				form.name.className='input-text';
			}
			 if (
				 (form.email.value == "") 
				 || 
				 
				 (form.email.value == null) 
				 
				 ||
				 
				 (!is_valid_email(form.email.value) )
				 
				 )
			{

				span.style.color='#FF9999';
				span.innerHTML='';
				span.innerHTML=' | F&uuml;llen Sie die Felder in rot';
				form.email.className ='input-text-error';
				errors++;
			}else
			{
				span.innerHTML='';
				form.email.className='input-text';
			}
		if (errors > 0) return false;
		form.submit();
		return true;		
			
		}

function isNumberKey(evt)
      {
    
         var charCode = (evt.which) ? evt.which : event.keyCode;
  
         if  (charCode == 46) return true;
         
         if (charCode > 31  &&  (charCode < 48 || charCode > 57  )  ) 
{
 
            return false;
}else{
         return true;
      }
      }

function setPersons(Id)
{
	var appendto = document.getElementById('change_me');
	appendto.innerHTML='';
	
	if (!appendto) return;
	
	switch (parseInt(Id)) // 4 cases
	{
    case 1:	

	var select = document.createElement('select');
	select.setAttribute('name','people');
	select.setAttribute('id','people');
	select.setAttribute('class','input-text-small');
	select.options[0] = new Option("1","1");
	select.options[1] = new Option("2","2");
	select.options[2] = new Option("3","3");
	break;
	
	case 2:	

	var select = document.createElement('select');
	select.setAttribute('name','people');
	select.setAttribute('id','people');
	select.setAttribute('class','input-text-small');
	select.options[0] = new Option("1","1");
	select.options[1] = new Option("2","2");
	select.options[2] = new Option("3","3");
	select.options[3] = new Option("4","4");
	break;
	
	case 3:	

	var select = document.createElement('select');
	select.setAttribute('name','people');
	select.setAttribute('id','people');
	select.setAttribute('class','input-text-small');
	select.options[0] = new Option("1","1");
	select.options[1] = new Option("2","2");
	select.options[2] = new Option("3","3");
	select.options[3] = new Option("4","4");
	break;	
	
	case 4:	

	var select = document.createElement('select');
	select.setAttribute('name','people');
	select.setAttribute('id','people');
	select.setAttribute('class','input-text-small');
	select.options[0] = new Option("1","1");
	select.options[1] = new Option("2","2");
	select.options[2] = new Option("3","3");
	select.options[3] = new Option("4","4");
	select.options[4] = new Option("5","5");
	select.options[5] = new Option("6","6");
	break;

	}
	
	appendto.appendChild(select);
	
}

function setmonth(mes)
{
  // if mes is a value 
  // tenemos que setear el selectedindex en el otro
  if (mes != "")
  {
	  var selectm = document.getElementById('month1');
	  selectm.selectedIndex = mes;
  }
}

function setyear(ano)
{
  // if año is a value 
  // tenemos que setear el selectedindex en el otro
  if (ano != "")
  {
	  var selecty = document.getElementById('year1');
	  selecty.selectedIndex = ano;
  }
}