$(document).ready(function(){
	/**
	 * added by gWd
	 */
	$('#search input[type=text]').focus(function(){
		if ($(this).attr('value')=='szukaj') $(this).attr('value','');
		else $(this).select();
	});
	$('#search input[type=text]').blur(function(){
		if ($(this).attr('value')=='') $(this).attr('value','szukaj');
	});
	
	// Portfolio hover
	$('a.project').hover( 
		function () {$(this).addClass('hover');
		}, 
		function () {$(this).removeClass('hover');
		}
	);
	//$('.large .img-wrap a').append('<span class="zoom"></span>');
	// Sidemenu
	$('.sidemenu li ul').hide();
	$('.sidemenu li.active ul').show();
	$('.sidemenu li a').click(function() {
		if ($(this).parents().hasClass('active')) {
			return true;
		} else {
			$('.sidemenu li ul').slideUp('slow');
			$('.sidemenu li').removeClass('active');
			$(this).next('ul').slideDown('slow');
			$(this).parent().addClass('active');
			return false;
		}
	});
	// Reset Font Size
	var originalFontSize = $('.font-size').css('font-size');
		$(".resetFont").click(function(){
		$('.font-size').css('font-size', originalFontSize);
		posCounters();
	});
	// Increase Font Size
	$(".increaseFont").click(function(){
		var currentFontSize = $('.font-size').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*1.1;
		if (newFontSize<10) { newFontSize = 10;}
		if (newFontSize>20) { return false;}
		$('.font-size').css('font-size', newFontSize);
		posCounters();
		return false;
	});
	// Decrease Font Size
	$(".decreaseFont").click(function(){
		var currentFontSize = $('.font-size').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*0.9;
		if (newFontSize<8) { return false;}
		$('.font-size').css('font-size', newFontSize);
		posCounters();
		return false;
	});
	//Counter
	$('.user-text ol').css('list-style', 'none');
	user_siblings = $('.user-text ol li');
	for (i=0;i<user_siblings.size();i=i+1){
		$(user_siblings[i]).append('<span class="counter">'+(i+1)+'</span>');
		$('.user-text ol li span.counter').css('font-size', 12);
	}
	
	posCounters = function() {
		$('.user-text ol li').each(function() {
			if ($(this).height() >= 16 ) {
				$(this).children('span.counter').css('top', ($(this).height()-16)/2);
			} 
		});
	};
	posCounters();
	//Photos
	$('.photos span.counter').html(1+'/'+$('.photos .img-wrap img').size());
	$('.photos .img-wrap').cycle({ 
		fx:     'blindX', 
		speed:  'slow', 
		timeout: 0, 
		next:   '.photos .next', 
		prev:   '.photos .prev',
		after:  function(currSlideElement, nextSlideElement, options, forwardFlag) {
			$('.photos span.counter').html((options.currSlide+1)+'/'+options.elements.length);
		}
	});
	//$('.large .img-wrap a').lightBox();
	//Shorts
	$('.shorts .short').css('display', 'block');
	$('.shorts').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 0, 
		next:   '#realiz .next', 
		prev:   '#realiz .prev'
	});
	//Accordion
	$('.ui-accordion .ui-accordion-content').css('height', 94);
	$("#accordion").accordion({ 
		event: 'mouseover', 
		speed: 'fast',
		fillSpace: true
	});
	$("#accordion h3:first-child").addClass('ui-state-active');
});