// JavaScript Document

// tira o controle do flash
function flash(arqflash,largura,altura) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
	document.write('<param name="movie" value="' + arqflash + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="' + arqflash + '" width="' + largura + '" height="' + altura + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>');
	document.write('</object>');
}

function M_over(src,clrOver) {
 if (!src.contains(event.fromElement)) {
  src.style.cursor = 'hand';
  src.background = clrOver;
 }
}
function M_out(src,clrIn) {
 if (!src.contains(event.toElement)) {
  src.style.cursor = 'default';
  src.background = clrIn;
 }
}

function NovaJanela(mypage, myname, w, h, scroll, status) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+', status='+status+''
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus();
}
}

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

function buscar(){
	pacote = document.frmBusca.pacote.value;
	tipo = document.frmBusca.tipo.value;
	destino = document.frmBusca.destino.value;
	
	window.location='index.php?meio=resultado&pacote='+pacote+'&tipo='+tipo+'&destino='+destino;
}

function votar(perg,resp){
	if(document.frmEnquete.idresp.value == ""){
		alert("Por favor, selecione uma resposta!");
	} else {
		caminho_enquete = 'enquete_resultado.php?idenq='+perg+'&idresp='+resp+'&acao=votar';
		NovaJanela(caminho_enquete,'resultado_enq','360','400','no','no')
	}
}

function resul(perg){
	caminho_enquete = 'enquete_resultado.php?idenq='+perg;
	NovaJanela(caminho_enquete,'resultado_enq','360','400','no','no')
}

function voto(id)	{
	document.frmEnquete.idresp.value = id;
}

function news(){
	// EMAIL A SER CADASTRADO
	email = document.frmNews.EMAIL.value
		
		if(email == ''){
			alert('Por favor, informe seu email!');
		} else {
			caminho_news = 'news.php?email='+email;
			NovaJanela(caminho_news,'news','300','200','no','no')
		}
}

function mostrarFormViagem(){
	 document.getElementById("novo").style.display='block';
}
function ocultarFormViagem(){
	 document.getElementById("novo").style.display='none';
}

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) { 
   var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; 

      if(document.all) { // Internet Explorer 
        nTecla = evtKeyPress.keyCode; } 
      else if(document.layers) { // Nestcape 
        nTecla = evtKeyPress.which; 
      } 

      sValue = objForm[strField].value; 

      // Limpa todos os caracteres de formatação que 
      // já estiverem no campo. 
      sValue = sValue.toString().replace( "-", "" ); 
      sValue = sValue.toString().replace( "-", "" ); 
      sValue = sValue.toString().replace( ".", "" ); 
      sValue = sValue.toString().replace( ".", "" ); 
      sValue = sValue.toString().replace( "/", "" ); 
      sValue = sValue.toString().replace( "/", "" ); 
      sValue = sValue.toString().replace( "(", "" ); 
      sValue = sValue.toString().replace( "(", "" ); 
      sValue = sValue.toString().replace( ")", "" ); 
      sValue = sValue.toString().replace( ")", "" ); 
      sValue = sValue.toString().replace( " ", "" ); 
      sValue = sValue.toString().replace( " ", "" ); 
      fldLen = sValue.length; 
      mskLen = sMask.length; 

      i = 0; 
      nCount = 0; 
      sCod = ""; 
      mskLen = fldLen; 

      while (i <= mskLen) { 
        bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/")) 
        bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) 

        if (bolMask) { 
          sCod += sMask.charAt(i); 
          mskLen++; } 
        else { 
          sCod += sValue.charAt(nCount); 
          nCount++; 
        } 

        i++; 
      } 

      objForm[strField].value = sCod; 

      if (nTecla != 8) { // backspace 
        if (sMask.charAt(i-1) == "9") { // apenas números... 
          return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9 
        else { // qualquer caracter... 
          return true; 
        } } 
      else { 
        return true; 
      } 
    }


// ENTREGA VIRTUAL
function newsEntregaVirtual(){

	// CORES
	var corDoFundo = 'FFFFFF';
	var corDaFonte = '000000';

	var destinoCompleto = 'http://www.entregavirtual.com.br/listas_cadastro.php?idcliente=34&idlista=187&fundo='+corDoFundo+'&fonte='+corDaFonte;

	var popup = window.open(destinoCompleto, 'newsletter', 'height=450, width=400, top='+((screen.height - 550) / 2)+', left='+((screen.width - 400) / 2)+', scrollbars=no, status=no, menubar=no');

	if(null == popup || true == popup.closed){
		alert('Seu bloqueador de popup´s esta impedindo que a janela de newsletter seja aberta. Desative-o e clique no botão novamente!');
	}

}

