// JavaScript Document

function ajaxCall(url, target){
	var req = new Request({
		url: url,
		method: 'get',
		evalScripts:true,
		noCache:true,
		onSuccess: function(result){
			$(target).set('html', result);
		}
		});
	req.send();

}



function ajaxForm(url, target){
		var bt_text = "";
		$(url).set('send', {
				   	evalScripts:true,
					noCache:true,
					onRequest: function(){
						$$("#"+url+" input").each(function(item,index){
														   if( item.getProperty('type') == "submit" ){
															   	item.setProperty('disabled','disabled');
																bt_text = item.getProperty('value');
																item.setProperty('value','Enviando...');
														   }
											});
					},
				   	onComplete: function(response) { 
						$$("#"+url+" input").each(function(item,index){
														   if( item.getProperty('type') == "submit" ){
															   	item.removeProperty('disabled');
																item.setProperty('value',bt_text);
														   }
											});

						$(target).set('html', response);
					}
		});
		
		$(url).send();
}



function comentarioEnviar(formulario,noticia_id,target){

	ajaxForm(formulario, target);

	return false;

}







/******************************************/

function abreJanela(url,nome,especificacoes) {
    w = window.open(url,nome,especificacoes);
	w.focus();
}

function abre_podcast(i){
	jan = window.open('http://www.medimagem.com.br/novo/podcast?id='+i,'podcast','width=450, height=600');
    jan.focus();
//    abreJanela("/novo/podcast/index.php?id="+id,"Podcast Med Imagem","width=450, height=600");
}



function pergunta(msg){

	return confirm(msg);

}



/*******************************************/



function mostra_aba(aba){

	if (aba == 1){

		$("div_atualizacao" ).style.display="none";

		$("div_album" ).style.display="block";

	}

	else {

		$("div_album" ).style.display="none";

		$("div_atualizacao" ).style.display="block";

	}

}



/*function ajax(url) 

{ 



	req = null; 

	// Procura por um objeto nativo (Mozilla/Safari) 

	if (window.XMLHttpRequest) { 

		req = new XMLHttpRequest(); 

		req.onreadystatechange = processReqChange; 

		req.open("GET",url,true); 

		req.send(null); 

	// Procura por uma versão ActiveX (IE) 

	} else if (window.ActiveXObject) { 

		req = new ActiveXObject("Microsoft.XMLHTTP"); 

		if(req) { 

		req.onreadystatechange = processReqChange; 

		req.open("GET",url,true); 

		req.send(); 

		} 

	} 



} 



function processReqChange() 

{ 





	if (req.readyState == 4) { 





		

		if (req.status ==200) { 

		

	

		document.getElementById('pagina').innerHTML = req.responseText;

		document.getElementById('pagina').style.visibility = 'visible';		



		

		} else { 

		alert("Houve um problema ao obter os dados:n" + req.statusText); 

		} 

	} 

} */





/*sem activex */

/*

var kXHR_instances=0;

var kXHR_objs=[];





XMLHttpRequest=function(){

	var i=0;

	var url='';

	var responseText='';

	var iframe='';

	this.onreadystatechange=function(){

		return false;

	}

	this.open=function(method,url){

		//TODO: POST methods

		this.i=++kXHR_instances; // id number of this request

		this.url=url;

		document.body.appendChild(document.createElement('<iframe id="kXHR_iframe_'+this.i+'" style="display:none" src="/"></iframe>'));

	}

	this.send=function(postdata){

		//TODO: use the postdata

		document.getElementById('kXHR_iframe_'+this.i).src=this.url;

		kXHR_objs[this.i]=this;

		setTimeout('XMLHttpRequest_checkState('+this.i+',2)',2);

	}

	return true;

}

XMLHttpRequest_checkState=function(inst,delay){

	var el=document.getElementById('kXHR_iframe_'+inst);

	if(el.readyState=='complete'){

		var responseText=document.frames['kXHR_iframe_'+inst].document.body.innerText;

		kXHR_objs[inst].responseText=responseText;

		kXHR_objs[inst].readyState=4;

		kXHR_objs[inst].status=200;

		kXHR_objs[inst].onreadystatechange();

		el.parentNode.removeChild(el);

	}else{

		delay*=1.5;

		setTimeout('XMLHttpRequest_checkState('+inst+','+delay+')',delay);

	}

}

*/