/*    Classes desenvolvidas por Allan Graciani  */
function cDiv(tid, tclass, tcontainer) {this.obj=document.createElement("div");this.container = document.getElementById(tcontainer);this.obj.className=tclass;this.id=tid;this.obj.innerHTML="";this.container.appendChild(this.obj);}cDiv.prototype.addClass = function(tclass) {var css=this.obj.className;if (!(css.indexOf(tclass))){ css+=" " +tclass;}}
cDiv.prototype.destroy=function(){this.obj.innerHTML="";this.container.removeChild(this.obj);}
cDiv.prototype.setSize=function(twidth,theight) {this.obj.style.width=twidth+"px";this.obj.style.height=theight+"px";}
cDiv.prototype.setPosition=function(ttop,tleft) {this.obj.style.top=ttop+"px";this.obj.style.left=tleft+"px";}
cAjax = function() {
var self = this;this.query='';this.url='';this.method='GET';this.retType='text';this.returnFunction=null;this.interval=null;this.xmlDoc=null;this.xmlhttp = null;this.debug=false;this.send=_send;if (!this.xmlhttp) {	var aVersoes = ["MSXML2.XMLHttp.6.0","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp", "Microsoft.XMLHttp"];	for (var i = 0; i < aVersoes.length; i++){		try{			this.xmlhttp = new ActiveXObject(aVersoes[i]);		}catch (e) {				}	}}if (!this.xmlhttp && typeof XMLHttpRequest!='undefined') this.xmlhttp = new XMLHttpRequest();	function _testReadyState() {	if (self.xmlhttp.readyState == 4) {	if (self.xmlhttp.status == '200') {	_internalReturn(true);	} else {_internalReturn(false);}	}}function _send (turl,tquery,tmethod,trettype){	if (turl!="")		this.url=turl;	if (tquery!="")		this.query=tquery;	if (tmethod!="")		this.method=tmethod.toUpperCase();	if (trettype!=""&&typeof(trettype)!="undefined")		this.retType=trettype.toLowerCase();	if (this.xmlhttp != null) {			this.interval=setInterval(_timeout,60000);		this.xmlhttp.onreadystatechange = _testReadyState; switch( this.method.toUpperCase()) { case 'POST': this.xmlhttp.open("POST",this.url,true);								this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");	this.xmlhttp.setRequestHeader("Content-length", this.query.length); this.xmlhttp.setRequestHeader("Connection", "close");	this.xmlhttp.send(this.query);break;			default:if (this.query!='')	url=this.url+'?'+this.query;else url=this.url;	this.xmlhttp.open("GET",url,true);this.xmlhttp.send(null);	break;	}}}function _timeout(){_internalReturn(false);}function _internalReturn(status) {clearInterval(self.interval);	if(status){	self.xmlDoc = (self.retType == 'xml' ? self.xmlhttp.responseXML : self.xmlhttp.responseText);if (self.debug){var container = document.getElementsByTagName("BODY");if (container.length > 0){var newDiv = document.createElement("DIV");			newDiv.setAttribute("style", "position:absolute; width:640; left:150; top:300; background: #FFFFFF; border: 2px solid #000000");				var txt = document.createTextNode(self.xmlhttp.responseText);newDiv.appendChild(txt);container[0].appendChild(newDiv);}}}  else	self.xmlDoc=null;	if (typeof(self.returnFunction) == 'function') {eval('new self.returnFunction');}}}

function queryForm(tform){
var retStr = new Array();

for(var i = 0; i < tform.elements.length; i++){
if(!(tform.elements[i].type=="button")) {
switch(tform.elements[i].ctype){
case "file":
break;
case "check": 
var qValue = encodeURIComponent(tform.elements[i].name);
qValue += "=";
if (tform.elements[i].checked)
qValue += encodeURIComponent(tform.elements[i].value);
retStr.push(qValue);
break;
case "radio":
if (tform.elements[i].checked){
var qValue = encodeURIComponent(tform.elements[i].name);
qValue += "=";
qValue += encodeURIComponent(tform.elements[i].value);
retStr.push(qValue);		
}
break;
case "rtf":
var qValue = encodeURIComponent(tform.elements[i].name);
qValue += "=";				
qValue += encodeURIComponent(CKEDITOR.instances[tform.elements[i].name].getData());
retStr.push(qValue);						
break;
default:
if (tform.elements[i].name!="sendFile"){
var qValue = encodeURIComponent(tform.elements[i].name);
qValue += "=";
qValue += encodeURIComponent(tform.elements[i].value);
retStr.push(qValue);
}
}
}
}
return retStr.join("&");
} 
function cCalendar() {this.months=new Array("janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro");this.date=new Date() ;this.month=0;this.year=0;this.container=null;this.callback=new Function();}cCalendar.prototype.mount = function(cont,y,m){cont.innerHTML="";this.container=cont;var today=new Date();this.date=new Date();this.date.setDate(1);if(y)this.date.setFullYear(y);if(m>=0)this.date.setMonth(m);this.month=this.date.getMonth();this.year=this.date.getFullYear();var mAnt=new Date();mAnt.setDate(this.date.getDate()-1);mA=mAnt.getDate();w=this.date.getUTCDay();var self=this;var calendar=document.createElement('table');var cbody=document.createElement("tbody");calendar.width='140';calendar.border='0';calendar.cellPadding='0';calendar.cellSpacing='0';var line=document.createElement('tr');var cell=document.createElement('th');button=document.createElement('input');button.type="button";button.className="cCalendar";button.value="◄";button.onclick=function(){var dt=self.date;dt.setDate(dt.getDate()-32);self.mount(self.container,dt.getFullYear(),dt.getMonth()); }
cell.appendChild(button);line.appendChild(cell);cell=document.createElement('th');cell.colSpan=5;cell.align='center';cell.innerHTML=this.months[this.month]+' ' +this.date.getFullYear();line.appendChild(cell);cell=document.createElement('th');button=document.createElement('input');button.type="button";button.className="cCalendar";button.value="►";button.onclick=function(){ var dt=self.date;self.mount(self.container,dt.getFullYear(),dt.getMonth());}
cell.appendChild(button);line.appendChild(cell);cbody.appendChild(line);line=document.createElement('tr');line.bgColor="#eeeeee";var week=new Array('D','S','T','Q','Q','S','S');for (i in week){cell=document.createElement('th');cell.width=20;cell.innerHTML=week[i];line.appendChild(cell);}cbody.appendChild(line);line=document.createElement('tr');dc=w;for (i=0;i<w;i++){dc--;dAnt=mA-dc;cell=document.createElement('td');cell.align='center';cell.style.color="#ddd";cell.innerHTML=dAnt;line.appendChild(cell);}d=1;while (this.date.getMonth()==this.month){cell=document.createElement('td');cell.align='middle';button=document.createElement('input');button.type="button";button.className="cCalendar";button.value=d;button.onclick=function(){ self._callback(this.value-1); }
cell.appendChild(button);line.appendChild(cell);w++;if (w>6){w=0;cbody.appendChild(line);line=document.createElement('tr');}d++;this.date.setDate(this.date.getDate()+1);}d=0;if(w>0)for (i=w;i<=6;i++){d++;cell=document.createElement('td');cell.align='center';cell.style.color="#ddd";cell.innerHTML=d;line.appendChild(cell);}cbody.appendChild(line);calendar.appendChild(cbody);cont.appendChild(calendar);}
cCalendar.prototype._callback = function(n){this.callback(this.year,this.month+1,n+1);}
function eventKeyPress(e,k,f){var keynum;if(window.event) {keynum = e.keyCode;}else if(e.which) {keynum = e.which;}if(keynum==k){eval(f);}}function preloadImages() {var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function newClick(id,table,key,div){var q='t='+table+'&k='+key+'&id='+id;var xml=new cAjax();xml.returnFunction=function() {if (div&&xml.xmlDoc!='')document.getElementById(div).innerHTML=xml.xmlDoc;}
xml.send('xml/clickControl.xml.php',q,'get','text');
}function loadXMLnews(y,m,d){news=document.getElementById('dvNoticiasContainer');news.innerHTML='<div style="text-align:center;padding-top:200px;padding-bottom:200px;"><img src="imagens/loading.gif" width="32" height="32" alt="carregando notícias" /><br />carregando aguarde...</div>';if(y&&m&&d){q='d='+y+','+m+','+d+'&e='+exclude;}else{q='e='+exclude;}var newsXML=new cAjax();newsXML.returnFunction=function(){try {var canal=newsXML.xmlDoc.childNodes[0];} catch(e) {var canal=false;}if(canal){news.innerHTML="";for(i=0;i<=canal.childNodes.length;i++){try{news.innerHTML+=canal.childNodes[i].firstChild.nodeValue;}catch(e){}}}}
newsXML.send('xml/news.xml.php',q,'get','xml');}function loadXMLagenda(y,m,d){agenda=document.getElementById('dvAgendaContainer');agenda.innerHTML='<div style="text-align:center;padding-top:40px;padding-bottom:40px;"><img src="imagens/loading.gif" width="32" height="32" alt="carregando notícias" /><br />carregando aguarde...</div>';if(y&&m&&d){q='d='+y+','+m+','+d+'&e='+exclude;}else{q='';} 	var agendaXML=new cAjax(); agendaXML.returnFunction=function() { try { var canal=agendaXML.xmlDoc.childNodes[0]; } catch(e) { var canal=false; } if(canal){ agenda.innerHTML=""; for(i=0;i<=canal.childNodes.length;i++){ try{agenda.innerHTML+=canal.childNodes[i].firstChild.nodeValue;}catch(e){}}}} 
agendaXML.send('xml/agenda.xml.php',q,'get','xml');	}
