$(window).bind('load', function() {
	$('#loading-realistations').hide();
	$('#loaded-content').show();
});

$(function() { 	
	// NASI KLIENCI
	$('#NKlienci table tr:last-child').addClass('last');


	// REALISATIONS 
			$('.item').hover(
				function () {
					//$('.overlay',this).attr('style','z-index: 9999 !important;');
					$('.overlay',this).show();
				}, 
				function () {
					$('.overlay',this).hide();
				}
			); 
			
			$('.img-controls a').click(function() {
				var ID = '#'+$(this).attr('rel');
				var IDimg = '#'+$(this).attr('rel')+' .'+$(this).attr('rel');
				
				$(IDimg).attr('src','');
				$(IDimg).fadeOut(120)
				
				$(ID+' .img-controls a').each(function() {
					$(this).removeClass('current');
				});
				$(this).addClass('current');
				
				$(IDimg).attr('src',$(this).attr('href'));
				
				$(IDimg).bind('load',
					function () {
						$(IDimg).fadeIn(300);
					});
				
				return false;
			});
			
			
			$('.item-control a').click(function() {
				$('#div-'+$(this).attr('id')).slideToggle(400);
				if ($(this).hasClass('collapse'))
					$(this).removeClass('collapse');
				else
					$(this).addClass('collapse');
			}); 
	
			$('#realizaje-top').click(function() {
					$.scrollTo('#breadcrumbs', 1250);
					return false;
			});
	

	
		//facebook widget

		$("#facebook").hover(function(){

				$(this).stop(true, false).animate({right:"0"},"medium");

		},function(){

				$(this).stop(true, false).animate({right:"-332"},"medium");

		},500);


	/*
	$('#facebook .working').click(
		function() {
			if ($('#facebook .widget').is(':visible')) 
				$('#facebook .widget').stop(true, false).animate({width: 'hide'});
			else
				$('#facebook .widget').stop(true, false).animate({width: 'show'});
			return false;
	});*/
	
	
	$('#newsletter .text').focus(function(){
		if($('#newsletter .text').attr('value') == 'adres e-mail...')
			$('#newsletter .text').attr('value','');
	});
	
	$('#newsletter .text').blur(function(){
		if($('#newsletter .text').attr('value') == '')
			$('#newsletter .text').attr('value','adres e-mail...');
	});

        /*
	$('#facebook .button .working').mouseover(function() {
			$('#facebook .button a').removeClass('working');
			$('#facebook .button a').addClass('active');
			$('#facebook .widget').animate({width: 'show'});
	});
	
	$('#facebook .widget').mouseout(function() {
		$('#facebook .widget').animate({width: 'hide'});
		$('#facebook .button a').removeClass('active');
		$('#facebook .button a').addClass('working');
	});
	*/
	
	//LIGHTBOX 
			$("a[rel='lightbox']").colorbox();
			$("a[rel='lightbox2']").colorbox();
	
	// SLIDER
			$('#slides').cycle({ pager: '#slider-controls' });
			$('#last-real .slides').cycle({ fx: 'scrollHorz', next: '#next', prev: '#prev', speed: 200, timeout: 0  });

	// CUFON
			Cufon.replace("#header_title, .header_title");
			Cufon.replace("span.name, span.www", { textShadow: '1px 1px #444' });
			
			$('.slides .slide').each(function() {
				$(this).addClass('cycled');
			});
	
});



