function clrbuscacomp(q) {if ((q == 'Adicione um programa &agrave; compara&ccedil;&atilde;o') || (q == 'Adicione um programa à comparação')) {document.getElementById('buscaprogadd').value='';}; return true;};
function getCookie(name){
var start=document.cookie.indexOf(name+"=");
var len=start+name.length+1;
if (start == -1) return null;
var end=document.cookie.indexOf(";",len);
if (end==-1) end=document.cookie.length;
return unescape(document.cookie.substring(len,end));
};

function setCookie(c_name,value,expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
};
//  FAVORITOS  //Sugerido por Junior alves
function favoritos() {
    var url      = "http://www.baixaki.com.br";
    var title    = "Baixaki - Download e Tecnologia";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var amd = document.createElement('a');
        amd.setAttribute('rel','sidebar');
        amd.setAttribute('href',url);
        amd.setAttribute('title',title);
        amd.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
};

//	USUÁRIOS
function usubox(t,s) { document.getElementById('usubox').style.height=t + 'px'; if(s==1) {document.getElementById('userhist').style.visibility='visible';document.getElementById('userhist').style.display='block';document.getElementById('histbot').style.visibility='visible';document.getElementById('histbot').style.display='block';} else {document.getElementById('userhist').style.visibility='hidden';document.getElementById('userhist').style.display='none';document.getElementById('histbot').style.visibility='hidden';document.getElementById('histbot').style.display='none';}};


//===========================
//			Redirect Mac & Linux
//===========================
//Baseado no exemplo: http://www.quirksmode.org/js/detect.html
var BrowserDetect = {
	init: function () {
		this.OS = this.searchString(this.dataOS) || "S.O. Desconhecido";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1) {
					 this.codOS = data[i].cod;
					 this.to = data[i].to;
					return data[i].identity;
				}
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows",
			cod:1,
			to:"/"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac",
			cod:2,
			to:"/mac/"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone",
			   cod:6,
				to:"/iphone/m/"
	    },
		{
			   string: navigator.userAgent,
			   subString: "iPad",
			   identity: "iPad",
			   cod:6,
				to:"/iphone/"
	    },
		{
			   string: navigator.userAgent,
			   subString: "Android",
			   identity: "Android",
			   cod:7,
				to:"/android/m/"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux",
			cod:3,
			to:"/linux/"
		}
	]

};
BrowserDetect.init();

function sethome() {
	if(document.referrer.indexOf("baixaki.com.br")==-1) {
		if(BrowserDetect.to!="/") {window.location = "http://www.baixaki.com.br" + BrowserDetect.to};
	}; 
};

function querystring(ji) {hu = window.location.search.substring(1); gy = hu.split("&"); for (i=0;i<gy.length;i++) {ft = gy[i].split("="); if (ft[0] == ji) {return ft[1];}}}




function clrcck() {$.cookie('historico', '', { expires: -1, path: '/' });$.cookie('s_sess', '', { expires: -1, path: '/', domain: '.baixaki.com.br' });$.cookie('s_pers', '', { expires: -1, path: '/', domain: '.baixaki.com.br' });};
//===========================
//				//	Historico
//===========================

function getuser(){
	
	var user=(getCookie("nznuser") == null) ? "X" : getCookie("nznuser");
	user = user.split("&",1) ;
	var avatar=(getCookie("avatar") == null) ? "0" : getCookie("avatar");
	avatar=avatar.split("&",1);
	var cod = (getCookie("nzncoduser") == null) ? "0" : getCookie("nzncoduser");
	cod = cod.split("&",1) ;
	var facebook = (getCookie("facebook") == null) ? "0" : getCookie("facebook");
	facebook = facebook.split("&",1) ;
	if(avatar=='1') { avatar='/usuarios/avatar/' + cod +  '-45.jpg?'+Math.random(); } else {avatar='/img/avatares/' + avatar +  '-45.jpg';}
	if(facebook=='1'){facebook='<div class="ic-from">Conectado pelo Facebook</div>'}else{facebook='';}
	if (cod > 1 ){ 
    
   document.write('<div id="user-box"><a href="/usuarios/meu-baixaki.asp"><div class="avatar"><img alt="'+user+'" src="'+avatar+'" />'+facebook+'</div>'+user+'</a><ul class="links"><li><a class="first" href="/usuarios/meu-baixaki.asp">Minha Área</a></li><li><a href="/usuarios/logout.asp">Sair</a></li></ul></div>');
	}else{
        document.write('<div id="signin"><div id=\"fb-root\"></div><div class="item"><a class="btn-txt" href="/usuarios/">Cadastre-se</a></div>');
        document.write('<div class="item" id="login-trigger"><a class="btn-txt" href="javascript:void(0);"><div class="arrow">Entrar</div></a>');
		document.write('<div id="login-box"><form method="post" name="login" id="login" target="frm-login" onsubmit="return preparaLogin();" action="/usuarios/login-frm.asp">');
		document.write('<div class="form-error" style="display:none;">Verifique se o seu email e/ou senha estão corretos.</div>');
        document.write('<ol><li><label class="form-label" for="email">E-mail</label><input class="form-text" id="login-email" maxlength="100" name="login-email" type="text" /></li>');
        document.write('<li><label class="form-label" for="senha">Senha</label><input class="form-text" id="login-senha" maxlength="30" name="login-senha" type="password" /><label class="form-other"><input id="lembra" name="lembra" type="checkbox" value="1" />Lembrar meu login</label></li>');
        document.write('<li><input class="form-button" name="Submit" type="submit" value="Entrar" /><a class="form-link" href="/usuarios/senha.asp">Recuperar senha</a><input id="go" name="go" type="hidden" value="/" /></li></ol>');
        document.write('<div class="facebook" id="facebook"><input class="bt-fb" name="Facebook" type="button" value="Entrar" />Conectar pelo Facebook</div>');
        document.write('<span class="load-s" style="display:none;">Carregando</span>');
        document.write('</form></div></div></div>');
	}

};


function preparaLogin() {
	if ($("#frm-login").html()==null) {
		$("body").append("<iframe src=\"\" id=\"frm-login\" name=\"frm-login\" style=\"display:none;\"></iframe>");
	}
	mostrarCarregando();
	return true;
}
function loginFeito(usuario) {
	location.reload(true);
}
function msgErro(msg, login) {
	esconderCarregando();
	$("#login-senha").val('');
	if (typeof(login)=='undefined') {
		$("#login-email").val('');
	} else {
		$("#login-email").val(login);
	}
	$("#login-email").addClass('error');
	$("#login-senha").addClass('error');
	$(".form-error").show();
	$(".form-error").html(msg);
	$('.load-s').hide();
	window.setInterval('$(".form-error").hide();$(".form-error").html("");',2000);
	if(login=='banido'){document.location.href='/usuarios/index.asp?err=2';}
}
function mostrarCarregando() {
	$('.load-s').show();
	$("#user-box #login .fm-btn").remove();
	$("#user-box #login .fm-bta").remove();
	$("#user-box .msg-error").css('display','none');
}
function esconderCarregando() {
$("#user-box #login").html($("#user-box #login").html()+'<input name="Submit" type="submit" class="fm-btn" value="Entrar" /><a href="/usuarios/senha.asp" class="fm-bta">Esqueceu sua senha?</a>');
$("#user-box #login .load-s").remove();
}




function tipso() { //usado na pág dos programas para mostrar alternativas pro SO do user
	document.write('<div id="tipso"><div class="close" onclick="document.getElementById(\'tipso\').style.display=\'none\';">fechar</div>');	
	document.write('Voc&ecirc; est&aacute; usando ' + uSOstr +  ', mas este download s&oacute; funciona no ' + pSOstr + '. <br /><a href="/');
	if(uSO!=1){document.write(uSOstr.toLowerCase() + '/');};
	document.write(url + '">Clique aqui para baixar o ' + prog + ' para ' + uSOstr + '</a></div>');
};

//$(document).ready(function() {
// var followers=$('#followers').html();
//  followers=followers.replace('followers','seguidores');
//  $('#followers').html(followers);
//});



$(document).ready(function() {
		//FORMS
			$('.fm-txt').focus(function(){
				$(this).addClass('active');
			}).blur(function(){
				$(this).removeClass('active');
			});
			
			//BT-GENERIC
			$(function(){ $(".bt-generic[title]").tipTip();	})
			
			//LIGHTBOX
			$(function(){ $(".lightbox").lightbox();	})
			
			//SLIDER
			$('#special').tinycarousel({ controls: false, pager: true, interval: true, intervaltime: 6000});
			
			//TABS
			initHomeTabs=function(x){
				var y = x.split("#");
				
				$(x+' .tab-content').each(function(index) {
					$(this).attr('id',y[1]+'-tab-'+index);
				});
				$(x+' .tab-nav a').each(function(index) {
					$(this).attr('href',x+'-tab-'+index);
				});
				$(x+' .tab-content').hide(); // Hide all divs
				$(x+' .tab-content:first').show(); // Show the first div
				$(x+' .tab-nav li:first').addClass('active'); // Set the class of the first link to active
				$(x+' .tab-nav li a').click(function(){ //When any link is clicked
					$(x+' .tab-nav li').removeClass('active'); // Remove active class from all links
					$(this).parent().addClass('active'); //Set clicked link class to active
					var currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
					$(x+' .tab-content').hide(); // Hide all divs
					$(currentTab).fadeIn(); // Show div with id equal to variable currentTab
					return false;
				});
			}
			initHomeTabs("#topnews");
			initHomeTabs("#media");
		
		});
    
		$(document).ready(function() {
		  var loginActive = false;
		
		  $("body").not("#login-trigger").not("#login-box").click( function(){
			if (loginActive) {
			  $("#login-trigger").toggleClass("active");
			  loginActive = false;
			};
		  });
		
		  $("#login-trigger").click( function(e){
			if (!loginActive){
			  $(this).toggleClass("active");
			  loginActive = true;
			} else {
			  $(this).toggleClass("active");
			  loginActive = false;
			}
			e.stopPropagation();
		  });
		
		  $("#login-box").click(function(e){
			e.stopPropagation();
		  });
		
		  $("'[placeholder]'").focus(function() {
			var input = $(this);
			if (input.val() == input.attr("'placeholder'")) {
			  input.val("''");
			  input.removeClass("'placeholder'");
			}
		  }).blur(function() {
			var input = $(this);
			if (input.val() == "''" || input.val() == input.attr("'placeholder'")) {
			  input.addClass("'placeholder'");
			  input.val(input.attr("'placeholder'"));
			}
		  }).blur();

		//$('.bt-fb').bind('click', function() {if ($("#conecta-facebook").html() == null) {$("body").append("<iframe id=\"conecta-facebook\" name=\"conecta-facebook\" style=\"display:none;\" />");}$('#conecta-facebook').attr('src','/inc/face-bxk.htm');});
			//$('.adtopabs_h').css('top','171px');
			//$('.adtopabs_i').css('top','191px');
	//if($('#adtopDet').html() != null){
	//	var bannerTop = $('#adtopDet');var offsetBanner = bannerTop.offset();var offsetBannerTop = offsetBanner.top+10;$('.adtopabs_h').offset({top:offsetBannerTop});$('.adtopabs_h').css('z-index','1000');$('.adtopabs_i').offset({top:offsetBannerTop});$('.adtopabs_i').css('z-index','1000');$('.adtopabs_i').css('top','200px');
		//$('.adtopabs_i').css('top','200px');
		//if(navigator.userAgent.toLowerCase().search('chrome') > 0){$('.adtopabs_i').css('top','200px');}
		//$('.adtopabs_i').css('top','180px');
	//}
		});

	$(document).ready(function() {   
	$('#login-trigger').click(function() {
		$('.facebook').css('padding','0px');
		$('.facebook').css('height','40px');		
		$('#facebook').html('<iframe frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\" width=\"100%\" height=\"35px\" src=\"/inc/ifrm-log-facebook-new.htm?v=1\"></iframe>');
		//$('.load-s').show();
		});
	});
	
	
	
	
//=================================================================
//
//			Importado da detalhes
//
//=================================================================	
	
//===========================
//			Detecta e retorna o sistema operacional
//===========================
function getsistema(){
	if(navigator.userAgent.indexOf('Linux') != -1)
	{ var so = "Linux"; }
	else if((navigator.userAgent.indexOf('Windows 95')!= -1))
	{ var so = "Windows 95"; }
	else if((navigator.userAgent.indexOf('Windows 98')!= -1))
	{ var so = "Windows 98"; }
	else if((navigator.userAgent.indexOf('Win')!=-1)&&(navigator.userAgent.indexOf(' 2000')!=-1))
	{ var so = "Windows 2000"; }
	else if((navigator.userAgent.indexOf('Win')!= -1)&&(navigator.userAgent.indexOf('NT 5.1')!= -1))
	{ var so = "Windows XP"; }
	else if((navigator.userAgent.indexOf('Win')!= -1)&&(navigator.userAgent.indexOf('NT 5.2')!= -1))
	{ var so = "Windows XP 64"; }
	else if((navigator.userAgent.indexOf('Win')!= -1)&&(navigator.userAgent.indexOf('NT 6.0')!= -1))
	{ var so = "Windows Vista"; }
	else if((navigator.userAgent.indexOf('Win')!= -1)&&(navigator.userAgent.indexOf('NT 6.0')!= -1)&&(navigator.userAgent.indexOf('WOW64')!= -1))
	{ var so = "Windows Vista 64"; }
	else if((navigator.userAgent.indexOf('Win')!= -1)&&(navigator.userAgent.indexOf('NT 6.1')!= -1))
	{ var so = "Windows 7"; }
	else if((navigator.userAgent.indexOf('Win')!= -1)&&(navigator.userAgent.indexOf('NT 6.1')!= -1)&&(navigator.userAgent.indexOf('WOW64')!= -1))
	{ var so = "Windows 7 64"; }
	else if((navigator.userAgent.indexOf('Win')!= -1)&&(navigator.userAgent.indexOf('NT 6.2')!= -1))
	{ var so = "Windows 8"; }
	else if((navigator.userAgent.indexOf('Win')!= -1)&&(navigator.userAgent.indexOf('NT 6.2')!= -1)&&(navigator.userAgent.indexOf('WOW64')!= -1))
	{ var so = "Windows 8 64"; }
	else if(navigator.userAgent.indexOf('Mac') != -1)
	{ var so = "Mac"; }
	else if(navigator.userAgent.toLowerCase().indexOf('unix') != -1)
	{ var so = "Unix"; }
	else { var so = "nada"; }
	return so;
};

//===========================
//			Verifica se o sistema operacional é compatível
//===========================
function sistemacompativel(){
	var so = getsistema();
	var so_=so.replace('Windows ','');
	if(so!='nada'){if(sistemaOp!='Web'){if(pSO!=4){if(sistemaOp.indexOf(so_)!= -1){document.write('<span class=\"platform ok\"><span class=\"ttip\"><strong>Sistema Compat&iacute;vel</strong>Voc&ecirc; est&aacute; usando o '+so+'</span></span>');}else{document.write('<span class=\"platform no\"><span class=\"ttip\"><strong>Sistema Incompat&iacute;vel</strong>Voc&ecirc; est&aacute; usando o '+so+'</span></span>');}}}}	
};

//==========================