//var historyCount=1;
function get_url(url){
	//dhtmlHistory.add(historyCount,url);
	//historyCount++;

	$('dd').innerHTML="<img border=\"0\" src=\"/_/indicator.gif\" vspan=\"10\" hspace=\"10\">aguarde...";
	var params={};
	
	if(!url) return false;
	
	url = url + "&Case=print";
	var ajax = new Ajax.Updater({success:'dd'},url,{method:'get',parameters:params,onFailure:reportError});
}
function search_area(){
	$('dd').innerHTML="";
	_v('dd',false);
	_v('searchArea2',true);
}
var mesAnterior=0;
function cafe_muda_mes(bMes,mes_atual,mes_aterior){
	bMes.style.color="red";
	get_url('/Aberto/Cafe/Presidente/mes:'+mes_atual+'?a=1');
}
function reportError(request){
	$('dd').innerHTML='error: '+request;
}
function ajax_loadFetchContent(div_id,media_type,content_id){
	ax_loadContentOn=div_id;
    if(!content_id) return false;
	var url="/Aberto/Clipping/Ajax/Materia:"+content_id;
	//window.open(url);
	ax_ld(url,div_id);
}
function ax_ld(url,div){
 var ax = new Ajax.Request(url,{method:'get',parameters:div,onComplete:showResponse});
}
ax_loadContentOn=""; // deve conter o nome do div q irah receber o conteudo.
function showResponse(objectRequest){
	 $(ax_loadContentOn).innerHTML = objectRequest.responseText;
}
var anterior="";
function escolher_assunto(midia){
	if(anterior) _v(anterior,false);
	_v(midia,true);
	anterior=midia;
}
function _fobj(_,__,___){
	if(!___){if(__){___=__.document;}else{___=window.document;}}
	if(___[_]) return ___[_]; if(___.all&&___.all[_]) return ___.all[_];
	if(___.getElementById&&___.getElementById(_)) return ___.getElementById(_);
	for(var x=0;x<___.forms.length;x++){if(___.forms[x][_]) return ___.forms[x][_];}
	for(var x=0;x<___.anchors.length;x++){if(___.anchors[x].name==_) return ___.anchors[x];}
	for(var x=0;document.layers&&x<___.layers.length;x++) var a=_fobj(_,null,___.layers[x].document);if(a){return a;}
	if(!__&&window[_]){return window[_];}if(__&&__[_]){return __[_];}
	for(var x=0;__&&__.frames&&x<__.frames.length;x++) var a=_fobj(_,__.frames[x],__.frames[x].document);if(a){return a;}
	return null;
}
function _v(_,__,___){
	var $_=_fobj(_,___); if(!$_) return;
	if($_.style){
		if($_.style.display) 
			if($_.style.display=='none')
				$_.style.display='block'
			else $_.style.display='none';
		else 
			$_.style.visibility=__?'visible':'hidden';
	}else{
		$_.visibility=__?'show':'hide';
	}
}
function close_palyer(){
 _v("player",false);
}
function send_by_email(id,mes){
		var email="";
		if(email=prompt("Digite seu e-mail:")){
			var url = "/Aberto/Cafe/Materia/id:"+id+":mes:"+mes+"?Email="+email;
			get_url(url)
			_v("player",true);
		}
}
function flash_player(url,name){
        var palyer_url = "/conteudo/audios/player.swf";
        var podFile = url;
        var podName = name;

        var div = document.getElementById("player");
        
		var salvar = " <a href='"+url+"' alt='Clique com o botão direito do mouse aqui e escolhar salvar.'>Salvar este áudio (clique aqui).</a>";
        if (!document.getElementById("podPlayer")) {
            
            content = '<div>'+
                    '<object id="podPlayer" type="application/x-shockwave-flash" data="'+palyer_url+'?pod='+encodeURIComponent(podFile)+'&podname='+encodeURIComponent(podName)+'" width="238" height="17">'+
                    '<param name="movie" value="/conteudo/audios/player.swf?pod='+encodeURIComponent(podFile)+'&podname='+encodeURIComponent(podName)+'" />'+
                    '<param name="wmode" value="transparent" />'+
                    '</object>'+
                    '</div>';
            
            div.innerHTML = content + salvar;
            div.style.display = "block";
            div.style.visibility = "visible";
        } else {
            podPlayer.SetVariable("/fileChange:pod", encodeURIComponent(podFile));
            podPlayer.SetVariable("/fileChange:podname", podName);
            podPlayer.TPlay("/fileChange");
        }

}  

// search area
function fazer_pesquisa(){
	var PESQUISAR=$('palavras');
	var ok=false;
	if(PESQUISAR.value==''){
		if(PESQUISAR.value==''){
			PESQUISAR.style.backgroundColor='#FF1A00';
			PESQUISAR.style.color='#FFFFFF';
			PESQUISAR.focus();
			ok=alerta('ATENÇÃO: VOCÊ DEVE DIGITAR ALGUM CONTEÚDO PARA PESQUISAR.');
		}
	}else{
		var Palavras=$F('palavras');
		var url='/Aberto/Cafe/Presidente/Pesquisar:'+Palavras+"?";
_v('searchArea2',false);
_v('dd',true);

		get_url(url);

	}
	return false;
	return ok;
}
function alerta(msg){
	var alerta=$('alerta');
	msg = alerta.innerHTML + msg +"<br />";
	alerta.innerHTML=msg;
	_v('alerta',true);
	return false;
}
// search area
