/* nmq..
jQuery(document).ready(function() { 
	jQuery('ul.nav').superfish(); 
	jQuery('ul.topnav').superfish(); 
}); 
*/

/* Tabs */
jQuery(document).ready(function(){
       //var tag_cloud_class = '#tag-cloud'; 
       //Fix for tag clouds - unexpected height before .hide() 
       // var tag_cloud_height = jQuery('#tag-cloud').height();

       //jQuery('.inside ul li:last-child').css('border-bottom','1px') // remove last border-bottom from list in tab conten
       jQuery('.tabs').each(function(){
	   var tab_afirst = jQuery(this).children('li').children('a:first');
       tab_afirst.addClass('selected'); // Add .selected class to first tab on load
	   
	   
       });
	   
       jQuery('.inside > *').hide();
       jQuery('.inside > *:first-child').show();
       
       jQuery('.tabs li a').click(function(evt){ // Init Click funtion on Tabs
        
            var clicked_tab_ref = jQuery(this).attr('href'); // Strore Href value
            
            jQuery(this).parent().parent().children('li').children('a').removeClass('selected'); //Remove selected from all tabs
            jQuery(this).addClass('selected');
            jQuery(this).parent().parent().parent().children('.inside').children('*').hide();
			
			var this_insidea =  jQuery('.inside ' + clicked_tab_ref);
            this_insidea.fadeIn(500);
			
			evt.preventDefault();	

			// vaxt ferqi ucun ;
			var now_time = new Date().getTime();
			var time_dif = now_time - this_insidea.data("settime");
			if(isNaN(time_dif)) time_dif = 80000;
			
			if(clicked_tab_ref == "#jsvote" && time_dif > 10000) {
			 this_insidea.html("<center><img src=\"images/loading.gif\" border=0></center>");
			 this_insidea.load("ajax.php?mod=Voting_ajax");
			 this_insidea.data("settime", now_time);
			}
			
			if(clicked_tab_ref == "#jsarxiv" && time_dif > 20000) {
			 this_insidea.html("<center><img src=\"images/loading.gif\" border=0></center>");
			 this_insidea.load("ajax.php?mod=news_arxiv");
			 this_insidea.data("settime", now_time);
			}
			
			if(clicked_tab_ref == "#jshava" && time_dif > 20000) {
			 this_insidea.html("<center><img src=\"images/loading.gif\" border=0></center>");
			 this_insidea.load("ajax.php?go=hava");
			 this_insidea.data("settime", now_time);
			}
			
			if(clicked_tab_ref == "#mytopusers" && time_dif > 20000) {
			 this_insidea.html("<center><img src=\"images/loading.gif\" border=0></center>");
			 this_insidea.load("ajax.php?go=mytopusers");
			 this_insidea.data("settime", now_time);
			}
			

        });
    
});
