var req;

function navigate(month,year) {
		
		// ----------------------------------------------------------------------------
		// Rafael - 19/11/2008
		// Troquei os nomes das variaveis para não haver problema no resto do codigo.
		// ----------------------------------------------------------------------------
		mes = month;
		ano = year;
		if ( mes == '' ){
			var dataDehoje = new Date();
			mes = (dataDehoje.getMonth() + 1);
		}
		mes = "0" + mes;
		
		if ( ano == '' ){
			var dataDehoje = new Date();
			ano = dataDehoje.getFullYear();
		}
		$("select[@name='mes'] option[@value='" +  mes.substr( (mes.length -2), mes.length ) + "']").attr("selected","selected");
		$("select[@name='ano'] option[@value='" + ano + "']").attr("selected","selected");
				
	
		// codigo do cara...
		if ( month != '' ) {
			month = "0" + month;
			month = month.substr( (mes.length -2), mes.length );
		}
				
		var url = "http://www.odiariomaringa.com.br/newCalendar.php/"+month+"/"+year;
        if(window.XMLHttpRequest) {
            req = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
        }
        req.open("GET", url, true);
        req.onreadystatechange = callback;
        req.send(null);
}

function callback() {        
        obj = document.getElementById("calendar");
        setFade(0);
        
		if(req.readyState == 4) {
                if(req.status == 200) {
                        response = req.responseText;
                        obj.innerHTML = response;
                        fade(0);
                } else {
                        alert("There was a problem retrieving the data:\n" + req.statusText);
                }
        }
}

function fade(amt) {
	if(amt <= 100) {
		setFade(amt);
		amt += 10;
		setTimeout("fade("+amt+")", 5);
    }
}

function setFade(amt) {
	obj = document.getElementById("calendar");
	
	amt = (amt == 100)?99.999:amt;
  
	// IE
	obj.style.filter = "alpha(opacity:"+amt+")";
  
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = amt/100;
  
	// Mozilla and Firefox
	obj.style.MozOpacity = amt/100;
  
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = amt/100;
}