// JavaScript Document

var timerID = null;
var timerRunning = false;

function stopclock (){

        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}

function startclock () {

        stopclock();
        showtime();
}

function showtime () {

        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var timeValue = ((hours < 10) ? "0" : "") + hours
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        document.clock.brasil.value = timeValue


        var hours = now.getHours() + 4;
        var hours = ((hours >= 24)  ? hours - 24 : hours);
        var timeValue = ((hours < 10) ? "0" : "") + hours
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        document.clock.roma.value = timeValue
        timerID = setTimeout("showtime()",1000);

        timerRunning = true;

}

function MudaCor(qual) { //v2.0
var corAntiga;
var novaCor;

corAntiga = document.getElementById(qual).bgColor;
    if(corAntiga == "#fcfcfc"){
   		novaCor = "#ffffd0"; 
	}else if(corAntiga == "#f0f0f0"){
   		novaCor = "#fff8bb"; 
	}else if(corAntiga == "#ffffd0"){
  		novaCor = "#fcfcfc"; 
	}else{
		novaCor = "#f0f0f0";
	};
document.getElementById(qual).bgColor = novaCor;
}

function ConfirmaExclusao() { //v2.0
if (confirm('Deseja realmente excluir as enquetes selecionadas?')) {
document.form1.submit();
}
}

var slideShowSpeed = 4000
var crossFadeDuration = 3
var Pic = new Array()

Pic[0] = 'imagens/img_topo_recife.jpg'
Pic[1] = 'imagens/img_topo_joao_pessoa.jpg'
Pic[2] = 'imagens/img_topo_aracaju.jpg'
Pic[3] = 'imagens/img_topo_maceio.jpg'
Pic[4] = 'imagens/img_topo_natal.jpg'
Pic[5] = 'imagens/img_topo_fortaleza.jpg'
Pic[6] = 'imagens/img_topo_teresina.jpg'
Pic[7] = 'imagens/img_topo_sao_luis.jpg'
Pic[8] = 'imagens/img_topo_macapa.jpg'
Pic[9] = 'imagens/img_topo_belem.jpg'
Pic[10] = 'imagens/img_topo_manaus.jpg'
Pic[11] = 'imagens/img_topo_boavista.jpg'

var t
var g = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=5)"
	  document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[g].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   g = g + 1
   if (g > (p-1)) g=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' : Digite seu e-mail corretamente.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' : campo obrigatório.\n'; }
  } if (errors) alert('Verifique os seguintes campos:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function PopUp(endereco, tamanho){
	window.open(""+endereco+"","Pop",""+tamanho+", scrollbars=yes");
	void(0);
}
