$(document).ready(function()
{
 $('.onas').hover(function(){$(this).addClass('onas_hover')}, function(){$(this).removeClass('onas_hover')});
 $('.zgodovina').hover(function(){$(this).addClass('zgodovina_hover')}, function(){$(this).removeClass('zgodovina_hover')});
 $('.clani').hover(function(){$(this).addClass('clani_hover')}, function(){$(this).removeClass('clani_hover')});
 $('.forum').hover(function(){$(this).addClass('forum_hover')}, function(){$(this).removeClass('forum_hover')});
 $('.koledar').hover(function(){$(this).addClass('koledar_hover')}, function(){$(this).removeClass('koledar_hover')});
 $('.kontakt').hover(function(){$(this).addClass('kontakt_hover')}, function(){$(this).removeClass('kontakt_hover')});
 
  //$('.topm').hover(function(){$(this).css('background-color','#495678')},function(){$(this).css('background-color','#829657')});
 
  $('.topm').click(function(){
  if($(this).next('ul').is(":hidden")) 
  {
   $(this).next('ul').slideDown();
 	 $(this).css('background','#495678');
  } 
  else 
  {
   $(this).next('ul').slideUp();
   $(this).css('background','#829657');
  };
 });
 
   jQuery('#mycarousel').jcarousel({
        // Configuration goes here
    });
 
 $('#clang').click(function(){
   $('#clanx').slideToggle("slow");

 });
 
 $('#gallery a').lightBox();
 $('.lightbox').lightBox();
});

function hideBox()
{
 $("#popup").hide();
}

function showUser(id,obj)
{
 var p = $(obj).position();
 var y = p.top + 20;
 var x = p.left;
 $("#popup").css("left",x+"px");
 $("#popup").css("top",y+"px");
 $("#popup").load("includes/showUser.php?id="+id);
 $("#popup").show();
}

function checkSignup()
{
 var t = ($('input:checkbox').attr('checked'));
 if(t == true)
 {
  $('.required2').css('color','#900');
 }
 else
 {
  $('.required2').css('color','#333');
 }
 $('form :input').filter('.required').after('&nbsp;*');
 $('form :input').blur(function(){
 var ime2 = '';
 $('#infoBox').empty();
 $('form :input').filter('.required').each(function(){
      	if(this.value == '')
   	   	{
   	   		//alert("ime");
   	   		var ime = $(this).prev('span').text();
   	   		ime2 = ime2 + '<span class="error">Polje <b>"'+ime+'"</b> je potrebno izpolniti!</span><br/>';
   	   	}
        else if($(this).is("#email"))
        {
         var email = this.value;
         if(this.value != '' && !/.+@.+\.[a-zA-z]{2,4}$/.test(this.value)){
          $ime2 = ime2 + '<span class="error">Preverite vaš email naslov!</span><br/>';
         }
      	}

   });
 	 $('#infoBox').append(ime2+'<br/>');

  });

  // Validate form input
  $('form').submit(function(){
    var p = 0;
    $('#infoBox').html('');
    $('form :input').filter('.required').each(function(){
      if(this.value == '')
      {
       p++;
       var ime = $(this).prev('span').text();
       
       if(ime == '')
       {
       }
       else
        $('#infoBox').append('<span class="error">Polje <b>."'+ime+'".</b> je potrebno izpolniti!</span><br/>');
      }
      else if($(this).is("#email"))
      {
       if(this.value != '' && !/.+@.+\.[a-zA-z]{2,4}$/.test(this.value)){
       		alert("Napaka v email naslovu!");
        $('#infoBox').append('<span class="error">Preverite vaš email naslov!</span><br/>');
        p++;
      	}
      }
    });
    
    
    $('form :input').filter('.agree').each(function(){
     if(this.value == 0)
      p++;
      $('#infoBox').append('<span class="error">Obkljukajte pogoje pogoje uporabe</span><br/>');
     });

    if(p < 3)
    {
     var str = $('form').serialize();
     $.post("registracija.php",str,function(data){
      $('#prijava').html(data);
     });
     
    }

   	 return false;
  });
}



function checkSignup()
{
/*
 $('form :input').filter('.required').after('&nbsp;*');
 $('form :input').blur(function(){
 var ime2 = '';
 $('#infoBox').empty();
 $('form :input').filter('.required').each(function(){
      	if(this.value == '')
   	   	{
   	   		//alert("ime");
   	   		var ime = $(this).prev('span').text();
   	   		ime2 = ime2 + '<span class="error">Polje <b>"'+ime+'"</b> je potrebno izpolniti!</span><br/>';
   	   	}
        else if($(this).is("#email"))
        {
         var email = this.value;
         if(this.value != '' && !/.+@.+\.[a-zA-z]{2,4}$/.test(this.value)){
          $ime2 = ime2 + '<span class="error">Preverite vaš email naslov!</span><br/>';
         }
      	}

   });
 	 $('#infoBox').append(ime2+'<br/>');

  });
*/
}

