////////////////
// Mostra uma imagem numa nova janela, com descrição e botão para fechar. Formato portrait.
////////////////
function DisplayImage(imgFile,strText)
{			
	PreView = window.open("", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=480,height=640");
	PreView.document.open();
	PreView.document.write("<HTML><HEAD>");
	PreView.document.write("<TITLE>Visualizar a Imagem</TITLE>");
	PreView.document.write("</HEAD><BODY BGCOLOR=#FDECC8 TEXT=FFFFFF>");
	PreView.document.write("<p align='center'> <img src='" + imgFile + "' width='400' height='400' ><br><br>");
	PreView.document.write("<font face='verdana,tahoma' color=#000000 size=2>" + strText + "</font>");
	PreView.document.write("<FORM><CENTER><INPUT TYPE='button' VALUE='Fechar' " + "onClick='window.close()'></CENTER></FORM>");
	PreView.document.write("</CENTER>");
	PreView.document.write("</BODY></HTML>");
	PreView.document.focus();
	PreView.document.close();
}
////////////////
// Mostra um comentário simples
////////////////
function MostraComentario(strText)
{			
	PreView = window.open("", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=320,height=240");
	PreView.document.open();
	PreView.document.write("<HTML><HEAD>");
	PreView.document.write("<TITLE>O que significa...</TITLE>");
	PreView.document.write("</HEAD><BODY BGCOLOR=#FDECC8 TEXT=FFFFFF>");
	PreView.document.write("<font size=2 face='Verdana, Arial, Helvetica, sans-serif' Color=#000000><div align='justified'>" + strText + "<div align='justified'></Font>");
	PreView.document.write("<FORM><CENTER><INPUT TYPE='button' VALUE='Fechar' " + "onClick='window.close()'></CENTER></FORM>");
	PreView.document.write("</CENTER>");
	PreView.document.write("</BODY></HTML>");
	PreView.document.focus();
	PreView.document.close();
}

// Mostra uma imagem numa nova janela, com descrição e botão para fechar. A orientação pode ser Portrait*/
// ou landscape, definido por um parametro ('P' ou 'L')
function DisplayImage(imgFile,strText,Orientation)
{			
	if(Orientation == "P")
	{
		PreView = window.open("", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=580,height=640");
	}
	else
	{
		PreView = window.open("", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=650,height=490");
	}
	PreView.document.open();
	PreView.document.write("<HTML><HEAD>");
	PreView.document.write("<TITLE>Visualizar a Imagem</TITLE>");
	PreView.document.write("</HEAD><BODY BGCOLOR=#FDECC8 TEXT=FFFFFF>");
	if(Orientation == "P")
	{
		PreView.document.write("<p align='center'> <img src='" + imgFile + "' width='500' height='550' ><br><br>");
	}
	else
	{
		PreView.document.write("<p align='center'> <img src='" + imgFile + "' width='640' height='480' ><br><br>");
	}
	PreView.document.write("<font face='Verdana, Tahoma' size='2' color='000000'>" + strText + "</font>");
	PreView.document.write("<FORM><CENTER><INPUT TYPE='button' VALUE='Fechar' " + "onClick='window.close()'></CENTER></FORM>");
	PreView.document.write("</CENTER>");
	PreView.document.write("</BODY></HTML>");
	PreView.document.focus();
	PreView.document.close();
}

////////////////
// Mostra uma imagem numa nova janela, com descrição e botão para fechar. Formato grande.
////////////////
function DisplayImageLarge(imgFile,strText)
{			
	PreView = window.open("", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=800,height=700");
	PreView.document.open();
	PreView.document.write("<HTML><HEAD>");
	PreView.document.write("<TITLE>Visualizar a Imagem</TITLE>");
	PreView.document.write("</HEAD><BODY BGCOLOR=#FDECC8 TEXT=FFFFFF>");
	PreView.document.write("<p align='center'> <img src='" + imgFile + "' width='750' height='585' ><br><br>");
	PreView.document.write("<font face='verdana,tahoma' color=#000000 size=2>" + strText + "</font>");
	PreView.document.write("<FORM><CENTER><INPUT TYPE='button' VALUE='Fechar' " + "onClick='window.close()'></CENTER></FORM>");
	PreView.document.write("</CENTER>");
	PreView.document.write("</BODY></HTML>");
	PreView.document.focus();
	PreView.document.close();
}

/************************************************************************/
// Rise and Set times of the Sun
/************************************************************************/
var MyPI = 3.1415926535897932384626433832795;
var RADEG = 180/MyPI;
var DEGRAD = MyPI/180;

//var RADEG = 1;
//var DEGRAD = 1;

// SunTimes Fucntion
// Computes the sunrise and sunset times.
function SunTimes (strYear, strMonth, strDay, longitude, latitude, TZ, isdst)
{
	var d;
	var N; 
	var i; 
	var w; 
	var M; 
	var M_tmp;
	var L; 
	var e;
	var e1; 
	var a;
	var xv; 
	var yv; 
	var v;
	var xs; 
	var ys; 
	var xe;
	var ecl;
	var lonsun; 
	var ye; 
	var ze; 
	var ra;
	var dec;
	var h;
	var GMST0;
	var UT_Sun_in_south;
	var LHA;
	var hour_rise;
	var hour_set;
	var min_rise;
	var min_set;
	
	// calculate days since 2000 jan 1
	d = ( 367 * (strYear) - parseInt((7 * ((strYear) + (((strMonth) + 9) / 12))) / 4) + parseInt((275 * (strMonth)) / 9) + (strDay) - 730530);
	
	// Orbital elements of the Sun:
	N = 0.0;
	i = 0.0;
	w = 282.9404 + (0.0000470935 * d);
	a = 1.000000;
	e = 0.016709 - (1.151E-9 * d);
	M_tmp = 356.0470 + (0.9856002585 * d);
	M = rev(M_tmp);
	ecl = 23.4393 - (3.563E-7 * d);
	L = w + M;
	if (L < 0 || L > 360)
	{	
		L = rev(L);
	}
	
	// position of the Sun
	E1 = M + e*(180/MyPI) * Math.sin(M * DEGRAD) * ( 1.0 + e * Math.cos(M * DEGRAD) );
	xv = Math.cos(E1 * DEGRAD) - e;
	yv = Math.sqrt(1.0 - e * e) * Math.sin(E1 * DEGRAD);
	//v = RADEG * Math.atan2(yv, xv);
	v = RADEG * MyAtan2(yv, xv);
	r = Math.sqrt(xv * xv + yv * yv);
	lonsun = v + w;
	if (lonsun < 0 || lonsun > 360)
	{
		lonsun = rev(lonsun);
	}

	xs = r * Math.cos(lonsun * DEGRAD);
	ys = r * Math.sin(lonsun * DEGRAD);
	xe = xs;
	ye = ys * Math.cos(ecl * DEGRAD);
	ze = ys * Math.sin(ecl * DEGRAD);
	RA = RADEG * Math.atan2(ye, xe);
	//Dec = RADEG * Math.atan2(ze, (Math.sqrt((xe * xe)+(ye * ye))));
	Dec = RADEG * MyAtan2(ze, (Math.sqrt((xe * xe)+(ye * ye))));

	h=-0.833;
	GMST0 = L + 180;
	if (GMST0 < 0 || GMST0 > 360)
	{
		GMST0 = rev(GMST0);
	}
	UT_Sun_in_south = ( RA - GMST0 - longitude ) / 15.0;
	if (UT_Sun_in_south < 0)
	{
		UT_Sun_in_south=UT_Sun_in_south + 24;
	}
	

	LHA= (Math.sin(h * DEGRAD) - (Math.sin(latitude * DEGRAD) * Math.sin(Dec  * DEGRAD)))/(Math.cos(latitude * DEGRAD) * Math.cos(Dec * DEGRAD));
	if (LHA > -1 && LHA < 1)
	{
		//LHA = (RADEG * Math.acos(LHA))/15;
		LHA= (RADEG * MyAcos(LHA))/15;
	}
	else
	{
		SunTimes = "No sunrise,No sunset";
		return;
	}	
	
	hour_rise=UT_Sun_in_south - LHA;
	hour_set=UT_Sun_in_south + LHA;
	min_rise=parseInt((hour_rise-parseInt(hour_rise)) * 60);
	min_set=parseInt((hour_set-parseInt(hour_set)) * 60);
	hour_rise=(parseInt(hour_rise) + (TZ + isdst));
	hour_set=(parseInt(hour_set) + (TZ + isdst));
	if (min_rise < 10)
	{
		//min_rise = right("0000" + min_rise, 2);
	}
	if (min_set < 10)
	{	
		//min_set = right("0000" + min_set, 2);
	}

	var tmpSunTimes;
	tmpSunTimes = hour_rise + ":" + min_rise + "," + hour_set + ":" + min_set;
	return tmpSunTimes;
}

// Supp||t functions

function rev(qqq)
{
	var x;
	x = (qqq - (parseInt((qqq/360.0)) * 360.0));
	if (x <= 0)
	{
		x = x + 360;
	}
	return x;
}

// To compute Atan2
function MyAtan2(ys,xs)
{
	// from the Draw Arrows tip
	// @ http://www.devx.com/upload/free/features/VBPJ/techtips/techtips11.pdf
	// by —Jim Deutch, Syracuse, New Y||k
	var theta;
	if (xs != 0)
	{
		theta = Math.atan(ys / xs);
		if (xs < 0)
		{
			theta = theta + MyPI;
		}
	}
	else
	{
		if (ys < 0)
		{
			theta = 3 * MyPI / 2; //90;
		}
		else
		{
			theta = MyPI / 2; //270
		}
	}
	return theta;
}


//To Compute Acos
function MyAcos(x)
{
	var retVAl;
	retVAl = Math.atan(-x / Math.sqrt(-x * x + 1)) + 2 * Math.atan(1);
	return retVAl;
}

/****************************************************************
Live Date Script- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use,
visit http://www.dynamicdrive.com
/*****************************************************************/
var dayarray=new Array("Domingo","Segunda-Feira","Ter&Ccedil;a","Quarta-Feira","Quinta-Feira","Sexta-Feira","S&Aacute;bado")
var montharray=new Array("Janeiro","Fevereiro","Mar&Ccedil;o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro")

function getthedate(){
	var mydate=new Date()
	var year=mydate.getYear()
	if (year < 1000)
		year+=1900
	var day=mydate.getDay()
	var month=mydate.getMonth()
	var daym=mydate.getDate()
	if (daym<10)
		daym="0"+daym
	var hours=mydate.getHours()
	var minutes=mydate.getMinutes()
	var seconds=mydate.getSeconds()
	var dn="AM"
	/*if (hours>=12)
	dn="PM"
	if (hours>12){
	hours=hours-12
	}
	if (hours==0)
	hours=12*/
	if (minutes<=9)
		minutes="0"+minutes
	if (seconds<=9)
		seconds="0"+seconds
	//change font size here
	var cdate="<font size='1' color='#FFFFFF'><b>"+dayarray[day]+", "+daym+" de "+montharray[month]+" "+year+" - "+hours+":"+minutes+":"+seconds
	+"</b></font></small>"
	if (document.all)
		document.all.clock.innerHTML=cdate
	else
		document.write(cdate)
	}
	

function goforit()
{
	if (document.all)
	setInterval("getthedate()",1000)
}