function isCorrectEmail( email )
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if ( filter.test( email ) )
	{
		return true;
	}
	else
	{
		return false;
	}
}

function checkContact()
{
	var formu = document.envioForm;
	if ( formu.namemail.value == "" )
	{
		alert( "Debe de rellenar el campo 'Nombre'" );
		formu.namemail.focus();
		return false;
	}
	if ( formu.apellidosmail.value == "" )
	{
		alert( "Debe de rellenar el campo 'Apellidos'" );
		formu.apellidosmail.focus();
		return false;
	}
	if ( formu.telefonomail.value == "" )
	{
		alert( "Debe de rellenar el campo 'Teléfono'" );
		formu.telefonomail.focus();
		return false;
	}
	if ( formu.emailmail.value == "" )
	{
		alert( "Debe de rellenar el campo 'Email'" );
		formu.emailmail.focus();
		return false;
	}
	if ( !isCorrectEmail( formu.emailmail.value ) )
	{
		alert( "La direcci\u00F3n de email no es correcta." );
		formu.emailmail.focus();
		return false;
	}
	/*if ( formu.destinomail.options[formu.destinomail.selectedIndex].value == "?" )
	{
		alert( "Debe de seleccionar el campo 'Destinatario'" );
		formu.destinomail.focus();
		return false;
	}*/	
	if ( formu.comentario.value == "" )
	{
		alert( "Debe de rellenar el campo 'Comentario'" );
		formu.comentario.focus();
		return false;
	}
	formu.submit();
}

function abrirCarrusel( typeCarrusel, pathRoot, promocion )
{
	if ( typeCarrusel == "1" )
	{
		// vista aérea
		window.open( pathRoot + "/carrusel.php?type=1&promo=" + promocion, "carrusel", "width=800,height=600" );
	}
	else if ( typeCarrusel == "2" )
	{
		// plano situación
		window.open( pathRoot + "/carrusel.php?type=2&promo=" + promocion, "carrusel", "width=800,height=600" );
	}
	else if ( typeCarrusel == "3" )
	{
		// plano finca
		window.open( pathRoot + "/carrusel.php?type=3&promo=" + promocion, "carrusel", "width=800,height=600" );
	}
	else if ( typeCarrusel == "4" )
	{
		// plano finca
		window.open( pathRoot + "/carrusel.php?type=4&promo=" + promocion, "carrusel", "width=800,height=600" );
	}
}

function abrirCarruselPlanoSituacion()
{
	alert( "plano de situacion" );	
}

function abrirCarruselPlanoFinca()
{
	alert( "plano de finca" );	
}

function openWin( id, pathRoot )
{
	if ( id == "privacidad" )
	{
		window.open( pathRoot + "/privacidad.php", "privacidad", "width=550, height=400" );
	}
	else if ( id == "avisolegal" )
	{
		window.open( pathRoot + "/avisolegal.php", "avisolegal", "width=550, height=400" );
	}
	else if ( id == "creditos" )
	{
		window.open( pathRoot + "/creditos.php", "creditos", "width=550, height=400" );
	}
}