////////////////////////////////////////////////////////////////AJAX///////////////////////////////////////////////////////////////
  var http_request = false;
  
    function makeRequest(url,funcao,isAssincrono) {	
        http_request = false;
		if(!isAssincrono){
			isAssincrono = true;
		}
		http_request=getXmlHttp();

        if (!http_request) {			
            return false;
        }else{	
			
		}	
		if(!funcao){
			funcao = defaultRequest;
		}		
        http_request.onreadystatechange = funcao;
        http_request.open('GET', url, isAssincrono);
        http_request.send(null);		
    }
	
 function getXmlHttp(){
	 if(window.XMLHttpRequest){
		 return new XMLHttpRequest();
	 } else if (window.ActiveXObject) {			 
		 var axO=['Microsoft.XMLHTTP','Msxml2.XMLHTTP','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0'];
		 for(var i=0;i<axO.length;i++){ 
			try{ 
				return new ActiveXObject(axO[i]);
				}catch(e){
					
				} 
		}
	}
 }
 
function alertContents(obj) {	
	strT = "<a target='_blank' href=\"${link}\" class=\"texto\">${titulo}</a>";
	arrCampos = new Array("${link}","${titulo}");
	var strLinks = "";
	var strTitulos = "";
	var cont = 0;
	if (http_request.readyState == 4 && http_request.status == 200){ 
		if(http_request){
			var feed = http_request.responseXML.getElementsByTagName("entry");
			for(j = 0; j < feed.length; j++){
				var feedf = feed[j].childNodes;
				for(i = 0; i < feedf.length;i++){
					if(cont == 11){
						break;
					}
					if(feedf[i].nodeType == 1){
					try{ 						
						if(feedf[i].nodeName == 'link'){ 						
							if(feedf[i].getAttribute("type") == "text/html"){
								cont++;
								strLinks += feedf[i].getAttribute("href")+"---";
							}							
						}
						if(feedf[i].nodeName == 'title'){ 
							strTitulos += sapo_replace("#","",feedf[i].firstChild.nodeValue)+'---';							
						}						
												
					}catch(e){
					
						}
					}
					
				}
				if(cont == 11){
						break;
					}
			}
				var titulos = strTitulos.split('---');
				var links = strLinks.split('---');
				
				for(i = 0; i< titulos.length-1;i++){
					var str = strT;
						str = sapo_replace(arrCampos[0],links[i],str);
						str = sapo_replace(arrCampos[1],titulos[i],str);
						obj.innerHTML +=str;
				}
			
		}
    }else if(http_request.readyState == 1){	
	
	}
}


function transform(xml,obj){
	
	//var feed = objXml.getElementsByTagName("feed");
	//alert(feed.length);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function sapo_replace(strFind,newValue,str){
	while(str.indexOf(strFind)!=-1){
			str = str.replace(strFind,newValue); 
		} 
	return str;	
}



function iniciaTwitter(idObj){
	url = 'redirect.php?param='+Math.random();
	var obj = document.getElementById(idObj);
	if(obj){
		funcao = function() {
			alertContents(obj);	
		}
		makeRequest(url,funcao);
	}
}


function verGaleria(url){
	if(url.value.length > 0){
		window.open(url.value, 'pop', 'width=785,height=630,scrollbars=yes');
	}
}

function verFoto(url){
	if(url.length > 0){
		window.open("pop_imagem.shtml?"+url, 'pop', 'width=10,height=10,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=80,left=100');
	}
}

function iniciaImagem(){
	var img = document.getElementById('imagem');
	
	if(document.all){
		window.resizeTo(img.width,img.height+60);
	}
	else{
		window.resizeTo(img.width,img.height+90);
	}
	img.style.display='none';
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
