// JavaScript Document


var dim_array = 9;
function imagens (x){
	var img = new Array(dim_array); 
	var aux = 0;
	img[0] = "imagens/cabecalho/logo0.jpg";
	img[1] = "imagens/cabecalho/logo1.jpg";
	img[2] = "imagens/cabecalho/logo2.jpg";
	img[3] = "imagens/cabecalho/logo3.jpg";
	img[4] = "imagens/cabecalho/logo4.jpg";
	img[5] = "imagens/cabecalho/logo5.jpg";
	img[6] = "imagens/cabecalho/logo6.jpg";
	img[7] = "imagens/cabecalho/logo7.jpg";
	img[8] = "imagens/cabecalho/logo8.jpg";
	if (x >= dim_array)
		aux = dim_array - 1;
	else
		aux = x;

	return img[aux];
}
function randomIMG() {
	var valor;
	if (Math.random)
		valor = Math.round(Math.random() * (dim_array-1));
	else {
		var now = new Date();
		valor = (now.getTime() / 1000) % dim_array;
	}
	return imagens(valor);
}

function change_background(color){	//altera a cor de fundo

	var fundo = document.body;
	
	fundo.style.backgroundColor = ""+ color +"";
	
	return 1;
}
//------------------------------------------------------------------------------

function getCalendarForMonth(month, year){
  	var dayOfWeekArray = new Array("D", "S", "T", "Q","Q", "S", "S")
  	var monthArray = new Array("Janeiro", "Fevereiro", 
                   "Março", "Abril", "Maio", "Junho", 
                   "Julho", "Agosto", "Setembro", 
                   "Outubro", "Novembro", "Dezembro")
  	var noDaysArray = new Array(31, 28, 31, 30, 31, 30, 
                    31, 31, 30, 31, 30, 31)
  	var firstOfMonth = new Date(month + "/1/" + year )
  	var day = - firstOfMonth.getDay()

	var currentTime = new Date()
	var today = currentTime.getDate()

	// determine number of days in month
	var noDays = noDaysArray[month-1]
	if (month == 2){
		if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0){
	  		noDays = 29
	  	}
	}

	//fabricate string for tables
	var strMonth = "<TABLE border='0' align='center' cellpadding='0' cellspacing='1' >"
	strMonth += "<TR><TD>"
	strMonth += "<TABLE border=0 cellpadding=3 cellspacing=0 align='center'>"
	strMonth += "</TR><TR bgcolor='#4CA0BA' align='center'>"
  	
	for(var i = 0; i<=6; i++){
		strMonth += "<TD width=10><FONT face='arial' color='white' size=1>"
    	strMonth += dayOfWeekArray[i] + "</FONT></TD>"
	}
  
  	strMonth += "</TR><TR align='right'>"

  	//fabricate first week of month
  	for (i = 0; i <= 6; i++){
    	strMonth += "<TD width=10><FONT face='arial' size=1 color='white'>"
    	day++
    	if(day > 0){
      		if (day == today)
				strMonth += "<span style='color:orange;'>"+day+"</span>"
			else
				strMonth += day
      	}else{
      		strMonth += " "
      	}
    	strMonth += "</FONT></TD>"
    }

  	//fabricate remaining weeks
  	for(var j=1; j < 6; j++){
    	strMonth += "</TR><TR align='right'>"
    	for (i = 0; i <= 6; i++){
      		strMonth += "<TD><FONT face='arial' size=1 color='white'>"
      		day++
      		if(day <= noDays){
				if (day == today)
        			strMonth += "<span style='color:#D3E213;'>"+day+"</span>"
				else
					strMonth += day
        	}else{
        		strMonth += " "
        	}
      		strMonth += "</FONT></TD>"
      	}
    	if (day >= noDays){
      		break;
      	}
    }
  	strMonth += "</TR></TABLE>"
  	strMonth += "</TD></TR></TABLE>"

  	return strMonth
}

function list_date(){
	var aux;
	
	<!-- Begin
	Stamp = new Date();
	year = Stamp.getYear();
	if (year < 2000) year = 1900 + year;
	aux = '' + Stamp.getDate() +"/"+(Stamp.getMonth() + 1)+ "/"+ year + '';
	var Hours;
	var Mins;
	var Time;
	Hours = Stamp.getHours();

	if (Hours == 0)
		Hours = 24;

	Mins = Stamp.getMinutes();
	if (Mins < 10)
		Mins = "0" + Mins;

	aux += '&nbsp;&nbsp;&nbsp;' + Hours + ":" + Mins + '';
	// End -->
	return aux;
}

// JavaScript Document
function toggleVisibility(me){
	if (me.style.visibility=="hidden"){
		me.style.visibility="visible";
	}else{
		me.style.visibility="hidden";
	}
}

//Create a center popup
function createwindow(url, largura, altura,Scroll,nome){
	esq = (screen.availWidth - largura ) / 2 -30;
	cim  = (screen.availHeight - altura) / 2 - 10 ;	
	janela = window.open(url,nome,"toolbar=no,width="+ largura + ",height=" + altura + ",left=" + esq + ",top=" + cim + ",scrollbars="+ Scroll +",directories=no,status=no,resize=no,menubar=no")
} 
