function popUp(page, name_page, att){
	window.open(page, name_page, att);
}
//---------------------------------------------------------------------------------------
function showLayer(layer_id){
	if(document.getElementById(layer_id).style.display == "none"){
		document.getElementById(layer_id).style.display = "";
	}else{
		document.getElementById(layer_id).style.display = "none";
	}
}
//---------------------------------------------------------------------------------------
function showHideLayer(show_layer_id, arr_hide_layer_id){
	/*if(document.getElementById(show_layer_id).style.display == ""){
		document.getElementById(show_layer_id).style.display = "none";
	}else{
		document.getElementById(show_layer_id).style.display = "";
	}*/
	document.getElementById(show_layer_id).style.display = "";
	
	if(arr_hide_layer_id.indexOf(",")){
		var arr_hide = arr_hide_layer_id.split(",");
		for (i = 0 ; i < arr_hide.length ; i++) {
			document.getElementById(arr_hide[i]).style.display = "none";
		}
	}else{
		document.getElementById(arr_hide_layer_id).style.display = "none";
	}
}
//---------------------------------------------------------------------------------------
function hideLayer(layer_id){
	document.getElementById(layer_id).style.display = "none";
}
//---------------------------------------------------------------------------------------
function check_loaded(){
	page_loaded = true;	
}
page_loaded = false;
//--------------------------------------------------------------
function check_tp_origin(val, form_id, val_verify, field_others, div){
	f = eval(form_id + "." + field_others);
	if(val == val_verify){
		f.disabled = false;
		document.getElementById(div).style.display = "";
	}else{
		f.disabled = true;
		f.value = "";
		document.getElementById(div).style.display = "none";
	}
}
//--------------------------------------------------------------
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function perfil_apagar(){
	if (confirm("Deseja realmente remover seu perfil?")) {
		return true;
	} else {
		return false;
	}
}

function perfil_remover_foto(){
	if (confirm("Deseja realmente remover sua foto?")) {
		return true;
	} else {
		return false;
	}
}

function perfil_remover_foto_galeria(perfil_id, id, url){
	if (confirm("Deseja realmente apagar esta foto da galeria?")) {
		return true;
	} else {
		return false;
	}
}

function perfil_remover_audio(){
	if (confirm("Deseja realmente apagar este audio?")) {
		return true;
	} else {
		return false;
	}
}

function perfil_remover_video() {
	if (confirm("Deseja realmente remover video?")) {
		return true;
	} else {
		return false;
	}
}

function perfil_remover_post() {
	if (confirm("Deseja realmente apagar esta história?")) {
		return true;
	} else {
		return false;
	}
}

function perfil_remover_comentario() {
	if (confirm("Deseja realmente apagar este comentário?")) {
		return true;
	} else {
		return false;
	}
}

function showPerfilCompleto(){
	if(document.getElementById('perfil_completo').style.display == "none"){
		document.getElementById(layer_id).style.display = "";
	}else{
		document.getElementById(layer_id).style.display = "none";
	}
}
function clearValue(field)
{
if (field.defaultValue == field.value)
field.value = ""
} 

function deletar_arvore() {
	if (confirm("Deseja realmente apagar esta árvore?")) {
		return true;
	} else {
		return false;
	}
}

var Paginator = {
	jumpToPage: function(pages) {
		var page = prompt("Entre com um número entre 1 e " + pages + " para ir até a página", "");
        if (page != undefined) {
            page = parseInt(page, 10)
            if (!isNaN(page) && page > 0 && page <= pages) {
                window.location.href = "?page=" + page;
            }
        }
    }
};

function mostra_arquivo_categoria(categoria_id) {
	div_id = "categoria_" + categoria_id;
	aberto = $(div_id).getProperty("aberto");
	if (aberto == 0) {
		$(div_id).setHTML("carregando...");
		var url = "/arquivo/mostra_categoria/" + categoria_id + "/";
		new Ajax(url, {
		method: 'get',
		update: $(div_id)
		}).request();
		$(div_id).setProperty("aberto", 1);
		$(div_id).setStyle("display", "");
	} else {
		$(div_id).setProperty("aberto", 0);
		$(div_id).setStyle("display", "none");
	}
}

function mostra_video_destaque(video_id) {
	$('video_player').setHTML("carregando...");
	if (!video_id) {
		video_id = "";
	}
	var url = "/arquivo/mostra_video_destaque/";
	var querystring = {"video_id": video_id};
	new Ajax(url, {
  	method: 'get',
  	data: querystring,
  	onComplete: mostra_video_destaque_callback
  	}).request();
}

function mostra_video_destaque_callback(json_str) {
	obj = Json.evaluate(json_str);
	titulo = obj[0].fields.titulo;
	texto = obj[0].fields.texto;
	video = obj[0].fields.video;
	data_cadastro = format_date(obj[0].fields.data_cadastro);
	var so = new SWFObject(media_url + "swf/player_video.swf", "pl_video", "320", "285", "8");
	so.skipDetect = true;
	so.addParam("quality", "high");
	so.addParam("wmode", "opaque");
	so.addVariable("has_vinheta", 1);
	so.addVariable("url_host", "http://static.japao100.com.br/static/");
	so.addVariable("video_url", video);
	so.addVariable("atualiza", "20071016194900");
	so.write("video_player");
	$('video_titulo').setHTML(titulo);
	$('video_texto').setHTML(texto);
	$('video_date').setHTML(data_cadastro);
}

function mostra_videos(page) {
	if (page) {
		var querystring = {"page": page};
	} else {
		var querystring = {};
	}
	var url = "/arquivo/mostra_videos/";
	new Ajax(url, {
	method: 'get',
	data: querystring,
	update: $('video_list')
	}).request();
}

function mostra_podcast_destaque(podcast_id) {
	$('podcast_player').setHTML("carregando...");
	if (!podcast_id) {
		podcast_id = "";
	}
	var url = "/arquivo/mostra_podcast_destaque/";
	var querystring = {"podcast_id": podcast_id};
	new Ajax(url, {
  	method: 'get',
  	data: querystring,
  	onComplete: mostra_podcast_destaque_callback
  	}).request();
}

function mostra_podcast_destaque_callback(json_str) {
	obj = Json.evaluate(json_str);
	titulo = obj[0].fields.titulo;
	texto = obj[0].fields.texto;
	audio = obj[0].fields.audio;
	data_cadastro = format_date(obj[0].fields.data_cadastro);
	var so = new SWFObject(media_url + "swf/player_audio_novo.swf", "pl_podcast", "150", "23", "8");
	so.skipDetect = true;
	so.addParam("quality", "high");
	so.addParam("wmode", "opaque");
	so.addVariable("url_host", "http://static.japao100.com.br/static/");
	so.addVariable("song", "http://static.japao100.com.br/static/" + audio);
	so.addVariable("atualiza", "20071016194900");
	so.write("podcast_player");
	$('podcast_titulo').setHTML(titulo);
	$('podcast_texto').setHTML(texto);
	$('podcast_date').setHTML(data_cadastro);
}

function mostra_podcasts(page) {
	if (page) {
		var querystring = {"page": page};
	} else {
		var querystring = {};
	}
	var url = "/arquivo/mostra_podcasts/";
	new Ajax(url, {
	method: 'get',
	data: querystring,
	update: $('podcast_list')
	}).request();
}

function format_date(value) {
   arr_separa = value.split(" ");
   arr_value = arr_separa[0].split("-");
   return arr_value[2] + "/" + arr_value[1] + "/" + arr_value[0];
}


function video_exame(video_id){
   
   switch(video_id){
      case 1:
         video = 'videos/ins_exame_festa.flv';
         $('hideaki').style.display = 'none';
         $('maeda').style.display = 'none';
         $('satoshi').style.display = 'none';
         $('marino').style.display = 'none';
         break;
      case 2:
         video = 'videos/ins_sueli_sakata.flv';
         $('hideaki').style.display = '';
         $('maeda').style.display = 'none';
         $('satoshi').style.display = 'none';
         $('marino').style.display = 'none';
         break;
      case 3:
         video = 'videos/ins_satoshi_yokoda.flv';
         $('hideaki').style.display = 'none';
         $('maeda').style.display = 'none';
         $('satoshi').style.display = '';
         $('marino').style.display = 'none';
         break;
      case 4:
         video = 'videos/ins_marino_kurita.flv';
         $('hideaki').style.display = 'none';
         $('maeda').style.display = 'none';
         $('satoshi').style.display = 'none';
         $('marino').style.display = '';
         break;
      case 5:
         video = 'videos/ins_jorge_maeda.flv';
         $('hideaki').style.display = 'none';
         $('maeda').style.display = '';
         $('satoshi').style.display = 'none';
         $('marino').style.display = 'none';
         break;
      default:
         video = 'videos/ins_exame_festa.flv';
         break;
   }             

   var so = new SWFObject("/static/swf/player_video.swf", "pl_video", "320", "285", "8");
   so.skipDetect = true;
   so.addParam("quality", "high");
   so.addParam("wmode", "opaque");
   so.addVariable("has_vinheta", 1);
   so.addVariable("url_host", "http://static.japao100.com.br/static/");
   so.addVariable("video_url", video);
   so.addVariable("atualiza", "20071016194900");
   so.write("video_player");
}