	var font = "config.xml";


	var num = -1;
	var limite;
	var src = new Array();
	var legenda = new Array();
	var linkx = new Array();

		if(navigator.appName == "Netscape"){
				function fAjax() { 

					var ajax; 
					try {
						ajax = new XMLHttpRequest(); // XMLHttpRequest para browsers mais populares, como: Firefox, Safari, dentre outros. 
					}catch(ee) { 
						try {ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS 
					}catch(e) { 
						try {ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS 
					}catch(e) {
							ajax = false; 
							}
						}
					}
			
					if(ajax){
						ajax.open("GET", font, true);
						ajax.onreadystatechange = function(){
							if(ajax.readyState == 4){
								if(ajax.status == 200){
									meuXML = ajax.responseXML;
									limite = meuXML.getElementsByTagName("imagem").length;

									for(i = 0; i < limite; i++){
										src[i] = meuXML.getElementsByTagName("imagem")[i].childNodes[1].firstChild.nodeValue;
										legenda[i] = meuXML.getElementsByTagName("imagem")[i].childNodes[3].firstChild.nodeValue;
										linkx[i] = meuXML.getElementsByTagName("imagem")[i].childNodes[5].firstChild.nodeValue;
									}

									rotation();
								}
							}
						};
						ajax.send(null);
					}
				
			
				}

			function rotation(){
				num++;
				if(num == limite){
					num = 0;
				}
				fTrocar();
				//tempo total
				tt = setTimeout(rotation, 3000);
			}
			
			
			function fTrocar(){
					document.getElementById("imgPrincipal").style.filter = "alpha(Opacity=0)";
					document.getElementById("imgPrincipal").src = src[num];
					document.getElementById("legenda").innerHTML = legenda[num];
					document.getElementById("hiperlink").href = linkx[num];
					
					fAnimacao();
				}
				
				function fAnimacao(){
					
					var opacidade = document.getElementById("imgPrincipal").style.opacity;
					
					op = parseFloat(opacidade);
					
					op += 0.1;
					
					if( op >= 1){
						clearTimeout(tempo);	
					}else{
						document.getElementById("imgPrincipal").style.opacity = ""+op;
					}
			
					tempo = setTimeout(fAnimacao, 100);
			
				}
				

			function tNum(tipo){
				if(tipo == "sub"){
					num = num - 1;
					if(num < 0){
						num = limite-1;
					}
					fTrocar();
				}
				if(tipo == "soma"){
					num = num + 1;
					if(num >= limite){
						num = 0;
					}
					fTrocar();
				}
				
										clearTimeout(tt);
						tt = setTimeout(rotation, 3000);
				if(tipo == "pause"){
					clearTimeout(tt);
				}
	
			}
		}else if(navigator.appName == "Microsoft Internet Explorer"){
			
			function iAjax() { 
					var ajax; 
					try {
						ajax = new XMLHttpRequest(); // XMLHttpRequest para browsers mais populares, como: Firefox, Safari, dentre outros. 
					}catch(ee) { 
						try {ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS 
					}catch(e) { 
						try {ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS 
					}catch(e) {
							ajax = false; 
							}
						}
					}
					
					if(ajax){
				
						ajax.open("GET", font, true);
						ajax.onreadystatechange = function(){
							if(ajax.readyState == 4){
								if(ajax.status == 200){
									meuXML = ajax.responseXML;
									limite = meuXML.getElementsByTagName("imagem").length;
			
									for(i = 0; i < limite; i++){
										src[i] = meuXML.getElementsByTagName("imagem")[i].childNodes[0].firstChild.nodeValue;
										legenda[i] = meuXML.getElementsByTagName("imagem")[i].childNodes[1].firstChild.nodeValue;
										linkx[i] = meuXML.getElementsByTagName("imagem")[i].childNodes[2].firstChild.nodeValue;
									}
									rotation();
								}
							}
						};
						ajax.send(null);
					}
				
			
				}
				
				function iTrocar(){
					document.getElementById("imgPrincipal").style.filter = "alpha(Opacity=0)";
					document.getElementById("imgPrincipal").src = src[num];
					document.getElementById("legenda").innerHTML = legenda[num];
					document.getElementById("hiperlink").href = linkx[num];
					
					iAnimacao();
				}
				
				function iAnimacao(){
					
					var opacidade = document.getElementById("imgPrincipal").style.filter;
					
					op = parseFloat(opacidade.substr(14, opacidade.indexOf(")") ) );
					
					op += 10;
					
					if( op >= 100){
						clearTimeout(tempo);	
					}else{
						document.getElementById("imgPrincipal").style.filter = "alpha(Opacity="+op+")";
					}
			
					tempo = setTimeout(iAnimacao, 100);
			
				}
				
				
				function tNum(tipo){

						if(tipo == "sub"){
							num = num - 1;
							if(num < 0){
								num = limite-1;
							}
							iTrocar();

						}
						if(tipo == "soma"){
							num = num + 1;
							if(num >= limite){
								num = 0;
							}
							iTrocar();

						}
						clearTimeout(tt);
						tt = setTimeout(rotation, 3000);
						
						if(tipo == "pause"){
							clearTimeout(tt);
						}
			
					}
					
				function rotation(){
					num++;
					if(num == limite){
						num = 0;
					}
					iTrocar();
					//tempo total
					tt = setTimeout(rotation, 3000);
				}
		}