http_request = false;
var tempo = 0;
var eme=0;
err=false;
var imagensp = new Array();
function preloading(){
for (x=0; x<preloading.arguments.length; x++){
imagensp[x] = new Image();
imagensp[x].src = preloading.arguments[x];
}
}
preloading(
"/imagens/preload.gif",
"/imagens/b3.gif",
"/imagens/smiles/icon_biggrin.gif",
"/imagens/smiles/icon_smile.gif",
"/imagens/smiles/icon_sad.gif",
"/imagens/smiles/icon_eek.gif",
"/imagens/smiles/icon_confused.gif",
"/imagens/smiles/icon_cool.gif",
"/imagens/smiles/icon_lol.gif",
"/imagens/smiles/icon_mad.gif",
"/imagens/smiles/icon_razz.gif",
"/imagens/smiles/icon_redface.gif",
"/imagens/smiles/icon_cry.gif",
"/imagens/smiles/icon_evil.gif",
"/imagens/smiles/icon_twisted.gif",
"/imagens/smiles/icon_rolleyes.gif",
"/imagens/smiles/icon_wink.gif",
"/imagens/smiles/b.gif",
"/imagens/smiles/i.gif",
"/imagens/smiles/icon_mrgreen.gif",
"/imagens/10.gif"
);


function set_nick (args)
{
		var comeca = new Date();
		var termina = new Date ();
		termina.setTime (comeca.getTime() + 3600000*24*30);
		ncck = escape(args);
		document.cookie = "meunick =" + ncck + "; expires=" + termina.toGMTString() + "; path=/;";
}


function ler(ocont,dur,ext,titt){
var sps="mimg"+ocont;
var memb="memb1"+ocont;



var version = deconcept.SWFObjectUtil.getPlayerVersion();
if (document.getElementById && version["major"] < 9) {
document.getElementById(sps).innerHTML ='<br /><br /><br /><br />Versão detectada do seu Flash Player: '+ version["major"] +'.'+ version['minor'] +'<br />Este conteúdo requer o Flash Player 9.0 ou superior.<br /><b><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" target="_blank">Download da Última Versão do Flash Player</a></b><br /><br />Depois de fazer o Download actualize a página.<br /><br /><div align="left">Se após os passos acima continuar a ver esta mensagem, certifique-se que o javascript está activado nas opções do seu browser.<br />Em último caso, poderá ter um problema no seu sistema com o plugin do seu Flash Player, faça o download do <a href="http://www.adobe.com/go/tn_14157" target="_blank">Flash uninstall</a> e desinstale o Flash Player, voltando a instalar de seguida <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" target="_blank">Aqui</a>.<br /><br /><br /><br /><hr></div>';
}
else{
if(dur==4){
var so = new SWFObject("/leitor.swf", "leitor", "590", "469", "9", "");
}
else if(dur==3 || dur==0){
var so = new SWFObject("/ler.swf", "leitor", "470", "427", "9", "");	
}
else if(dur==10){
var so = new SWFObject("/leitor9.swf", "leitor", "590", "359", "9", "");
}
else{
var so = new SWFObject("/ler9.swf", "leitor", "590", "408", "9", "");	
}

so.addVariable("ler", ext);
so.addVariable("zzz", dur);
so.addVariable("xvolume", 100);
so.addVariable("titt", titt);
so.addVariable("exte", ext);
so.addParam("allowscriptaccess","always");
so.addParam("allowFullScreen", "true");
so.write(sps);
//if(ext != 'land'){
document.getElementById(memb).style.display ='';
//}
var uri="/visu.php?id="+ocont;
makeRequest(uri,"");
}
}


function emb(ocont,ek,idv){
var emb="emb"+ek+""+ocont;
var memb="memb"+ek+""+ocont;
var zemb="zemb"+ocont;
document.getElementById(memb).style.display ='none';
document.getElementById(emb).style.display ='';
document.getElementById(zemb).value ='<embed src="http://sorisomail.com/vid/'+idv+'/" type="application/x-shockwave-flash" wmode="transparent" width="470" height="380"></embed>';
}

function mod(ocont,mrz,p,z){
if(p !=1){
var emb="emb2"+ocont;
}
else{
var emb="emb3"+ocont;
}

if(z==1){
var aviso='<br><br>(Comentário Apagado)<br>';
}
else if(z==2){
var aviso='<br><br>(Comentário Oculto)<br>';
}
else if(z==3){
var aviso='<br><br>(Comentário Reposto)<br>';
}

document.getElementById(emb).innerHTML =aviso;
var uri="/mod.php?id="+ocont+"&m="+mrz+"&tp="+z;
makeRequest(uri,"");
}



function favor(id,fu,tip){
var uri="/metfav.php?id="+id+"&tip="+tip+"&fu="+fu;
makeRequest(uri,id);
}



function user(ocont,mrz,cjq){
var minges="minges"+cjq+""+mrz+""+ocont;
document.getElementById(minges).innerHTML ='Marcado como ofensivo';
var uri="/denun.php?id="+ocont+"&m="+mrz;
makeRequest(uri,"");
}



function user2(ocont,mrz){
var uri="/mcat.php?id="+ocont+"&m="+mrz;
makeRequest(uri,"");
}

function mouseover(ocont,ek,df){
var ofen="ofend"+ek+""+ocont;
if(df==1){
document.getElementById(ofen).style.display ='';
}
else{
document.getElementById(ofen).style.display ='none';	
}
}

function mvisus(idvi){
var uri="/visu.php?id="+idvi;
makeRequest(uri,"");
}

//function responder(idresposta){
//var resdiv="responde"+idresposta;
//document.getElementById(resdiv).style.display ='';
//}


function lermed(ocont, exte, ntp){
var spsz="mimgz"+ocont;
var spsx="mimgx"+ocont;
var sps="mimg"+ocont;
testa=ocont;
var version = deconcept.SWFObjectUtil.getPlayerVersion();
if (document.getElementById && version["major"] < 8) {
document.getElementById(sps).innerHTML ='<br /><br /><br /><br />Versão detectada do seu Flash Player: '+ version["major"] +'.'+ version['minor'] +'<br />Este conteúdo requer o Flash Player 8.0 ou superior.<br /><b><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" target="_blank">Download da Última Versão do Flash Player</a></b><br /><br />Depois de fazer o Download actualize a página.<br /><br />';
}
else{
if(ntp==0){

if(ocont>11477){
//var media="http://sorisomail.cadsr.com/media/lerpps.swf";
var media="/media/lerpps.swf";
}
else{
var media="/media/lerpps.swf";
}

var so = new SWFObject(media, "", "590", "442", "8", "");
so.addVariable("dpps", exte);
so.addVariable("vdr", "12");
}
else{
var media="/media/"+exte+".swf";
var so = new SWFObject(media, "", "590", "429", "8", "");	
}
so.addVariable("cdp", "150");
so.addParam("allowFullScreen", "true");
so.addParam("allowScriptAccess", "always"); 
so.addVariable("tamanho", "full");
so.write(sps);
if(eme !=1){
document.getElementById(spsz).style.display ='none';
document.getElementById(spsx).style.display ='';
}
uri="/visu.php?id="+ocont;
makeRequest(uri,"");
}

}

function apaga(ocont){
var sps="mimg"+ocont;
document.getElementById(sps).style.display ='none';
}

function lerimg(ocont, exte,vis){
var spsz="mimgz"+ocont;
var spsx="mimgx"+ocont;
var sps="mimg"+ocont;
var imagem="/media/"+exte+".jpg";
if(vis==1){
var visas="visualização";
}
else{
var visas="visualizações";	
}
img='<div align="right" class="tab2">'+vis+' '+visas+' </div><img src="'+imagem+'" class="borda">';
document.getElementById(sps).innerHTML =img;
document.getElementById(spsz).style.display ='';
document.getElementById(spsx).style.display ='none';
}


function openTargete (form, features, windowName) {
if (!windowName)
windowName = 'Email' + (new Date().getTime());
form.target = windowName;
open ('', windowName, features);
}

function popup(gpid){   
open('/download.php?id='+gpid+'&m=1','3G','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=250,height=240');
}
function popupp(gpid){   
open('/downloadp.php?id='+gpid+'&z='+testa+'&m=1','PPS','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=250,height=200');
}


function makeRequest(urlc,zona) {
zon=zona;

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml; charset=iso-8859-1');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        if(zona != ""){
		eme=1;
		http_request.onreadystatechange = alertCon;
		
		}
		
		
		
        http_request.open('GET', urlc, true);
		http_request.send(null);


    }
	
	function alertCon() {
	if (http_request.readyState == 4) {
	if (http_request.status == 200) {
		
		result = http_request.responseText;
		
		
		//document.getElementById(zon).innerHTML = result;				
		var embf="embf"+zon;
		document.getElementById(embf).innerHTML = result;
	}
		
	}
	
	
	}
function ancho(anc) {
document.location="#"+anc;
}


function makePOSTRequest(urlm, parameters,idcoment,tip) {

urlmz=urlm;
parametersz=parameters;
idcomentz=idcoment;
tipos=tip;
	comentsc = "comentario"+idcoment;
	metc="coment"+idcoment;
	inform="inform"+idcoment;
	if(tip != 2){
		comentsz="coments"+idcoment;
		document.getElementById(comentsc).focus();
		//document.getElementById(inform).innerHTML = mesp;
		document.getElementById(comentsz).style.display ='none';
		
		}
	else{
		comentsz="mimg"+idcoment;
		}

	if(tip==1){
		document.getElementById(metc).style.display ='none';
		}

		
     http_request = false;

	  
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/html');
			http_request.overrideMimeType('text/html; charset=iso-8859-1'); 
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
	  

      http_request.onreadystatechange = alertContents;
	  if(parameters==0){
	  http_request.open('GET', urlm, true);
	  //http_request.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=iso-8859-1");
	  http_request.send(null);
	  }
	  else{
	   http_request.open('POST', urlm, true);
	   http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   http_request.setRequestHeader("Content-length", parameters.length);
	   //http_request.setRequestHeader("Connection", "close");
	   http_request.send(parameters);
	  }
	  requestTimer = setTimeout(function() {
      http_request.abort();
	  //alert("abortou")
	  var uri="/erros.php?er=1";
	  makeRequest(uri,"");
      }, 20000);
	  
   }

erros=false;

function alertContents() {
	
if (http_request.readyState == 1) {
var estado='A enviar pedido...';	
}
else if (http_request.readyState == 2) {
var estado='Pedido recebido...';	
}
else if (http_request.readyState == 3) {
var estado='A processar...';	
}
else{
var estado='';	
}
var mesp='<center><b><font color="#000000">'+estado+'</font></b> <img src="/imagens/preload.gif" width="94" height="17" border="0" align="absmiddle" /></center><br /><br />';
document.getElementById(inform).innerHTML = mesp;
if (http_request.readyState == 4 || http_request.readyState == 0) {
clearTimeout(requestTimer);
if (http_request.status == 200) {
erros=false;
err=false;
if(tipos != 2){
document.getElementById(comentsz).style.display ='';
document.getElementById(inform).innerHTML ='';
}
result = http_request.responseText;
document.getElementById(comentsz).innerHTML = result; 
http_request.abort();
} 
else {

http_request.abort();
err=true;
erros=false;

document.getElementById(metc).style.display ='';
document.getElementById(comentsz).style.display ='';
document.getElementById(comentsz).innerHTML = ''; 
document.getElementById(inform).innerHTML = '<center>O limite do tempo de resposta expirou.<br /><b>Tente Novamente</b></center>';	
var uri="/erros.php?er=2";
makeRequest(uri,"");
}


}



}

   
   function pass(id,zz) {
    url='url'+id;
	if(zz==1){
	var inforc="inforc"+id
	document.getElementById(inforc).style.display ='';
	document.getElementById(url).value='';
	document.getElementById(url).focus();
	}
	else{
	//document.getElementById(url).focus();
	document.location="#marca"+id;
   }
   }

   
   
   function get(obj,resid,idc,tp) {
	   var contasml=0;
	   var nome="nome"+idc
	   var comentario="comentario"+idc
	   var com_id="com_id"+idc
	   var envia="envia"+idc
	   var url="url"+idc
	   var resposta="resposta"+idc
	   var apg="apg"+idc
	   var inform="inform"+idc
	   document.getElementById(inform).style.display ='';
	   document.getElementById(inform).innerHTML = '';
	   var com_ids='com_id='+idc;
	   var comtemp=document.getElementById(comentario).value.replace(/€/g, "&euro;");
					
	  var poststr = "nome=" + encodeURIComponent( document.getElementById(nome).value ) +
                    "&comentario=" + encodeURIComponent( comtemp ) +
					"&com_id=" + encodeURIComponent( document.getElementById(com_id).value ) +
					"&url=" + encodeURIComponent( document.getElementById(url).value ) +
					"&resposta=" + encodeURIComponent( document.getElementById(resposta).value ) +
					"&envia=" + encodeURIComponent( document.getElementById(envia).value ) +
					"&apg=" + encodeURIComponent( document.getElementById(apg).value );
					
if(document.getElementById(comentario).value.length>1){
relogio = new Date();
agora = relogio.getTime();
}

var divide = document.getElementById(comentario).value.split(" ");

for(i=0; i!=divide.length; i++){

if(divide[i].length>75){
var exede=true;
}
 
}

if(exede){
alert("Não pode colocar palavras ou endereços demasiado extensos.");
}
else if(document.getElementById(comentario).value.length<2){
document.getElementById(inform).innerHTML = 'Você não comentou.';
document.getElementById(comentario).focus();
}
else if(document.getElementById(nome).value.length>40){
document.getElementById(inform).innerHTML = 'O Nome/Nick não pode conter mais de 40 caracteres.';
}
else if(document.getElementById(comentario).value.length>2000){
totalc=document.getElementById(comentario).value.length;
document.getElementById(inform).innerHTML = 'O comentário contem '+totalc+' caracteres e não pode exceder os 2000 caracteres.';
}
else if(tempo+8000 > agora && document.getElementById(url).value.length<1 && !err){
diferenca=Math.round(9-((agora-tempo)/1000));
document.getElementById(inform).innerHTML = 'Não pode enviar comentários em tão curto espaço de tempo. Espere '+diferenca+' segundos';
}
else{
	
if(document.getElementById(nome).value.length>1){
set_nick (document.getElementById(nome).value);
}
		
relogio = new Date();
tempo = relogio.getTime();
if (tp ==5){
var aurl='/comentarios.php?quant=100';
tp=1;	
}
else{
var aurl='/comentarios.php';	
}

if (resid >0){
makePOSTRequest(aurl, poststr, resid,tp);
obj.parentNode.parentNode.removeChild(obj.parentNode);
}
else{  
makePOSTRequest(aurl, poststr, idc,tp);
}

}


}

function confirma(idf) {
	   var inform="inform"+idf
	   var nik="nome"+idf;
	   var site="url"+idf;
	   var comenta="comentario"+idf;
	   document.getElementById(inform).style.display ='';
	   document.getElementById(inform).innerHTML = '<font color="#009933">Comentário Adicionado.</font>';
	   document.getElementById(nik).value ='';
   	   document.getElementById(site).value ='';
   	   document.getElementById(comenta).value ='';
   
   }
   



function responder(resid, cache, comr){
var mete="formr"+comr;
var inform="inform"+comr
var sml="sml"+comr;

document.getElementById(mete).innerHTML ='<div align="left" style="font-size:10px;"><hr><form name="formc'+comr+'" id="formc'+comr+'" action="javascript:get(document.getElementById("formc'+comr+'"));\"><table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td><font color="#FF0000">*</font> Nome/Nick:</td><td><input class="texta" style="width:150px;" name="nome" id="nome'+comr+'" type="text" onClick="metenick(\''+comr+'\')" /></td></tr><tr><td valign="top"><font color="#FF0000">*</font> Resposta: <div id="'+sml+'" align="center" style="border-top: 1px solid #000000; padding-top: 1px; display: none;"></div></td><td><textarea class="texta" rows="4" style="width:450px;" id="comentario'+comr+'" onClick="abresml(\''+comr+'\')"></textarea><input id="com_id'+comr+'" type="hidden" value="'+resid+'" /><input name="url" id="url'+comr+'" type="hidden" value="" /><input id="envia'+comr+'" type="hidden" value="sim" /><input id="resposta'+comr+'" type="hidden" value="'+comr+'" /><input name="apg" id="apg'+comr+'" type="hidden" value="'+cache+'" /><br /><input type="button" name="button" class="buton3" onclick="javascript:get(this.parentNode,'+resid+','+comr+',1);"> <span id="'+inform+'" style="color:#FF0000;"></span></td></tr></table></form></div>';
//this.parentNode.parentNode.removeChild(this.parentNode);
}

function mudar(comre){
var formra="formra"+comre;
var formr="formr"+comre;
document.getElementById(formr).style.display ='none';
document.getElementById(formra).style.display ='';
}

function metenick(metenk){
var mtnk="nome"+metenk;
if(document.getElementById(mtnk).value.length<1){
cookie_nick="meunick";
var resultado = document.cookie.match ( cookie_nick + "=(.*?)(;|$)" );
if ( resultado ){
document.getElementById(mtnk).value = ( unescape ( resultado[1] ) );
}
}
}

function abresml(smlid){
contasml=0;
var sml="sml"+smlid;
var comentario="comentario"+smlid;
document.getElementById(sml).style.display ='';
if(document.getElementById(comentario).value.length<1){
document.getElementById(sml).innerHTML ='<a href="javascript:metesmile(\':D\','+smlid+')"><img border="0" src="/imagens/smiles/icon_biggrin.gif"></a> <a href="javascript:metesmile(\':)\','+smlid+')"><img border="0" src="/imagens/smiles/icon_smile.gif"></a> <a href="javascript:metesmile(\':lol:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_lol.gif"></a> <a href="javascript:metesmile(\':8)\','+smlid+')"><img border="0" src="/imagens/smiles/icon_cool.gif"></a><br /><a href="javascript:metesmile(\':???:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_confused.gif"></a> <a href="javascript:metesmile(\':shock:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_eek.gif"></a> <a href="javascript:metesmile(\':(\','+smlid+')"><img border="0" src="/imagens/smiles/icon_sad.gif"></a> <a href="javascript:metesmile(\':x\','+smlid+')"><img border="0" src="/imagens/smiles/icon_mad.gif"></a><br /><a href="javascript:metesmile(\':cry:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_cry.gif"></a> <a href="javascript:metesmile(\':oops:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_redface.gif"></a> <a href="javascript:metesmile(\':evil:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_evil.gif"></a> <a href="javascript:metesmile(\':twisted:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_twisted.gif"></a><br /><a href="javascript:metesmile(\':roll:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_rolleyes.gif"></a> <a href="javascript:metesmile(\':wink:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_wink.gif"></a> <a href="javascript:metesmile(\':mrgreen:\','+smlid+')"><img border="0" src="/imagens/smiles/icon_mrgreen.gif"></a> <a href="javascript:metesmile(\':P\','+smlid+')"><img border="0" src="/imagens/smiles/icon_razz.gif"></a>';
}



var mtnk="nome"+smlid;
if(document.getElementById(mtnk).value.length<1){
cookie_nick="meunick";
var resultado = document.cookie.match ( cookie_nick + "=(.*?)(;|$)" );
if ( resultado ){
document.getElementById(mtnk).value = ( unescape ( resultado[1] ) );
}
}

}



contasml=0;
function metesmile(string, smlid){
contasml++;
var comentario="comentario"+smlid
if(contasml<3){
document.getElementById(comentario).value = document.getElementById(comentario).value + " "+string+" ";
document.getElementById(comentario).focus();
}
}
limpconf=true;
function limpa(){
if(limpconf){
document.getElementById("emailn").value = "";
limpconf=false;
}
}








/*
   Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
   of Simon Willison (see comments by Simon below).

   Description:
   	
   	Uses css selectors to apply javascript behaviours to enable
   	unobtrusive javascript in html documents.
   	
   Usage:   
   
	var myrules = {
		'b.someclass' : function(element){
			element.onclick = function(){
				alert(this.innerHTML);
			}
		},
		'#someid u' : function(element){
			element.onmouseover = function(){
				this.innerHTML = "BLAH!";
			}
		}
	};
	
	Behaviour.register(myrules);
	
	// Call Behaviour.apply() to re-apply the rules (if you
	// update the dom, etc).

   License:
   
   	This file is entirely BSD licensed.
   	
   More information:
   	
   	http://ripcord.co.nz/behaviour/
   
*/   

var Behaviour = {
	list : new Array,
	
	register : function(sheet){
		Behaviour.list.push(sheet);
	},
	
	start : function(){
		Behaviour.addLoadEvent(function(){
			Behaviour.apply();
		});
	},
	
	apply : function(){
		for (h=0;sheet=Behaviour.list[h];h++){
			for (selector in sheet){
				list = document.getElementsBySelector(selector);
				
				if (!list){
					continue;
				}

				for (i=0;element=list[i];i++){
					sheet[selector](element);
				}
			}
		}
	},
	
	addLoadEvent : function(func){
		var oldonload = window.onload;
		
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}
}

Behaviour.start();

/*
   The following code is Copyright (C) Simon Willison 2004.

   document.getElementsBySelector(selector)
   - returns an array of element objects from the current document
     matching the CSS selector. Selectors can contain element names, 
     class names and ids and can be nested. For example:
     
       elements = document.getElementsBySelect('div#main p a.external')
     
     Will return an array of all 'a' elements with 'external' in their 
     class attribute that are contained inside 'p' elements that are 
     contained inside the 'div' element which has id="main"

   New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
   See http://www.w3.org/TR/css3-selectors/#attribute-selectors

   Version 0.4 - Simon Willison, March 25th 2003
   -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
   -- Opera 7 fails 
*/

function getAllChildren(e) {
  // Returns all children of element. Workaround required for IE5/Windows. Ugh.
  return e.all ? e.all : e.getElementsByTagName('*');
}

document.getElementsBySelector = function(selector) {
  // Attempt to fail gracefully in lesser browsers
  if (!document.getElementsByTagName) {
    return new Array();
  }
  // Split selector in to tokens
  var tokens = selector.split(' ');
  var currentContext = new Array(document);
  for (var i = 0; i < tokens.length; i++) {
    token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
    if (token.indexOf('#') > -1) {
      // Token is an ID selector
      var bits = token.split('#');
      var tagName = bits[0];
      var id = bits[1];
      var element = document.getElementById(id);
      if (tagName && element.nodeName.toLowerCase() != tagName) {
        // tag with that ID not found, return false
        return new Array();
      }
      // Set currentContext to contain just this element
      currentContext = new Array(element);
      continue; // Skip to next token
    }
    if (token.indexOf('.') > -1) {
      // Token contains a class selector
      var bits = token.split('.');
      var tagName = bits[0];
      var className = bits[1];
      if (!tagName) {
        tagName = '*';
      }
      // Get elements matching tag, filter them for class selector
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue; // Skip to next token
    }
    // Code to deal with attribute selectors
    if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
      var tagName = RegExp.$1;
      var attrName = RegExp.$2;
      var attrOperator = RegExp.$3;
      var attrValue = RegExp.$4;
      if (!tagName) {
        tagName = '*';
      }
      // Grab all of the tagName elements within current context
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      var checkFunction; // This function will be used to filter the elements
      switch (attrOperator) {
        case '=': // Equality
          checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
          break;
        case '~': // Match one of space seperated words 
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
          break;
        case '|': // Match start with value followed by optional hyphen
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
          break;
        case '^': // Match starts with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
          break;
        case '$': // Match ends with value - fails with "Warning" in Opera 7
          checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
          break;
        case '*': // Match ends with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
          break;
        default :
          // Just test for existence of attribute
          checkFunction = function(e) { return e.getAttribute(attrName); };
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (checkFunction(found[k])) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
      continue; // Skip to next token
    }
    
    if (!currentContext[0]){
    	return;
    }
    
    // If we get here, token is JUST an element (not a class or ID selector)
    tagName = token;
    var found = new Array;
    var foundCount = 0;
    for (var h = 0; h < currentContext.length; h++) {
      var elements = currentContext[h].getElementsByTagName(tagName);
      for (var j = 0; j < elements.length; j++) {
        found[foundCount++] = elements[j];
      }
    }
    currentContext = found;
  }
  return currentContext;
}

/* That revolting regular expression explained 
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
  \---/  \---/\-------------/    \-------/
    |      |         |               |
    |      |         |           The value
    |      |    ~,|,^,$,* or =
    |   Attribute 
   Tag
*/










/*
Page:           rating.js
Created:        Aug 2006
Last Mod:       Mar 11 2007
Handles actions and requests for rating bars.	
--------------------------------------------------------- 
ryan masuga, masugadesign.com
ryan@masugadesign.com 
--------------------------------------------------------- */

var xmlhttp
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	 xmlhttp=false
	@end @*/
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	function myXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('couldn\'t create xmlhttp object');
	 }
	}
	return(xmlhttplocal);
}

function sndReq(vote,id_num,ip_num,units,cache) {
	var theUL = document.getElementById('unit_ul'+id_num); // the UL
	
	// switch UL with a loading div
	theUL.innerHTML = '<div class="loading"></div>';
	
	//var estrelas='unit_ul'+id_num;
	
	
	//document.getElementById(estrelas).innerHTML ='<div class="loading"></div>';
	
	
    xmlhttp.open('get', 'http://sorisomail.com/rpc.php?u=aaa&j='+vote+'&q='+id_num+'&t='+ip_num+'&c='+units);
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(null);	
}

function handleResponse() {
  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
			
       	var response = xmlhttp.responseText;

		var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText(update[0], update[1]);
        }
		}
    }
}

function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"
    if (DOM) {
        var viewer = document.getElementById(div2show);
        viewer.innerHTML = text;
    }  else if(IE) {
        document.all[div2show].innerHTML = text;
    }
}

/* =============================================================== */
var ratingAction = {
		'a.rater' : function(element){
			element.onclick = function(){

			var parameterString = this.href.replace(/.*\?(.*)/, "$1"); // onclick="sndReq('j=1&q=2&t=127.0.0.1&c=5');
			var parameterTokens = parameterString.split("&"); // onclick="sndReq('j=1,q=2,t=127.0.0.1,c=5');
			var parameterList = new Array();

			for (j = 0; j < parameterTokens.length; j++) {
				var parameterName = parameterTokens[j].replace(/(.*)=.*/, "$1"); // j
				var parameterValue = parameterTokens[j].replace(/.*=(.*)/, "$1"); // 1
				parameterList[parameterName] = parameterValue;
			}
			var theratingID = parameterList['q'];
			var theVote = parameterList['j'];
			var theuserIP = parameterList['t'];
			var theunits = parameterList['c'];
			var thecache = parameterList['u'];

			//for testing	alert('sndReq('+theVote+','+theratingID+','+theuserIP+','+theunits+')'); return false;
			//sndReq(theVote,theratingID,theuserIP,theunits,thecache); return false;		
			
			}
		}
		
	};
Behaviour.register(ratingAction);


function votacao(){};





/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
