  MyWindow=null; //esta variável armazena o nome da última janela aberta por

var id,position=0;
var loveIt = 0;
var likeIt = 0;
var noComment = 0;
var itIsCool = 0;
var itIsHot = 0;
var itIsJazzy = 0;
var IWantIt = 0;
var secondTimeEmail = 0;
var secondTimeName = 0;
var secondTimeCic = 0;
var secondTimeEnd = 0;
var secondTimeGar = 0;

var theImages = new Array()
 
theImages[0] = '../img/header1.jpg' 
theImages[1] = '../img/header2.jpg'
theImages[2] = '../img/header3.jpg'
theImages[3] = '../img/header4.jpg'
theImages[4] = '../img/header5.jpg' 
theImages[5] = '../img/header6.jpg'
theImages[6] = '../img/header7.jpg'
 
var j = 0
var p = theImages.length;
var preBuffer = new Array()
 
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
 
function showImage(){
    if(whichImage==0){
    document.write('<a href ="index.html"><img src="'+theImages[whichImage]+'" border=0 width=770 height=250></a>');
    }
    else if(whichImage==1){
    document.write('<a href ="index.html"><img src="'+theImages[whichImage]+'" border=0 width=770 height=250></a>');
    }
    else if(whichImage==2){
    document.write('<a href ="index.html"><img src="'+theImages[whichImage]+'" border=0 width=770 height=250></a>');
    }
    else if(whichImage==3){
    document.write('<a href ="index.html"><img src="'+theImages[whichImage]+'" border=0 width=770 height=250></a>');
    }
    else if(whichImage==4){
    document.write('<a href ="index.html"><img src="'+theImages[whichImage]+'" border=0 width=770 height=250></a>');
    }
	else if(whichImage==5){
    document.write('<a href ="index.html"><img src="'+theImages[whichImage]+'" border=0 width=770 height=250></a>');
    }
    else if(whichImage==6){
    document.write('<a href ="index.html"><img src="'+theImages[whichImage]+'" border=0 width=770 height=250></a>');
    }
    else if(whichImage==7){
    document.write('<a href ="index.html"><img src="'+theImages[whichImage]+'" border=0 width=770 height=250></a>');
    }
 
}

var enderecosite="http://www.pousadaellshadai.tur.br"
var titulosite="Pousada El Shadai"
function adicionafavoritos(){
	if (document.all)
		window.external.AddFavorite(enderecosite,titulosite) ;
}		

/*function disableRightClick(e)
{
  var message = "Todos os direitos são reservados";
  
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      alert(message);
	  javascript:adicionafavoritos();
      return false;
    }
  }
  else
  {
    alert(message);
	javascript:adicionafavoritos();
    return false;
  }
}
disableRightClick();*/

function validatePrompt (Ctrl, PromptStr)
{
	alert (PromptStr)
        Ctrl.focus();
        return;
}
function Acknowledge (Ctrl, PromptStr)
{
	alert (PromptStr)
	return;
}
function ShowMsgItIsCool(form)
{
	Ctrl = form.Page_description_a;
	if (!itIsCool)
   {
		Acknowledge (Ctrl, "Quarto com televisão, frigobar, telefone, canal de vídeo e banheiro individual externo.");
      itIsCool = 1;
	}
   else itIsCool = 0;
}

function ShowMsgItIsHot(form)
{
	Ctrl = form.Page_description_b;
	if (!itIsHot)
   {
		Acknowledge (Ctrl, "Quarto com televisão, telefone, canal de vídeo e banheiro.");
      itIsHot = 1;
	}
   else itIsHot = 0;
}


function ShowMsgItIsHot1(form)
{
	Ctrl = form.Page_description_c;
	if (!itIsJazzy)
   {
		Acknowledge (Ctrl, "Quarto com televisão, telefone, canal de vídeo e banheiro.");
      itIsJazzy = 1;
	}
   else itIsJazzy = 0;
}

function ShowMsgItIsJazzy(form)
{
	Ctrl = form.Page_description_c;
	if (!itIsJazzy)
   {
		Acknowledge (Ctrl, "Quarto com televisão, telefone, canal de vídeo e banheiro.");
      itIsJazzy = 1;
	}
   else itIsJazzy = 0;
}
function TestEmailBox(form) {

	// Check the User name
  	Ctrl = form.nome;
	if (Ctrl.value == "")
   {
		if (!secondTimeName)
      {
			validatePrompt (Ctrl, "Você não especificou o seu nome.\nPor favor preencha o campo.")
      	secondTimeName = 1;
      	return false;
      }
	}

	// Check the User Cic
  	Ctrl = form.cpf;
	if (Ctrl.value == "")
   {
		if (!secondTimeCic)
      {
			validatePrompt (Ctrl, "Você não especificou o seu CPF.\nPor favor preencha o campo.")
      	secondTimeCic = 1;
      	return false;
      }
	}

	// Check the User End
  	Ctrl = form.endereco;
	if (Ctrl.value == "")
   {
		if (!secondTimeEnd)
      {
			validatePrompt (Ctrl, "Você não especificou o seu Endereço.\nPor favor preencha o campo.")
      	secondTimeEnd = 1;
      	return false;
      }
	}


	// Check the User Gar
  	Ctrl = form.gares;
	if (Ctrl.value == "")
   {
		if (!secondTimeGar)
      {
			validatePrompt (Ctrl, "Você não especificou a Garantia.\nPor favor preencha o campo.")
      	secondTimeGar = 1;
      	return false;
      }
	}

	// Check the E_mail address
	Ctrl = form.email;
	if (Ctrl.value == "" || Ctrl.value.indexOf ('@', 0) == -1  || Ctrl.value.indexOf ('.', 0) == -1)
   {
		if (!secondTimeEmail)
      {
			validatePrompt (Ctrl, "Você não preencheu seu endereço de e-mail.\nPor favor preencha o campo.")
      	secondTimeEmail = 1;
      	return false;
      }
	}
	return true;
}

function runSubmit (form, button)
{
	if (TestEmailBox(form))
   {
		Ctrl = form;
		// What does the user say?
		if (loveIt || likeIt || itIsCool || itIsJazzy)
   	{
			Acknowledge (Ctrl, "Obrigado por preencher este formulário e pelos seus comentários.")
   	}
		else
      {
      	Acknowledge (Ctrl, "Obrigado por preencher este formulário.")
		}
		form.submit();
	}
	return;
}

function jczOpenWindow(theURL,winName) {
  if(MyWindow != null)
 {
  if(!MyWindow.closed) 
  {
   if(MyWindow.name != winName) 
   {
    MyWindow.close();    
    MyWindow = window.open(theURL,winName,'status=yes,scrollbars=no,width=800,height=600');

   } else 
   {
    MyWindow.focus(); 
   }
  } else 
  {   
   MyWindow = window.open(theURL,winName,'alwaysRaised=yes,status=yes,scrollbars=no,width=800,height=600');
  }
 }
 else
 { 
  MyWindow = window.open(theURL,winName,'alwaysRaised=yes,status=yes,scrollbars=no,width=800,height=600');
 }
}

function jczResetWindow(bmp) 
{         
 self.moveTo(2,2);
 self.resizeTo(bmp.width+50,bmp.height+130); 
}
