﻿function gE(id){return document.getElementById(id)};

var _form;

function init()
{
	//mask = new DVDarkMask(document.body," ");
	$().ready(function(){$('#coda-slider-1').codaSlider({autoSlide: true,autoSlideInterval: 7000,autoSlideStopWhenClicked: true})});
	mask = new DVDarkMask(document.body,"enviando mensagem...");
	
	var loc = document.location.pathname;
		loc = loc.substring(loc.lastIndexOf('/')+1,loc.lastIndexOf('.'));
		var tel = null;
	switch(loc)
	{
		case 'localizacao':
			gE('imgrodape').style.visibility='hidden';
		break;
		case 'ohotel':
		case 'acomodacoes':
		case 'gurupi':
			$(function() {
				$('#conteudo .galeria a').lightBox();
			});		
			break;
		case 'contato':
			tel = new DVFormattedField(gE('c_fone'),'(##)####-####',function()
			{
				gE('c_email').focus();
			},
			function()
			{
			});
			_form = new DVForm(gE('contato'));
			break;
		case 'tabela_de_precos':
			break;
		default:
			mask_dark = new DVDarkMask();
			mask_dark.showMessage(false);
			
			loc = 'index';
			pr_checkin = new DVCalendar(gE('checkin'));
			pr_checout = new DVCalendar(gE('checkout'));
			bt_completar = new DVButton(gE('botc'),"Completar dados para pré-reserva",[7,6]);
			bt_completar.onClick.push(function()
			{
				if(pr_checkin.dt==null)
				{
					alert('Campo [data de entrada] não informado]');
					pr_checkin.obj.focus();
					return false;
				}
				gE('preres').submit();
			});
			break;
	}
	
	gE('_'+loc).setAttribute('selected',true);
}

	
function enviaEmail()
{
	if(_form.check())
	{
		mask.setVisible(true);
		mask.setText('enviando mensagem...');
		var sm = new Ajax("sendmail.php",function(ret)
		{
			mask.setVisible(false);
			if(parseInt(ret))
			{
				alert("Mensagem enviada com sucesso!\n\nResponderemos o mais breve possível!");
				document.location.replace('http://www.vianortehotel.com.br/contato.php');
			}
			else
				alert("Ocorreram problemas, a mensagem não pode ser enviada\n tente novamente mais tarde!");
		});
		mask.setVisible(true);
		sm.vars.push("ass="+gE('c_assunto').value);
		sm.vars.push("msg="+gE('c_msg').value);
		sm.vars.push("mail="+gE('c_email').value);
		sm.vars.push("fone="+gE('c_fone').value);
		sm.vars.push("nome="+gE('c_nome').value);
		sm.requestText(null,mask);
	}
}

function alteraStatusMsn()
{
	var img = gE('sts_msn');
}

	
