
var toScroll=new Array()
var ie=document.all
var dom=document.getElementById
var firstNews_obj;
var secondNews_obj;

function newsScroll(name){
  var c=this; c.name=name; c.mc=0; c.i=2;
  return this;
}

newsScroll.prototype.addItem = function(text,link,font,fontSize,fontStyle){
  var c = this;
  if (link !=''){
    if (font != '')
      toScroll[c.mc]="<a href='"+link+"'><font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font></a>";
    else
      toScroll[c.mc]="<a href='"+link+"'><font Class='"+fontStyle+"'>"+text+"</font></a>";
  }
  else { 
    if (font != '')
      toScroll[c.mc]="<font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font>";
    else
      toScroll[c.mc]="<font Class='"+fontStyle+"'>"+text+"</font>";
  }
  c.mc++;
}

newsScroll.prototype.construct = function(){
  var c = this; theWidth = c.scrollerwidth; theHeight=c.scrollerheight; thebgColor = c.scrollerbgcolor; theBackground =c.scrollerbackground; theDelay=c.scrollerdelay;
  scroll_obj=eval(c.name);        
  if (ie||dom){
    document.writeln('<div id="main2" style="position:relative;width:'+theWidth+';height:'+theHeight+';overflow:hidden;background-color:'+thebgColor+' ;background-image:url('+theBackground+')">')
    document.writeln('<div style="position:absolute;width:'+theWidth+';height:'+theHeight+';clip:rect(0 '+theWidth+' '+theHeight+' 0);left:0;top:0">')
    document.writeln('<div id="firstNews" style="position:absolute;width:'+theWidth+';left:0;top:1">')
    document.write(toScroll[0])
    document.writeln('</div>')
    document.writeln('<div id="secondNews" style="position:absolute;width:'+theWidth+';left:0;top:0;visibility:hidden">')
    document.write(toScroll[dyndetermine=(toScroll.length==1)? 0 : 1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</div>')
  }
}

newsScroll.prototype.move = function(whichdiv){
  var c = this; theDelay = c.scrollerdelay; theHeight = c.scrollerheight; 
  scroll_obj=eval(c.name);
  tdiv=eval(whichdiv)

  if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=5){
    tdiv.style.top=0+"px"
    setTimeout("scroll_obj.move(tdiv)",theDelay)
    setTimeout("scroll_obj.move2(secondNews_obj)",theDelay)
    //document.write('Got Milk?')
  return
  }
  if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){
    tdiv.style.top=parseInt(tdiv.style.top)-5+"px"
    setTimeout("scroll_obj.move(tdiv)",50)
  }
  else {
    tdiv.style.top=parseInt(theHeight)+"px"
    tdiv.innerHTML=toScroll[c.i]
    if (c.i==toScroll.length-1)
      c.i=0
    else
      c.i++
  }
}

newsScroll.prototype.move2 = function(whichdiv){
  var c = this; theDelay = c.scrollerdelay; theHeight= c.scrollerheight;
  scroll_obj=eval(c.name);
  tdiv2=eval(whichdiv)

  if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=5){
    tdiv2.style.top=0+"px"
    setTimeout("scroll_obj.move2(tdiv2)",theDelay)
    setTimeout("scroll_obj.move(firstNews_obj)",theDelay)
    return
  }
  if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
    tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px"
    setTimeout("scroll_obj.move2(secondNews_obj)",50)
  }
  else {
    tdiv2.style.top=parseInt(theHeight)+"px"
    tdiv2.innerHTML=toScroll[c.i]
    if (c.i==toScroll.length-1)
      c.i=0
    else
      c.i++
  }
}

newsScroll.prototype.startScroll = function(){
  var c = this;
  scroll_obj=eval(c.name);        
  
  if (toScroll.length >2)
    c.i = 2;
  else
    c.i = 0;
  
  firstNews_obj=ie? firstNews : document.getElementById("firstNews")
  secondNews_obj=ie? secondNews : document.getElementById("secondNews")
  setTimeout("scroll_obj.move(firstNews_obj)",c.scrollerDelay);
  secondNews_obj.style.top=theHeight;
  secondNews_obj.style.visibility='visible'
}






function click() {
if (event.button==2||event.button==3) {
 oncontextmenu='return false';
  }
}
document.onmousedown=click
document.oncontextmenu = new Function("return false;")

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();

function nereidFade(object, destOp, rate, delta)
{
	if(!document.all)
	return;
	if (object != "[object]")
	{
	setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
	return;
	}
	clearTimeout(nereidFadeTimers[object.sourceIndex]);
	diff = destOp-object.filters.alpha.opacity;
	direction = 1;
	if (object.filters.alpha.opacity > destOp)
	{
		direction = -1;
	}
	delta=Math.min(direction*diff,delta);
	object.filters.alpha.opacity+=direction*delta;
	if (object.filters.alpha.opacity != destOp)
	{
		nereidFadeObjects[object.sourceIndex]=object;
		nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
	}
}
if(document.images)		
{
	var offimg = new Array();
	offimg["cool"] = new Image(120,50);
	offimg["cool"].src = "[INSERT]";

	function imageOn(imgName) {
		if (document.images) {
			document.images[imgName].src = onimg[imgName].src;
		}
	}
	function imageOff(imgName) 
	{
		if (document.images) {
			document.images[imgName].src = offimg[imgName].src;
		}
	}

	function setMsg(msg) {
		window.status = msg;
		return true;
	}

}

function apaga()
{
	if((document.getElementById('newsletter').value) == "e-mail")
		document.getElementById('newsletter').value = "";
}

function apaga1()
{
	if((document.getElementById('newsletter_nome').value) == "nome")
		document.getElementById('newsletter_nome').value = "";
}

function box(link)
{
	window.open(link,"",""); 
}

function ValidaForm()
{
	var	erro = "";
	var valida = true;
	
	if (document.getElementById('newsletter_nome').value == "") erro += "1";
	if (document.getElementById('newsletter').value == "") erro += "1";
	
	if (document.getElementById('newsletter_nome').value == "nome") erro += "1";
	if (document.getElementById('newsletter').value == "e-mail") erro += "1";
	
	valida = emailCheck(document.getElementById('newsletter').value);
	//if (document.getElementById('newsletter').value == "e-mail") erro += "1";
	
	if (erro != "")
	{
		if(valida == true)
		{
			var aerro;
			aerro ="Preencha os campos corretamente! \n\n"; 
			//alert(aerro);
			document.getElementById("mensagem_1").style.display = "block";
		}
		return false;
	}
	else if(valida == false)
	{
		return false;
	}
	else
	{
        return true;
	}
}


function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

//alert("Endereço de e-mail incorreto (verifique @ )");
document.getElementById("mensagem_1").style.display = "block";
return false;
}
var user=matchArray[1];
var domain=matchArray[2];


for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
//alert("Este e-mail contém caracteres invalidos.");
document.getElementById("mensagem_1").style.display = "block";
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
//alert("Este e-mail contém caracteres inválidos.");
document.getElementById("mensagem_1").style.display = "block";
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

//alert("E-mail inválido.");
document.getElementById("mensagem_1").style.display = "block";
return false;
}


var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
//alert("E-mail inválido.");
document.getElementById("mensagem_1").style.display = "block";
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
//alert("E-mail inválido.");
document.getElementById("mensagem_1").style.display = "block";
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
//alert("E-mail inválido.");
document.getElementById("mensagem_1").style.display = "block";
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
//alert("E-mail inválido.");
document.getElementById("mensagem_1").style.display = "block";
return false;
}

// If we've gotten this far, everything's valid!
return true;
}



var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes';
win=window.open(mypage,myname,settings);}



function pess()
{
	
	//var num = document.form.site.options[document.form.site.selectedIndex].value;

	var num = document.getElementById("pessoas").options[document.getElementById("pessoas").selectedIndex].value;
	var i;
	for(i=1; i<10; i++)
	{
		if(i<=num){
			document.getElementById("linha_"+i).style.display = "block";
		}
		else
		{
			document.getElementById("linha_"+i).style.display = "none";
		}
	}
	
}

function dest(num,op)
{
	var ultimo = 0;

	if(op == 'a')
	{
		if(num == 1)
		{	
			document.getElementById("dest_"+num).style.display = "block";
			document.getElementById("dest_c").style.display = "block";
			document.getElementById("dest_r").style.display = "block";
		}
		else if(num == 0)
		{	
			var i;
			for(i=1; i<20; i++)
			{
				if(document.getElementById("dest_"+i))
					if(document.getElementById("dest_"+i).style.display == "block")
						ultimo = i;
				
			}

			ultimo=ultimo+1;

			document.getElementById("dest_"+ultimo).style.display = "block";
		}
	}
	else if(op == 'r')
	{
		document.getElementById("dest_"+num).style.display = "none";

		document.getElementById("dest_origem_"+num).value = "";
		document.getElementById("dest_destino_"+num).value = "";
		document.getElementById("dest_dia_"+num).value = "0";
		document.getElementById("dest_mes_"+num).value = "0";
		document.getElementById("dest_hor_"+num).value = "0";
		document.getElementById("dest_conf_"+num).checked = false;

		
	}
}

function fechar(id)
{
	document.getElementById(id).style.display = "none";
}

function abrir(id)
{
	document.getElementById(id).style.display = "block";
}

function ValidaForm2()
{
	var	erro = "";
	var	email = "";
	var valida = true;
	
	if(document.getElementById('email').value != document.getElementById('conf_email').value) email += "1";


	if(document.getElementById('nome').value == "") erro += "1";
	if(document.getElementById('origem').value == "") erro += "1";
	if(document.getElementById('destino').value == "") erro += "1";
	if(document.getElementById('hotel').value == "") erro += "1";
	if(document.getElementById('email').value == "") erro += "1";
	if(document.getElementById('conf_email').value == "") erro += "1";

	
	if (email != "")
	{
		document.getElementById("mensagem_a1").style.display = "block";
		return false;
	}
	else if(erro != "")
	{
		document.getElementById("mensagem_a2").style.display = "block";
		return false;
	}
	else
	{
        return true;
	}
}

function ValidaForm_orc()
{
	var	erro = "";
	var valida = true;
	
	if (document.getElementById('nome').value == "") erro += "1";
	if (document.getElementById('cidade').value == "") erro += "1";
	if (document.getElementById('estado').value == "") erro += "1";
	if (document.getElementById('email').value == "") erro += "1";

	if (erro != "")
	{
		
		document.getElementById("mensagem_b").style.display = "block";
		return false;
	}
	else
	{
        return true;
	}
}

function verifica_ida()
{
	if(document.getElementById('tipo_viagem').checked == false)
			document.getElementById("ida").style.display = "block";
	else
		document.getElementById("ida").style.display = "none";


}