//signin box toggler
jQuery(document).ready(function(){

	//hide check
	jQuery('#signIn').hide();

	jQuery("#haveAccount #signInLink").click(function() {

		jQuery(this).toggleClass("signInToggler");

		jQuery('#signIn').slideToggle(400); // First click should toggle to 'show'
		return false; //deactivate normal link behaviour
	});

});

//read more about Kigol toggler
jQuery(document).ready(function(){

	//hide check
	jQuery('#kigolMoreInfo').hide();
	
	//show
	jQuery("#kigolBox #kigolMoreInfoLink").click(function() {

		jQuery("#kigolBox #kigolMoreInfoLink").css({opacity: 100, visibility: "visible"}).animate({opacity: 0});

		jQuery('#kigolMoreInfo').slideDown(400); // 'show'
		return false; //deactivate normal link behaviour
	});
	
	//hide
	jQuery("#kigolBox #closeMoreInfo").click(function() {

		jQuery("#kigolBox #kigolMoreInfoLink").css({opacity: 0, visibility: "visible"}).animate({opacity: 100});

		jQuery('#kigolMoreInfo').slideUp(400); // 'hide'
		return false; //deactivate normal link behaviour
	});
	


//read more article story ---
	
	//hide check
	jQuery('#moreStory').hide();
	
	//show
	jQuery("#newsItem #moreStoryLink").click(function() {

		jQuery("#newsItem #moreStoryLink").css({opacity: 100, visibility: "visible"}).animate({opacity: 0});

		jQuery('#moreStory').slideDown(400); // 'show'
		return false; //deactivate normal link behaviour
	});
	
	//hide
	jQuery("#newsItem #closeMoreStory").click(function() {

		jQuery("#newsItem #moreStoryLink").css({opacity: 0, visibility: "visible"}).animate({opacity: 100});

		jQuery('#moreStory').slideUp(400); // 'hide'
		return false; //deactivate normal link behaviour
	});
	
});





//Top 5 Videos switcher
jQuery(document).ready(function(){

	jQuery("div#clipList .topList a").click(function() {
		
		//remove all current classes
		jQuery("div#clipList .topList li").removeClass("on");

		// add on class to selected item
		jQuery(this).parent("li").addClass("on");
		
		// grab url
		var url  = jQuery(this).attr("href");
		//convert normal YouTube url to embed url
		var url2 = url.replace('watch?v=','v/');
		jQuery("div#clipPreview").html('<object width="440" height="270"><param name="movie" value="'+url2+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+url2+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="440" height="270"></embed></object>');
		
		//deactivate normal link behaviour
		return false;
	}); 
	
});

// KiGOL last logged in users!

jQuery(document).ready(function(){
    var kigolUsers = getLastLoggedInUsersKigol();
      var kigolLastUsers = '';
      var kigolLastUsers2 = '';
      var kigolNewUsers = '';
      var kigolNewUsers2 = '';      
      // top users
      for (var i=0; i< 9; i++) {        
        kigolLastUsers = kigolLastUsers + '<li class="rounded" style="background:url('+kigolUsers[i][2]+') no-repeat;"><a href="#signUpPop" rel="prettyPhoto" class="rounded" title="'+kigolUsers[i][1]+'"></a></li>';
      }
      jQuery('#topusers01').html(kigolLastUsers);
     
      // top users part II
      for (var e=10; e< 19; e++) {
        kigolLastUsers2 = kigolLastUsers2 + '<li class="rounded" style="background:url('+kigolUsers[e][2]+') no-repeat;"><a href="#signUpPop" rel="prettyPhoto" class="rounded" title="'+kigolUsers[e][1]+'"></a></li>';
      }
      jQuery('#topusers02').html(kigolLastUsers2);
      
      // top users part III
      for (var i=18; i< 20; i++) {
        kigolNewUsers = kigolNewUsers + '<li class="rounded" style="background:url('+kigolUsers[i][2]+') no-repeat;"><a href="#signUpPop" rel="prettyPhoto" class="rounded" title="'+kigolUsers[i][2]+'"></a></li>';
      }
      jQuery('#newusers01').html(kigolNewUsers);
      
});


function getLastInvites(){
    // set the array values with the hour values
    var arrHours = new Array();
    
    //config the values
    var iniValue = 200;
    var subValue = 8;
    var currentValue = iniValue;
    
    // construct the array
    for(var i=1; i<=24; i++){            
        arrHours[i] = currentValue - subValue;
        currentValue = arrHours[i];
        //alert(arrHours[i]);
    }
  
    var hour = new Date();    
    
    // show :D
    return arrHours[hour.getHours()];
    
 }

function rand(n){
  return(Math.floor(Math.random()*n+1));
}

function getPopularPhoto(){
    
    var photolist = new Array();
    var popularphoto = '';

    photolist[0] = '<li><a href="/i/splash/popular/A-linda-torcida-do-Fluminense.jpg" class="latestItem" rel="prettyPhoto" title="por kigol"><img src="/i/splash/popular/A-linda-torcida-do-Fluminense.jpg" alt="A-linda-torcida-do-Fluminense" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[1] = '<li><a href="/i/splash/popular/Alegria.jpg" class="latestItem" rel="prettyPhoto" title="por kigol kigol"><img src="/i/splash/popular/Alegria.jpg" alt="Alegria" onclick="return false;" /></a></li>';
    photolist[2] = '<li><a href="/i/splash/popular/Andre-Luis-no-Fogao-Nervoso.jpg" class="latestItem" rel="prettyPhoto" title="por Cachumbera"><img src="/i/splash/popular/Andre-Luis-no-Fogao-Nervoso.jpg" alt="Andre-Luis-no-Fogao-Nervoso" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[3] = '<li><a href="/i/splash/popular/Argentina-x-Holanda-1978.jpg" class="latestItem" rel="prettyPhoto" title="por rafaelalaby"><img src="/i/splash/popular/Argentina-x-Holanda-1978.jpg" alt="Argentina-x-Holanda-1978" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[4] = '<li><a href="/i/splash/popular/Australianas-lindas.jpg" class="latestItem" rel="prettyPhoto" title="{__ text=\'posted by\'} kigol"><img src="/i/splash/popular/Australianas-lindas.jpg" alt="Australianas-lindas" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[5] = '<li><a href="/i/splash/popular/Barthes-x-Ronaldo.jpg" class="latestItem" rel="prettyPhoto" title="por kigol"><img src="/i/splash/popular/Barthes-x-Ronaldo.jpg" alt="Barthes-x-Ronaldo" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[6] = '<li><a href="/i/splash/popular/Caninde-uma-casa-portuguesa-com-certeza.jpg" class="latestItem" rel="prettyPhoto" title="por rmicheletti"><img src="/i/splash/popular/Caninde-uma-casa-portuguesa-com-certeza.jpg" alt="Caninde-uma-casa-portuguesa-com-certeza" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[7] = '<li><a href="/i/splash/popular/Carlinhos-Bala-no-Nautico-em-2009.jpg" class="latestItem" rel="prettyPhoto" title="por rmicheletti"><img src="/i/splash/popular/Carlinhos-Bala-no-Nautico-em-2009.jpg" alt="Carlinhos-Bala-no-Nautico-em-2009" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[8] = '<li><a href="/i/splash/popular/Classe-de-Michel-Platini.jpg" class="latestItem" rel="prettyPhoto" title="por paulorodrigues"><img src="/i/splash/popular/Classe-de-Michel-Platini.jpg" alt="Classe-de-Michel-Platini" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[9] = '<li><a href="/i/splash/popular/Copa-eh-beleza.jpg" class="latestItem" rel="prettyPhoto" title="por sydneymunn"><img src="/i/splash/popular/Copa-eh-beleza.jpg" alt="Copa-eh-beleza" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[10] = '<li><a href="/i/splash/popular/Cruzeiro-campeao-rotina.jpg" class="latestItem" rel="prettyPhoto" title="por rmicheletti"><img src="/i/splash/popular/Cruzeiro-campeao-rotina.jpg" alt="Cruzeiro-campeao-rotina" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[11] = '<li><a href="/i/splash/popular/Festa-preparada-para-os-1000-gols-de-Romario.jpg" class="latestItem" rel="prettyPhoto" title="ppor rafaelalaby"><img src="/i/splash/popular/Festa-preparada-para-os-1000-gols-de-Romario.jpg" alt="Festa-preparada-para-os-1000-gols-de-Romario" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[12] = '<li><a href="/i/splash/popular/Furacao-paranaense.jpg" class="latestItem" rel="prettyPhoto" title="por kigol"><img src="/i/splash/popular/Furacao-paranaense.jpg" alt="Furacao-paranaense" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[13] = '<li><a href="/i/splash/popular/Ibrahimovic-na-Internazionale.jpg" class="latestItem" rel="prettyPhoto" title="por paulorodrigues"><img src="/i/splash/popular/Ibrahimovic-na-Internazionale.jpg" alt="Ibrahimovic-na-Internazionale" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[14] = '<li><a href="/i/splash/popular/O-belo-Serra-Dourada.jpg" class="latestItem" rel="prettyPhoto" title="por paulorodrigues"><img src="/i/splash/popular/O-belo-Serra-Dourada.jpg" alt="O-belo-Serra-Dourada" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[15] = '<li><a href="/i/splash/popular/O-bi-mundial-do-Sao-Paulo.jpg" class="latestItem" rel="prettyPhoto" title="por Cachumbera"><img src="/i/splash/popular/O-bi-mundial-do-Sao-Paulo.jpg" alt="O-bi-mundial-do-Sao-Paulo" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[16] = '<li><a href="/i/splash/popular/O-Reizinho-Dener-na-Lusa.jpg" class="latestItem" rel="prettyPhoto" title="por rmicheletti"><img src="/i/splash/popular/O-Reizinho-Dener-na-Lusa.jpg" alt="O-Reizinho-Dener-na-Lusa" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[17] = '<li><a href="/i/splash/popular/O-saudoso-Eneas-na-Portuguesa.jpg" class="latestItem" rel="prettyPhoto" title="por vanillatrixx"><img src="/i/splash/popular/O-saudoso-Eneas-na-Portuguesa.jpg" alt="O-saudoso-Eneas-na-Portuguesa" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[18] = '<li><a href="/i/splash/popular/Opala-em-ritmo-do-Avai.jpg" class="latestItem" rel="prettyPhoto" title="por vanillatrixx"><img src="/i/splash/popular/Opala-em-ritmo-do-Avai.jpg" alt="Opala-em-ritmo-do-Avai" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[19] = '<li><a href="/i/splash/popular/Religiao-e-futebol-se-discutem.jpg" class="latestItem" rel="prettyPhoto" title="por paulorodrigues"><img src="/i/splash/popular/Religiao-e-futebol-se-discutem.jpg" alt="Religiao-e-futebol-se-discutem" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[20] = '<li><a href="/i/splash/popular/A-cara-de-uma-nacao.jpg" class="latestItem" rel="prettyPhoto" title="por rmicheletti"><img src="/i/splash/popular/A-cara-de-uma-nacao.jpg" alt="A-cara-de-uma-nacao" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[21] = '<li><a href="/i/splash/popular/A-elegância-de-Zidane.jpg" class="latestItem" rel="prettyPhoto" title="ppor rafaelalaby"><img src="/i/splash/popular/A-elegância-de-Zidane.jpg" alt="A-elegância-de-Zidane" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[22] = '<li><a href="/i/splash/popular/Bella-Dona.jpg" class="latestItem" rel="prettyPhoto" title="por kigol"><img src="/i/splash/popular/Bella-Dona.jpg" alt="Bella-Dona" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[23] = '<li><a href="/i/splash/popular/Futebol-cerveja-e-mulher--Bom.jpg" class="latestItem" rel="prettyPhoto" title="por paulorodrigues"><img src="/i/splash/popular/Futebol-cerveja-e-mulher--Bom.jpg" alt="Futebol-cerveja-e-mulher--Bom" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[24] = '<li><a href="/i/splash/popular/Futebol-da-sono-de-vez-em-quando.jpg" class="latestItem" rel="prettyPhoto" title="por paulorodrigues"><img src="/i/splash/popular/Futebol-da-sono-de-vez-em-quando.jpg" alt="Futebol-da-sono-de-vez-em-quando" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[25] = '<li><a href="/i/splash/popular/Gol-tatu-Eh-do-Paysandu.jpg" class="latestItem" rel="prettyPhoto" title="por Cachumbera"><img src="/i/splash/popular/Gol-tatu-Eh-do-Paysandu.jpg" alt="Gol-tatu-Eh-do-Paysandu" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[26] = '<li><a href="/i/splash/popular/Italia-campea-em-2006.jpg" class="latestItem" rel="prettyPhoto" title="por rmicheletti"><img src="/i/splash/popular/Italia-campea-em-2006.jpg" alt="Italia-campea-em-2006" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[27] = '<li><a href="/i/splash/popular/Nossa-A-Alemanha-esta-bem.jpg" class="latestItem" rel="prettyPhoto" title="por vanillatrixx"><img src="/i/splash/popular/Nossa-A-Alemanha-esta-bem.jpg" alt="Nossa-A-Alemanha-esta-bem!!" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[28] = '<li><a href="/i/splash/popular/O-eterno-Pacaembu.jpg" class="latestItem" rel="prettyPhoto" title="por paulorodrigues"><img src="/i/splash/popular/O-eterno-Pacaembu.jpg" alt="O-eterno-Pacaembu" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[29] = '<li><a href="/i/splash/popular/Periquito-palmeirense.jpg" class="latestItem" rel="prettyPhoto" title="por davidnurser"><img src="/i/splash/popular/Periquito-palmeirense.jpg" alt="Periquito-palmeirense!!" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[30] = '<li><a href="/i/splash/popular/Ronaldinho-Gaucho--craque-no-Barcelona.jpg" class="latestItem" rel="prettyPhoto" title="por rafaelalaby"><img src="/i/splash/popular/Ronaldinho-Gaucho--craque-no-Barcelona.jpg" alt="Ronaldinho-Gaucho!--craque-no-Barcelona" width="130" height="90" onclick="return false;" /></a></li>';
    photolist[31] = '<li><a href="/i/splash/popular/Romario-craque-tambem-no-Flamengo.jpg" class="latestItem" rel="prettyPhoto" title="por davidnurser"><img src="/i/splash/popular/Romario-craque-tambem-no-Flamengo.jpg" alt="Romario-craque-tambem-no-Flamengo" width="130" height="90" onclick="return false;" /></a></li>';    
    
    for(var i=0; i<5; i++){
    	popularphoto = popularphoto + photolist[rand(32)-1];
    }
    
    return popularphoto;
    
  }

jQuery(document).ready(function(){
	jQuery('.inviteCount').text(getLastInvites());
	jQuery('.popuphoto').html(getPopularPhoto());	
});

