//Copyright - 2000-2008 Alfredo J G A Borba. Todos os Direitos Reservados


//Script de Detecção do Navegador
function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1) && (agent.indexOf('firefox') == -1) && (agent.indexOf('chrome') == -1)));
    this.ns2 = (this.ns && (this.major == 3));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ns406 = (this.ns && (this.minor == 4.06));
    this.ns407 = (this.ns && (this.minor == 4.07));
    this.ns408 = (this.ns && (this.minor == 4.08));
    this.ns45 = (this.ns && (this.minor == 4.5));
    this.ns6 = (this.ns && (this.major >= 5));
    this.ie   = (agent.indexOf("msie") != -1 || agent.indexOf('firefox') != -1 || agent.indexOf('chrome') != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));    
	this.ie5  = (this.ie4 && (navigator.appVersion.indexOf('MSIE 4')==-1));
	this.ie6  = (this.ie5 && (navigator.appVersion.indexOf('MSIE 5')==-1));
	this.ie7  = (this.ie6 && (navigator.appVersion.indexOf('MSIE 6')==-1));
    this.fox = (agent.indexOf("firefox") != -1 || agent.indexOf("chrome") != -1);
	this.chr = (agent.indexOf("chrome") != -1);
    this.op3 = (agent.indexOf("opera") != -1);
	this.mac = (navigator.appVersion.indexOf("Mac")!=-1);
}

var is = new Is()
//Fim da Detecção do Navegador


//Função Para Data Determinada
function Data(tipo, dia, ms, ano, hora, minuto, segundo){

var data = new Date(ano, ms-1, dia, hora, minuto, segundo)

	switch (tipo) {
		case "" :
			return data
			
			//return dt
			break;
			
		case "diames" :
			return ((data.getDate()<10)? "0"+data.getDate() : data.getDate());		
			break;
			
		case "diasemana" :
			var diasemana = new Array(7)
			
			diasemana[0] = "Domingo"
			diasemana[1] = "Segunda-feira"
			diasemana[2] = "Ter&ccedil;a-feira"
			diasemana[3] = "Quarta-feira"
			diasemana[4] = "Quinta-feira"
			diasemana[5] = "Sexta-feira"
			diasemana[6] = "S&aacute;bado"
		
			return diasemana[data.getDay()]		
			break;
			
		case "mes" :
			var mes = new Array(12)
			mes[0] = "Janeiro"
			mes[1] = "Fevereiro"
			mes[2] = "Mar&ccedil;o"
			mes[3] = "Abril"
			mes[4] = "Maio"
			mes[5] = "Junho"
			mes[6] = "Julho"
			mes[7] = "Agosto"
			mes[8] = "Setembro"
			mes[9] = "Outubro"
			mes[10] = "Novembro"
			mes[11] = "Dezembro"
			
			return mes[data.getMonth()]		
			break;
		
		case "ano" :		
			return data.getFullYear()
			break;
			
		case "hora" :
			return ((data.getHours()<10)? "0"+data.getHours() : data.getHours());		
			break;
		
		case "minutos" :
			return ((data.getMinutes()<10)? "0"+data.getMinutes() : data.getMinutes());		
			break;
			
		case "segundos" :
			return ((data.getSeconds()<10)? "0"+data.getSeconds() : data.getSeconds());		
			break;
			
		case "tempo" :
			return data.getTime()		
			break;
		
	}
	return data
}
//Fim de Função Para Data Determinada


//Muda Data
function MudaData(op){
	if (op==0) {
		mes = new Date().getMonth()+1;
	}
	if (op==1) {
		mes--;
	}
	else if (op==2) {
		mes++;
	}
	var txt_HTML = Calend();	
	document.getElementById('calend').innerHTML = txt_HTML;
}
//Fim de Muda Data


//Construir Calendário
var ano = new Date().getFullYear();
var mes = new Date().getMonth()+1;
var dia = new Date().getDate();
function Calend(){
	var calend_html = "";
	var data_ref = new Date(ano, mes-1, dia);
	var hoje = new Date().getDate();
	var diasmeses = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var lnh = 0;
	
	if (((ano % 4 == 0) && (ano % 100 != 0)) || (ano % 400 == 0)){
	diasmeses[1] = 29;
	}
	
	numdias = diasmeses[data_ref.getMonth()];
	dia1 = data_ref;
	dia1.setDate(1);
	inicio = dia1.getDay();
	calend_html += "<table width='"+w_arg+"' border='0' cellspacing='0' cellpadding='1' bgcolor='#EEEEEE' style='font-family: Arial, Helvetica, sans-serif;'>";
	calend_html += "<tr><td colspan='7' align='center' style='background: #3366A0;'><a href=\"javascript: var novaJanela = window.open('http://www.webcalc.com.br/fr_painel.asp?pag=http://www.webcalc.com.br/datas/calendarios.html','WebCalc','toolbar=0,location=no,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=540,height=530,left=35,top=10');\"><img src='http://www.webcalc.com.br/externo/imagens/webcalc_calend_a.jpg' width='145' height='35' border='0' alt='WebCalc - Calendários'></a></td></TR>";
	calend_html += "<tr><td colspan='1' align='right' style='background: #FFCC0F;'><a href='javascript: MudaData(1);' title='Mês Anterior' style='color: #3366A0; font-weight: bold; font-size: 9pt;'>&lt;&lt;</a></td><td colspan='5' align='center' style='background: #FFCC0F;'><a href='javascript: MudaData(0);' title='Clique Para Mostrar Mês Atual' style='color: #3366A0; text-decoration : none; font-weight: bold; font-size: 9pt;'>"+Data('mes',1, mes, ano, 0, 0, 0)+"/"+Data('ano',1, mes, ano, 0, 0, 0)+"</a></td><td colspan='1' align='left' style='background: #FFCC0F;'><a href='javascript: MudaData(2);' title='Próximo Mês' style='color: #3366A0; font-weight: bold; font-size: 9pt;'>&gt;&gt;</a></td></TR>";
	calend_html += "<tr style='font-size: 9pt;'><TH>D</TH><TH>S</TH><TH>T</TH><TH>Q</TH><TH>Q</TH><TH>S</TH><TH>S</TH></TR>";
	calend_html += "<TR>";
	
	var coluna = 0;
	for (i=0; i<inicio; i++){
	calend_html += "<TD></td>";
	coluna++;
	}
	
	for (i=1; i<=numdias; i++){
	calend_html += "<td width='20' align='center' style='font-size: 9pt;";
		if (coluna==0){
			calend_html += " color: #FF0000'>";
			lnh++
			if (i == 1) lnh--
		}
		else calend_html += "'>";
	
		if (i == new Date().getDate() && mes == new Date().getMonth()+1 && ano == new Date().getFullYear()){
		calend_html += "<font style='background: #3366A0; color: #FFFFFF;'>"+i+"</font></td>";
		}
		else calend_html += i+"</td>";
	
		coluna++;
		if (coluna == 7){
		calend_html += "</TR><TR>"; 
		coluna = 0;		
		}
	}
	if (lnh == 4) {calend_html += "</TR><TR><td style='font-size: 9pt; color: #EEEEEE'>1</td></TR>";}
	calend_html += "</TABLE>";
	return calend_html;	
}
if (is.ns6 || is.ie4) {
	document.write("<div id='calend'>");
	document.write(Calend());
	document.write("</div>");
}
//Fim de Construir Calendário