function animaciones_principales(){
	$('.top_cuadro').animate({'top': '-290px'}, 800);
	$('.cuadro').animate({'top': '166px'}, 800);	
}

function cargar_bandera(valor_idioma){
  	if(valor_idioma=="0"){
		 $('.pie .bandera').css({"background":"url(imagenes/inglaterra.png) no-repeat","width":"60px","height":"60px"});
		 $('.pie .bandera').attr("onClick","cargar_principal('1')");
	}else{
		 $('.pie .bandera').css({"background":"url(imagenes/venezuela.png) no-repeat","width":"60px","height":"60px"});
		 $('.pie .bandera').attr("onClick","cargar_principal('0')");
	}
}

function arreglo_idiomas(valor){
	var matriz=new Array(7);
	for(i=0;i<2;i++){
		matriz[i]=new Array(7);
	}
	matriz[0][0]="Planes Especiales"; 
	matriz[0][1]="Hotel";
	matriz[0][2]="Restaurantes";
	matriz[0][3]="Eventos";
	matriz[0][4]="Tarifas";
	matriz[0][5]="Reservas";
	matriz[0][6]="Contactos";
	matriz[1][0]="Special Plans";
	matriz[1][1]="Hotel";
	matriz[1][2]="Restaurants";
	matriz[1][3]="Events";
	matriz[1][4]="Rates";
	matriz[1][5]="Reservations";
	matriz[1][6]="Contacts";
	return matriz[valor];
}

function cargar_idioma(valor_idioma){
    var arreglo=new Array(7);
	arreglo=arreglo_idiomas(valor_idioma);
	for(i=1;i<=4;i++) {
     $('#boton'+i).html(arreglo[i-1]);
	}
	for(i=2;i<=4;i++) {
     $('#top_boton'+i).html(arreglo[i+2]);
	}	  
}

function animaciones_secundarias(valor_idioma){
	    tiempo=0;
	    for(i=1;i<=4;i++) {
			tiempo+=200;
		    setTimeout("$('#color"+i+"').fadeIn(0300)",tiempo);
		}
		/*if(valor_idioma=="1") {
		  $('.center_imgs').css('background-image', 'url("http://hbellavista.com/documentos/principal_navidad_ingles.jpg")');	
		}*/
		setTimeout( "$('.top_cuadro_verde').fadeIn(0500)",0500);
		setTimeout( "$('.logo').slideDown(1200)",0700);
		setTimeout( "$('.center_imgs').fadeIn(2000)",0700);
		setTimeout( "$('.info_botones ul li').fadeIn(0800)",0800);
		setTimeout( "$('.extra').fadeIn(0800)",1200);
		setTimeout( "$('.info_info ul li').fadeIn(0800)",2200);
		setTimeout( "$('.pie').hide().slideDown('slow').html('<ul class=texto>Hotel Bella Vista C.A. J-30432296-8. Copyright© 2011 Todos los Derechos Reservados</ul><ul class=bandera> </ul>')",2500);
		setTimeout( "$('.top_cuadro_derecha li').fadeIn(0800)",2600);
		setTimeout( "cargar_bandera('"+ valor_idioma +"')",2500);		
}
/* Al cargarse la pagina */
function comienzo(valor_idioma){
cargar_idioma(valor_idioma);
$('.loading').hide().remove('normal');
$(".cuadro").animate({width:'toggle'},0700);
setTimeout(animaciones_principales,0800);
setTimeout("animaciones_secundarias('"+ valor_idioma +"')",1500);
}

function cambiar_fondo(id,color){
	if(id.indexOf('boton')!=-1) {
		if(color=="#2066a0")	$(id).css({ 'color': '#FFF' });
		if(color=="#035294")	$(id).css({ 'color': '#87accc' });
	}
		$(id).animate({ backgroundColor: color  }, 'medium');
}

function cambiar_foto(id,accion){
	      if($(id).css("background-color")=="transparent"){
	  for(i=1;i<=4;i++){
		  	$("#info"+i).dequeue().animate({opacity: "0.8"}, 500);
		   if(accion=="poner")
	 		 $(id).dequeue().animate({opacity: "1"}, 500);
	  }}	  
}

/* Para cargar la animacion de los colores*/
function info_fadein(id,color){
	$(id).css({  "background": 'none'});
	$(id).animate({ backgroundColor: color  }, 1000);
}

/* Para realizar la animacion de los colores */
function cargar_animacion_principal(id,color,id2,id3, direccion, color_fondo,id4,color2){
	info_fadein(id,color);
	setTimeout("$('"+ id2 +"').hide(), $('"+ id3 +"').css({ 'width':'500px', 'background': '"+color_fondo+"'}), $('"+ id3 +"').show('slide', { direction: '"+direccion+"' }, 0500)",0700);
	setTimeout("info_fadein('"+id4+"','"+color2+"')",500);
}

/* Funcion para reestructurar todo a sus valores iniciales */
function valores_default(numero_prin,numero_sec){
	 var arreglo =new Array(8);
	 arreglo[0]="0px 0px";
	 arreglo[1]="-250px 0px";
	 arreglo[2]="-500px 0px";
	 arreglo[3]="-750px 0px";
	 arreglo[4]="planes";
	 arreglo[5]="hotel";
	 arreglo[6]="rest";
	 arreglo[7]="eventos";
	 $("#info"+numero_sec +" h3").fadeOut('fast').remove();
	 $("#info"+numero_sec +" p").fadeOut('fast').remove();
	 $("#info"+numero_prin +" p").fadeOut('fast').remove();
	 $("#imagen_arriba").fadeOut('slow').remove();
	 for(i=1;i<=4;i++){
	  $("#info"+i).attr("onClick","cargar_informacion('"+ arreglo[i+3]+"')");
	  $("#info"+i).attr('Onmouseout',"cambiar_foto('#info"+i+"','quitar')");
	  $("#info"+i).attr('Onmouseover',"cambiar_foto('#info"+i+"','poner')");
	  $("#info"+i).hide();
	  $("#info"+i).css({"width": "250px","cursor":"pointer", "background":"url(imagenes/info.jpg) no-repeat", "background-position": arreglo[i-1]});
	  $("#info"+i).fadeIn('slow');
  }
   document.getElementById('arreglo').value="0";
}

function cargar_foto_arriba(id_botonera,tipo_info){
      var dataString = 'id_botonera='+ id_botonera+ '&tipo_info='+tipo_info+"&acc=1";
	  $.ajax({ type: "POST",url:'script_php/cargar_foto.php', data:dataString,
            success: function (html) {
				$("#imagen_arriba").fadeOut('slow').remove(); 
				  if(html!="nada"){				                
		    		$("<li id='imagen_arriba'></li>").appendTo('.center_imgs').addClass('imagenes_centro');
					$("#imagen_arriba").css({"background":"url(../documentos/"+html+") no-repeat", "height":"220px", "display":"none"}).fadeIn('slow');
				}}});	
}

function cargar_foto_abajo(id_botonera,tipo_info,id_info){
      var dataString = 'id_botonera='+ id_botonera+ '&tipo_info='+tipo_info+"&acc=2";
	  $.ajax({ type: "POST",url:'script_php/cargar_foto.php', data:dataString,
            success: function (html) { 
				if(html!="nada"){
					setTimeout("$('"+id_info+"').css({'background':'url(../documentos/"+html+") no-repeat'}).fadeIn('slow')",0800);
				}}});	
}

function cargar_info_principal(id_botonera,id_info_foto,id_info_principal,id_info_secundario){
  	 var dataString = 'id_botonera='+ id_botonera+ '&id_info_foto='+id_info_foto+ '&id_info_principal='+id_info_principal + '&id_info_secundario='+id_info_secundario+"&acc=3";
	  $.ajax({ type: "POST",url:'script_php/cargar_foto.php', data:dataString,
            success: function (html) {
					setTimeout("$('"+id_info_principal+"').html('"+html+"')",1000);
				}});	
}

function cargar_info_secundaria(id_botonera,tipo_info,id_info_secundario){
  	 var dataString = 'id_botonera='+ id_botonera+ '&tipo_info='+tipo_info+"&acc=4";
	  $.ajax({ type: "POST",url:'script_php/cargar_foto.php', data:dataString,
            success: function (html) { 
			        $(id_info_secundario).html('');
					setTimeout("$('"+id_info_secundario+"').html('"+html+"').fadeIn('slow')",1200);		
				}});	
}


/* IMPORTANTE para cargar la info */
function cargar_info(id_botonera,tipo_info, id_info_foto,id_info_principal, id_info_secundario,valor){
    cargar_foto_arriba(id_botonera,tipo_info); 
	cargar_foto_abajo(id_botonera,tipo_info,id_info_foto);
	if(valor==1)
		cargar_info_principal(id_botonera,id_info_foto,id_info_principal,id_info_secundario);
	cargar_info_secundaria(id_botonera, tipo_info,id_info_secundario); 	
}

/* Para cargar la animacion */
function cargar_informacion(boton,numero_prin, numero_sec){
  if(document.getElementById('arreglo').value==boton){
     valores_default(numero_prin,numero_sec);
  }else{
  for(i=1;i<=4;i++){
	  $("#info"+i).css({"width": "250px","cursor":"default"});
	  $("#info"+i).dequeue().animate({opacity: "1"}, 0100);
	  $("#info"+i).show();
	  $("#info"+i).removeAttr('onclick');
	  $("#info"+i).removeAttr('onmouseout');
	  $("#info"+i).removeAttr('onmouseover');
	  $("#info"+i+ " p").fadeOut('medium').remove();
	  $("#info"+i+ " h3").fadeOut('medium').remove();
  }
  if(boton=="planes"){
	  cargar_animacion_principal("#info1", "#bfd9e6", "#info3", "#info2","left","#FFF","#info4","#e8e3a9");
	  cargar_info(7,1,"#info4","#info1","#info2",1);
  } else if(boton=="hotel"){
	  cargar_animacion_principal("#info2", "#FFF", "#info3", "#info4","left","#bfd9e6","#info1","#ccffcc");
	  cargar_info(3,1,"#info1","#info2","#info4",1);
  } else if(boton=="rest"){
	  cargar_animacion_principal("#info3", "#d946f9","#info1", "#info2","right", "#FFF", "#info4", "#FFF");
	  cargar_info(8,1,"#info4","#info3","#info2",1);
  } else if(boton=="eventos"){
	  cargar_animacion_principal("#info4", "#e8e3a9","#info2", "#info3","right","#eeeeee","#info1", "#cccccc");
	  cargar_info(9,1,"#info1","#info4","#info3",1);
  }  document.getElementById('arreglo').value=boton;
  }
}

/*Funcio para cargar un modal con la informacion adicional */
function cargar_modal(id_con,accion){
	       tamano=0;
		   if(accion=="reservas")
		      	tamano=80;
		   else if(accion=="contactos")
		      	tamano=30;
		   else if(accion=="tarifas")
		      	tamano=10;
		   $.get("script_php/cargar_modal.php", {id_con:id_con,acc:accion}, function(data){
			$(data).modal({
				closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
				position: ["15%",],
				overlayId: 'contact-overlay',
				containerId: 'contact-container',
				onOpen: contact.open,
				onShow: contact.show,
				onClose: contact.close
			});
		}); 
	var img = ['cancel.png', 'form_bottom.gif', 'form_top.gif'];
	$(img).each(function () {
		var i = new Image();
		i.src = 'imagenes/contact/' + this;
	});
	var contact = {
	message: null,
	open: function (dialog) {
		// add padding to the buttons in firefox/mozilla
		if ($.browser.mozilla) {
			$('#contact-container .contact-button').css({
				'padding-bottom': '2px'
			});
		}
		// input field font size
		if ($.browser.safari) {
			$('#contact-container .contact-input').css({
				'font-size': '.9em'
			});
		}
		var title = $('#contact-container .contact-title').html();
		$('#contact-container .contact-title').html('');
		dialog.overlay.fadeIn(200, function () {
			dialog.container.fadeIn(200, function () {
				dialog.data.fadeIn(200, function () {
					$('#contact-container .contact-content').animate({
						height: 280 + tamano
					}, function () {
						$('#contact-container .contact-title').html(title);
						$('#contact-container form').fadeIn(200, function () {
							if ($.browser.msie && $.browser.version < 7) {
								$('#contact-container .contact-button').each(function () {
									if ($(this).css('backgroundImage').match(/^url[("']+(.*\.png)[)"']+$/i)) {
										var src = RegExp.$1;
										$(this).css({
											backgroundImage: 'none',
											filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' +  src + '", sizingMethod="crop")'
										});
									}
								});
							}
						});});});});});
	},
	show: function (dialog) {
		$('#contact-container .contact-send').click(function (e) {
			e.preventDefault();
			// validate form
			if (contact.validate()) {
				var msg = $('#contact-container .contact-message');
				msg.fadeOut(function () {
					msg.removeClass('contact-error').empty();
				});
				$('#contact-container .contact-title').html('Hotel Bella Vista');
				$('#contact-container form').fadeOut(200);
				$('#contact-container .contact-content').animate({height: '80px' 
				}, function () {
					$('#contact-container .contact-loading').fadeIn(200, function () {
						$.ajax({
						   url: "script_php/mandar_correo.php", data: $('#contact-container form').serialize() + '&acc='+accion, type: 'post',cache: false,dataType: 'html', success: function (data) {
									$('#contact-container .contact-message').html(data).fadeIn(200);
							},
							error: contact.error
						});
					});
				});
			}
			else {
				if ($('#contact-container .contact-message:visible').length > 0) {							
					var msg = $('#contact-container .contact-message div');
					msg.fadeOut(200, function () {
						msg.empty();
						contact.showError();
						msg.fadeIn(200);
						
					});
				}

				else { if(accion=="reservas"){
						$('#contact-container .contact-content').animate({
						height: 310 + tamano });
					}		
					$('#contact-container .contact-message').animate({
						height: '30px'
					}, contact.showError);
				}
				
			}
		});
	},

	close: function (dialog) {
		$('#contact-container .contact-message').fadeOut();
		$('#contact-container .contact-title').html('');
		$('#contact-container form').fadeOut(400);
		$('#contact-container .contact-content').animate({
			height: 0
		}, function () {
			dialog.data.fadeOut(200, function () {
				dialog.container.fadeOut(200, function () {
					dialog.overlay.fadeOut(200, function () {
						$.modal.close();
					});});});});
	},
	error: function (xhr) {
		alert(xhr.statusText);
	},
    validate: function () {
		contact.message='';
		elementos = document.getElementById('forma').elements;
    for(var i=0; i<elementos.length;i++){
	     if((elementos[i].value=="") && (elementos[i].tagName!="BUTTON")) 
		   contact.message += '- ' +elementos[i].name;
	}
       	if (contact.message.length > 0){
			contact.message= 'Requerido: '+contact.message;
			return false;
		}else 
			return true;
	},
	showError: function () {
		$('#contact-container .contact-message')
			.html($("<div class='contact-error'></div>").append(contact.message))
			.fadeIn(200);
	}
	};
}

/* Funcion para cargar las fotos del modal */
function cargar_fotos_modal(imagen1,imagen2){
	setTimeout("$('.foto_adentro1').css({'background':'url(../documentos/"+imagen1+") no-repeat'}).fadeIn('slow')",1500);
	setTimeout("$('.foto2').css({'background':'url(../documentos/"+imagen2+") no-repeat'}).fadeIn('slow')",1500);
}

/* Para llamar al principal */
function cargar_principal(valor){
	 $.post("script_php/cargar_foto.php", { valor: valor , acc:"5" }, function(){
	    document.location.href="principal.php";
	});
}
