// Funciones javascript de la página

// Funcion para cerrar el greyBox reservas desde la página padre
function closeParentWindow(id){
	parent.parent.GB_hide();
	if (id=='castellano'){
		document.location = "../es/index.html";
	}
	else if (id=='catalan'){
		document.location = "../ca/index.html";
	}
	else if (id=='ingles'){
		document.location = "../en/index.html";
	}
	else if (id=='frances'){
		document.location = "../fr/index.html";
	}
	else if (id=='castellano_private'){
		document.location = "../../es/members/index.php";
	}
	else if (id=='catalan_private'){
		document.location = "../../ca/members/index.php";
	}
	else if (id=='ingles_private'){
		document.location = "../../en/members/index.php";
	}
	else if (id=='frances_private'){
		document.location = "../../fr/members/index.php";
	}
	else if (id=='crucerosPullmantur'){
		document.location = "../reservas/crucerosPullmantur.php";
	}
	else if (id=='crucerosMSC'){
		document.location = "../reservas/crucerosMSC.php";
	}
}

// Funcion para cargar el form Aereo Reservas
function enviarAereo() {
	document.frmAereo.submit();
}

// Funcion para cargar el form Aereo Reservas
function enviarHotel() {
	document.frmHotel.submit();
}

// Funcion para cargar el form de Travelplan
function enviarTravelplan() {
	document.frmTravelplan.submit();
}

// Funcion para cargar el form Aereo Reservas
function enviarCosta() {
	document.frmCosta.submit();
}

// Funcion  para mostrar el iframe
function ShowWebSite(val)
{
	document.all.myFrame.src=val;
	document.all.myFrame.style.visibility="visible";
}

// Funcioon para el intercambio de imagenes
function changeImage(objeto,img)
{
    objeto.src=img;
}

// Funcion para validar el formulario de registro cliente
function validate(){ 
    if ((document.registro.name.value.length==0) || (document.registro.name_user.value.length==0) || (document.registro.address.value.length==0) || (document.registro.codPostal.value.length==0)|| (document.registro.city.value.length==0)|| (document.registro.province.value.length==0) || (document.registro.telephone.value.length==0)|| (document.registro.email.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.registro.name.focus() 
       return 0; 
    } 
    else {
			document.registro.submit();
	}
}

// Funcion para validar el formulario de login cliente
function validate_Login(){ 
    if ((document.login.name_user.value.length==0) || (document.login.password.value.length==0) || (document.login.telephone.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.login.name_user.focus() 
       return 0; 
    } 
    else {
			document.login.submit();
	}
}

// Funcion para validar el formulario de reserva de excursiones
function validate_FormExcursion(){ 
    if ((document.excursion.name.value.length==0) || (document.excursion.last_name.value.length==0) || (document.excursion.telephone.value.length==0) || (document.excursion.num_places.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.excursion.name.focus() 
       return 0; 
    } 
    else {
			document.excursion.precioPax.disabled=false;
			document.excursion.submit();
	}
}

// Funcion para validar el formulario de solicitud de cruceros
function validate_SolicitudCrucero(id){ 
    if ((document.crucero.name.value.length==0) || (document.crucero.last_name.value.length==0) || (document.crucero.telephone.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.crucero.name.focus() 
       return 0; 
    } 
    else {
		document.crucero.submit();
	}
}

// Funcion para validar el formulario de solicitud de cruceros
function validate_SolicitudOferta(id){ 
    if ((document.oferta.destino.value.length==0) ||(document.oferta.name.value.length==0) || (document.oferta.last_name.value.length==0) || (document.oferta.telephone.value.length==0) || (document.oferta.fechaInicial.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.oferta.name.focus() 
       return 0; 
    } 
    else {
		document.oferta.submit();
	}
}

// Funcion para validar el formulario de modificacion de datos del cliente
function validate_dataCustomers(){ 
    if ((document.dataCustomers.name.value.length==0) || (document.dataCustomers.name_user.value.length==0) || (document.dataCustomers.address.value.length==0) || (document.dataCustomers.codPostal.value.length==0)|| (document.dataCustomers.city.value.length==0)|| (document.dataCustomers.province.value.length==0) || (document.dataCustomers.telephone.value.length==0)|| (document.dataCustomers.email.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.dataCustomers.name.focus() 
       return 0; 
    } 
    else {
			document.dataCustomers.submit();
	}
}

// Funcion para validar el formulario de modificacion de datos del cliente
function validate_changeProfile(){ 
    if ((document.modifyProfile.nombre.value.length==0) || (document.modifyProfile.nombre_usuario.value.length==0) || (document.modifyProfile.password.value.length==0)|| (document.modifyProfile.direccion.value.length==0) || (document.modifyProfile.cp.value.length==0)|| (document.modifyProfile.poblacion.value.length==0)|| (document.modifyProfile.province.value.length==0) || (document.modifyProfile.telefono.value.length==0)|| (document.modifyProfile.email.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.modifyProfile.nombre.focus() 
       return 0; 
    } 
    else {
			document.modifyProfile.submit();
	}
}

// Funcion para validar el formulario de registro admin
function validate_Admin(){ 
    if ((document.registroAdmin.name.value.length==0) || (document.registroAdmin.nif.value.length==0) || (document.registroAdmin.password.value.length==0) || (document.registroAdmin.address.value.length==0) || (document.registroAdmin.codPostal.value.length==0)|| (document.registroAdmin.city.value.length==0)|| (document.registroAdmin.province.value.length==0) || (document.registroAdmin.telephone.value.length==0)|| (document.registroAdmin.email.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.registroAdmin.name.focus() 
       return 0; 
    } 
    else {
			document.registroAdmin.submit();
	}
}

// Funcion para validar el formulario de login admin
function validate_LoginAdmin(){ 
    if ((document.login.name.value.length==0) || (document.login.nif.value.length==0) || (document.login.password.value.length==0)){ 
       alert("Debe rellenar los campos obligatorios correctamente.") 
       document.login.name.focus() 
       return 0; 
    } 
    else {
			document.login.submit();
	}
}

// Funcion para inicializar googleMaps
function initialize() {
	
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(41.575765,2.027202), 16);
		map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
		
		var baseIcon = new GIcon();
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);
        baseIcon.infoShadowAnchor = new GPoint(18, 25);

			
		function createMarker(point, index) {
          
          var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);
          letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
          
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);

          GEvent.addListener(marker, "click", function() {
		  var content='<p><strong>Viatges Villegas S.L.</strong></p>';
		  marker.openInfoWindowHtml(content);
          });
		  
          return marker;
		  
		}
		var point = new GLatLng(41.575765, 2.027202);
		map.addOverlay(createMarker(point, 0));

	}
}
