$(document).ready(function(){$("input#newArticle").click(function(){$("div#newArticleBox").slideUp("fast",function(){$("div.formProporArtigo").slideDown("slow");});return false;});$("a#moreClassifiersBtn").click(function(){$(this).slideUp("fast",function(){$($(this).attr("href")).slideDown("slow");});return false;});$("a#newSearch").click(function(){$(this).slideUp("fast",function(){$($(this).attr("href")).slideDown("slow");});return false;});$("a#btnComment").click(function(){$(this).slideUp("fast",function(){$("div#commentForm").slideDown("slow");});return false;})
$("div.tabs").hide();$("div.tabs:first").show();$("#contentTabs a").click(function(){activeid=$("#contentTabs a.active").attr("href");if(activeid!=$(this).attr("href")){$(activeid).fadeOut("fast",function(){$(this).hide();});$($(this).attr("href")).fadeIn("slow");$("#contentTabs a").removeClass("active");$(this).addClass("active");}
return false;})
$("div.scrollContent").hide();$("div.scrollContent:first").show();$("a#scrollNext").click(function(){var divIndex=$("div.scrollContent:visible").attr("id");var divIndex=parseInt($("div.scrollContent").index(jQuery("#"+divIndex)))+1;var divsLength=parseInt($("div.scrollContent").length);if(divIndex<divsLength){$("div.scrollContent:visible").fadeOut("fast",function(){$(this).hide();});$("div.scrollContent:visible").next().fadeIn("fast");}else{$("div.scrollContent:visible").fadeOut("fast",function(){$(this).hide();});$("div.scrollContent:first").fadeIn("fast");}
return false;});$("a#scrollPrev").click(function(){var divIndexID=$("div.scrollContent:visible").attr("id");var divIndex=parseInt($("div.scrollContent").index(jQuery("#"+divIndexID)))-1;if(divIndex>=0){$("div.scrollContent:visible").fadeOut("fast",function(){$(this).hide();});$("div.scrollContent:visible").prev().fadeIn("fast");}else{$("div.scrollContent:visible").fadeOut("fast",function(){$(this).hide();});$("div.scrollContent:last").fadeIn("fast");}
return false;})
var AreaOptionsValues=Array();var AreaOptionsTexts=Array();$('#selectArea option').each(function(index){AreaOptionsValues[AreaOptionsValues.length]=$(this).val();AreaOptionsTexts[AreaOptionsTexts.length]=$(this).text();});var newul=document.createElement('ul');var op0=document.createElement('li');newul.id="areaJS";op0.id="opAreaActive";newul.appendChild(op0);for(i=1;i<AreaOptionsValues.length;i++)
{var op="";op=document.createElement('li');op.id="opA-"+i;op.addClass="opval-"+AreaOptionsValues[i];optext=document.createTextNode(AreaOptionsTexts[i]);op.appendChild(optext);newul.appendChild(op);}
$('#selectArea').hide();$('#selectAreaJS').append(newul);$('#selectAreaJS').show();$("#opAreaActive").text(AreaOptionsTexts[0]);for(i=1;i<AreaOptionsValues.length;i++)
{$("#opA-"+i).click(function(){$("li#opAreaActive").text($(this).text());var selectid=this.addClass.split("-");$("#area").val(selectid[1]);Fadeoutlis("areaJS","fast");if($("#area").val()>0&&$("#area").val()<4)
$("#selectNivelJS").slideUp("fast");else
$("#selectNivelJS").slideDown("fast");return false;})}
$("#opAreaActive").click(function(){if($('#opA-1').css('display')=='none'){if($('#opN-1').css('display')!='none')
Fadeoutlis("nivelJS","slow");$('#areaJS li').show();}else
Fadeoutlis("areaJS","slow");})
var LevelOptionsValues=Array();var LevelOptionsTexts=Array();$('#selectNivel option').each(function(index){LevelOptionsValues[LevelOptionsValues.length]=$(this).val();LevelOptionsTexts[LevelOptionsTexts.length]=$(this).text();});var newul=document.createElement('ul');var op0=document.createElement('li');newul.id="nivelJS";op0.id="opNivelActive";newul.appendChild(op0);for(i=1;i<LevelOptionsValues.length;i++)
{var op="";op=document.createElement('li');op.id="opN-"+i;op.addClass="opval-"+LevelOptionsValues[i];optext=document.createTextNode(LevelOptionsTexts[i]);op.appendChild(optext);newul.appendChild(op);}
$('#selectNivel').hide();$('#selectNivelJS').append(newul);$('#selectNivelJS').show();$("#opNivelActive").text(LevelOptionsTexts[0]);for(i=1;i<LevelOptionsValues.length;i++)
{$("li#opN-"+i).click(function(){$("li#opNivelActive").text($(this).text());var selectid=this.addClass.split("-");$("#level").val(selectid[1]);Fadeoutlis("nivelJS","fast");if($("#level").val()>0){$("#area").val("4");$("li#opAreaActive").text($("#area option:selected").text());}
return false;})}
$("li#opNivelActive").click(function(){if($('li#opN-1').css('display')=='none'){if($('li#opA-1').css('display')!='none')
Fadeoutlis("areaJS","slow");$('#nivelJS li').show();}else
Fadeoutlis("nivelJS","slow");})
$("#nivelJS li:last").css({borderBottom:'1px solid #999'});$("#areaJS li:last").css({borderBottom:'1px solid #999'});$("#nivelJS li:first").next().css({borderTop:'1px solid #999'});$("#areaJS li:first").next().css({borderTop:'1px solid #999'});$("#sidebar").mouseleave(function(){if($('li#opA-1').css('display')!='none'){Fadeoutlis("areaJS","slow");}
if($('li#opN-1').css('display')!='none'){Fadeoutlis("nivelJS","slow");}})});function Fadeoutlis(ulid,speed){$('#'+ulid+' li:not(:first)').fadeOut(speed,function(){$(this).hide();});}
