/*******
***Name        : set_blank_gals;
***Description : Inicar o div com a foto grande, com o valor da primeira foto do array nas galerias;
***Input       : djs_foto = nome da foto a ser carregada;
***Output      : nothing;
*******/
   function set_blank_gals(djs_foto) {
      var e = document.getElementById('fotoExt_gde');
      var i = document.createElement('img');
      i.setAttribute('src', 'fotos/' + djs_foto);
      i.setAttribute('width', '550');
      i.setAttribute('height', '270');
      e.appendChild(i);      
   }

/*******
***Name        : change_foto_gals;
***Description : Trocar a imagem do div com a foto grande, com o valor da primeira foto escolhida nas galerias;
***Input       : djs_foto = nome da foto a ser carregada;
***Output      : nothing;
*******/
   function change_foto_gals(djs_foto) {
      var e = document.getElementById('fotoExt_gde');
      if(!e.hasChildNodes()) {
         return;
      }      
      var c = e.childNodes;
      while(c.length > 0) {
         var no = c[c.length-1];
         e.removeChild(no);
      }
      var i = document.createElement('img');
      i.setAttribute('src', 'fotos/' + djs_foto);
      i.setAttribute('width', '550');
      i.setAttribute('height', '270');
      e.appendChild(i);
   }

/*******
***Name        : set_blank_djs;
***Description : Inicar o div com o nome e a foto grande, com o valor do primeiro valor do array na listagem dos djs;
***Input       : djs_name     = nome do dj a ser carregado;
                 djs_estilo   = estilo musical do dj a ser carregado;
                 djs_foto     = nome da foto a ser carregada;
***Output      : nothing;
*******/
   function set_blank_djs(djs_name, djs_estilo, djs_foto) {
      var e = document.getElementById('djs_name');
      var txt1 = document.createTextNode(djs_name);
      var br1  = document.createElement('br');
      var txt2 = document.createTextNode(djs_estilo);
      e.appendChild(txt1);
      e.appendChild(br1);
      e.appendChild(txt2);
      
      var f = document.getElementById('djs_foto');
      var i = document.createElement('img');
      i.setAttribute('src', 'fotos/' + djs_foto);
      i.setAttribute('width', '244');
      i.setAttribute('height', '167');
      f.appendChild(i);      
   }

/*******
***Name        : change_name_djs;
***Description : Trocar o nome e a imagem do djs na listagem dos djs;
***Input       : djs_name     = nome do dj a ser carregado;
                 djs_estilo   = estilo musical do dj a ser carregado;
                 djs_foto     = nome da foto a ser carregada;
***Output      : nothing;
*******/
   function change_name_djs(djs_name, djs_estilo, djs_foto) {
      var e = document.getElementById('djs_name');      
      if(!e.hasChildNodes()) {
         return;
      }      
      var c = e.childNodes;
      while(c.length > 0) {
         var no = c[c.length-1];
         e.removeChild(no);
      }

      var txt1 = document.createTextNode(djs_name);
      var br1  = document.createElement('br');
      var txt2 = document.createTextNode(djs_estilo);

      e.appendChild(txt1);
      e.appendChild(br1);
      e.appendChild(txt2);
     
      var f = document.getElementById('djs_foto');
      if(!f.hasChildNodes()) {
         return;
      }      
      var c = f.childNodes;
      while(c.length > 0) {
         var no = c[c.length-1];
         f.removeChild(no);
      }
      var i = document.createElement('img');
      i.setAttribute('src', 'fotos/' + djs_foto);
      i.setAttribute('width', '244');
      i.setAttribute('height', '167');
      f.appendChild(i);
   }

/*
Seção da barra de rolagem
*/
   function startDiv(dir) {
      x = 1; //amount to jump by
      delay = 10; //speed in milliseconds
      moving = window.setInterval("scrollDiv("+x+","+dir+")",delay);
      return true;
   }

   function speedDiv(dir){
      x = 5; //amount to jump by
      delay = 1; //speed in milliseconds
      speedmoving = window.setInterval("scrollDiv("+x+","+dir+")",delay);
      return true;
   }

   function scrollDiv(x,dir){
      if (dir == 1) {
         document.getElementById("mydiv").scrollTop -= x;
	   } else {
		 document.getElementById("mydiv").scrollTop += x;
      }
   }

   function stopSpeedDiv(){
      if (speedmoving) {
         window.clearInterval(speedmoving);
      }
   }

   function stopDiv() {
      if (moving) {
         window.clearInterval(moving);
      }
   }

   function pageScroll() {
      parent.iframe.scrollBy(0,50); // horizontal and vertical scroll increments
      scrolldelay = setTimeout('pageScroll()',50); // scrolls every 100 milliseconds
   }


/*
Seção da barra de rolagemb
*/
   function startDivb(dir) {
      x = 1; //amount to jump by
      delay = 10; //speed in milliseconds
      moving = window.setInterval("scrollDivb("+x+","+dir+")",delay);
      return true;
   }

   function speedDivb(dir){
      x = 5; //amount to jump by
      delay = 1; //speed in milliseconds
      speedmoving = window.setInterval("scrollDivb("+x+","+dir+")",delay);
      return true;
   }

   function scrollDivb(x,dir){
      if (dir == 1) {
         document.getElementById("mydivb").scrollTop -= x;
	   } else {
		 document.getElementById("mydivb").scrollTop += x;
      }
   }

   function stopSpeedDivb(){
      if (speedmoving) {
         window.clearInterval(speedmoving);
      }
   }

   function stopDivb() {
      if (moving) {
         window.clearInterval(moving);
      }
   }

   function pageScrollb() {
      parent.iframe.scrollBy(0,50); // horizontal and vertical scroll increments
      scrolldelay = setTimeout('pageScroll()',50); // scrolls every 100 milliseconds
   }


/******
function    :  AjaxRequest;
description :  função que cria o XMLHttpRequest para qualquer Browser. XMLHttpRequest é o item essencial para o Ajax;
input       :  nada;
output      :  nada;
******/
   function AjaxRequest() {
      Ajax = false;
      if( window.XMLHttpRequest ) {
         Ajax = new XMLHttpRequest();
      } else if ( window.ActiveXObject ) {
         try {
            Ajax = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               Ajax = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         } 
      }
   }

/******
function    :  carrega;
description :  função que carrega as paginas no local especificado (<div id="conteudo"></div>);
input       :  - n  : endereço da página a ser carregada (Obs: só serão abertas páginas internas do SIV, portanto n deve ser da seguinte forma mod_usuario/show_usuarios.php);
output      :  nada;
******/
   function carrega(n, d){
      var conteudo               = document.getElementById( d );
      conteudo.innerHTML         = '<div class="carregando">loading...</div>';
      
      Ajax.open("GET", n + '&d=' + d, true);
      Ajax.onreadystatechange = function() {
         if ( Ajax.readyState == 4 ) {
            var texto            = Ajax.responseText;
            texto                = unescape(texto);
            var conteudo         = document.getElementById( d );
            conteudo.innerHTML   = texto;
         }
      }
      Ajax.send(null);
   }


/*

*/
function changepage( frm, sel, error_msg ) {
   var e = document.getElementById(frm);
   var f = document.getElementById(sel);
   if (f.value == '0') {
      e.action = 'news.php';
   } else {
      e.action = 'news.php?dj=' + f.value;
   }
   e.submit();
}



   
/*

*/
   function set_blank_gals(djs_foto, w, h) {
      var e = document.getElementById('fotoExt_gde');
      var i = document.createElement('img');
      i.setAttribute('src', 'fotos/' + djs_foto);
      i.setAttribute('width', w);
      i.setAttribute('height', h);
      e.appendChild(i);      
   }

   function change_name_gals(djs_foto, w, h) {
      var e = document.getElementById('fotoExt_gde');
      if(!e.hasChildNodes()) {
         return;
      }      
      var c = e.childNodes;
      while(c.length > 0) {
         var no = c[c.length-1];
         e.removeChild(no);
      }
      var i = document.createElement('img');
      i.setAttribute('src', 'fotos/' + djs_foto);
      i.setAttribute('width', w);
      i.setAttribute('height', h);
      e.appendChild(i);
   }

   function validamail(){
      erros = "";
      if (document.booking.txt_nome.value == ""){
         erros = erros + "Entre com seu nome\n";
      }
      if (document.booking.txt_evento.value == ""){
         erros = erros + "Entre com o evento\n";
      }
      if (document.booking.txt_data.value == ""){
         erros = erros + "Entre com a data do evento\n";
      }
      var email = document.booking.txt_email.value;
      if (document.booking.txt_email.value == ""){
         erros = erros + "Entre com seu email\n";
      } else {
         if (email.indexOf('@') == -1){
            erros = erros + "O email digitado não é válido\n";
         }
      }
      if (document.booking.txt_tel.value == ""){
         erros = erros + "Entre com seu telefone para contato\n";
      }
      if (erros == "") {
         document.booking.submit();
      }
      else {
         alert(erros);
         return false;
      }
   }
      function validacontact(){
      erros = "";
      if (document.booking.txt_nome.value == ""){
         erros = erros + "Entre com seu nome\n";
      }
      var email = document.booking.txt_email.value;
      if (document.booking.txt_email.value == ""){
         erros = erros + "Entre com seu email\n";
      } else {
         if (email.indexOf('@') == -1){
            erros = erros + "O email digitado não é válido\n";
         }
      }
      if (erros == "") {
         document.booking.submit();
      }
      else {
         alert(erros);
         return false;
      }
   }