var timer;

$(document).ready(function(){
	$.fx.speeds._default = 500;
	
	var klasa = $('#flashMessage').attr('class');
	$('#flashMessage').dialog({
		hide: 'puff',
		draggable: false,
		modal: true,
		resizable: false,
		dialogClass: klasa
	});
	
	var time = $('#flashMessage').attr('rel') !== undefined ? $('#flashMessage').attr('rel') : 1500;
		
	setTimeout(function(){$('#flashMessage').dialog("close") }, time);
	
	$('#banner-layer').dialog({
		hide: 'puff',
		draggable: false,
		modal: true,
		resizable: false,
		width: 600,
		height: 400
	});
	
	$('.form-input').click(function(){
		$(this).val('');
	});
	
	$('#menu a').last().css('border-right', 'none');
	
	var clients = $('#klienci img');
	clients.hide();
	clients.first().show().addClass('active');
	
	timer = setInterval('changeClients()', 5000);
	
	$(".dropdown dt a").click(function() {
        $(".dropdown dd ul").toggle();
	});
	
	$(".dropdown dd ul li a").click(function() {
		$(".dropdown dd ul").hide();
	});
	
	$(".dropdown dd ul li").last().css('border-bottom', 'none');
});

$(document).bind('click', function(e) {
    var $clicked = $(e.target);
    if (! $clicked.parents().hasClass("dropdown")){
        $(".dropdown dd ul").hide();
	}
});

function changeClients(){
	var active = $('#klienci .active');
	var next = active.next('img');
		
	if(next.length == 0){
		next = $('#klienci img').first();
	}
		
	active.removeClass('active').fadeOut('', function(){
		next.addClass('active').fadeIn();
	});
}
