/*
$(document).ready(function(){
$('#tabs div').hide(); // Hide all divs
$('#tabs div:first').show(); // Show the first div
$('#tabs ul li:first').addClass('active'); // Set the class of the first link to active
$('#tabs ul li a.linkovi').click(function(){ //When any link is clicked
$('#tabs ul 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
$('#tabs div').hide(); // Hide all divs
$(currentTab).show(); // Show div with id equal to variable currentTab
return false;
});
});
function callback(eventObject) {
  this; // dom element
}*/
$(document).ready(function(){
var currentTab = false;

// plugin definition
$.fn.hilight = function(p) {


var broj_stranica=this.length/3;

if(this.length%3>0)
broj_stranica=broj_stranica+1;

if(broj_stranica>1){
var pagination_html;

    for(n=1;n<broj_stranica;n++){
        if(p==n){
            if(pagination_html)
            pagination_html=pagination_html+'<a class="page_activ" href="#">'+n+'</a> | ';    
            else
            pagination_html='<a class="page_activ" href="#">'+n+'</a> | ';        
        }
        else if(!(p)&&(n==1))
        {
            if(pagination_html)
            pagination_html=pagination_html+'<a class="page_activ" href="#">'+n+'</a> | ';    
            else
            pagination_html='<a class="page_activ" href="#">'+n+'</a> | ';    
        }
        else{
            if(pagination_html)
            pagination_html=pagination_html+'<a class="page" href="#">'+n+'</a> | ';
            else
            pagination_html='<a class="page" href="#">'+n+'</a> | ';
        }
    }
    
    $("#pagination").html(pagination_html);
}

    $('.page').click(function(){
    
    if(currentTab)
    $(currentTab+' ul li').hilight(this.innerHTML);
    else
    $('#tabs div:first ul li').hilight(this.innerHTML);
    });

    if(p)
    {
        //this.fadeOut("fast");
        this.css('display','none');
        var start=3*p-3;
        var kraj=3*p;
        for(i=start;i<kraj;i++)
        {
        //alert(i);
        this[i].style.display="block";
        }
    }
    else{
        for(i=0;i<this.length;i++)
        {
        if(i>2)
        this[i].style.display="none";
        }
    }
};

// start function
$('#tabs div:first ul li').hilight(); 

$('#tabs div').hide(); // Hide all divs
$('#tabs div:first').show(); // Show the first div
$('#tabs ul li:first').addClass('active'); // Set the class of the first link to active

$('#tabs ul li a.linkovi').click(function(){ //When any link is clicked
$('#tabs ul li').removeClass('active'); // Remove active class from all links
$(this).parent().addClass('active'); //Set clicked link class to active
currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link

$('#tabs div').hide(); // Hide all divs
$(currentTab).show(); // Show div with id equal to variable currentTab
$(currentTab+' ul li').hilight(1); 
return false;
});
});
