$(function(){ try {
	$('a[rel~=external]').attr('target','_blank');
	$('a[rel~=lightbox]').lightBox({ imageBlank: '/page/images/lightbox-blank.gif', imageLoading: '/page/images/lightbox-ico-loading.gif', imageBtnClose: '/page/images/lightbox-btn-close.gif', imageBtnPrev: '/page/images/lightbox-btn-prev.gif', imageBtnNext: '/page/images/lightbox-btn-next.gif', txtImage: 'Zdjęcie', txtOf: 'z' }); 

// rozmiar kontenerów z tłem	
	if($('#page-background').height() < $(window).height()-78)
		$('#page-background').height($(window).height()-78);

	
// rozwiazania check-all	
	$('#check-all').click(function(){
		$('input:checkbox').attr('checked',true);
	});
	$('#uncheck-all').click(function(){
		$('input:checkbox').attr('checked',false);
	});

// rozwiązania menu
	$(window).scroll(function(){
		if($(window).scrollTop() > 414)
		{
			if((parseInt($('#solution-menu').css('top'))+parseInt($('#solution-menu').css('height'))) > (parseInt($('#page-content').css('height'))+25))
				$('#solution-menu').css('top', parseInt($('#page-content').css('height'))-parseInt($('#solution-menu').css('height'))+25);
			else if(parseInt($('#solution-menu').css('top'))+parseInt($('#solution-menu').css('height')) == parseInt($('#page-content').css('height'))+25)
			{
				if($(window).scrollTop()-30 < parseInt($('#solution-menu').css('top')))
					$('#solution-menu').css('top', $(window).scrollTop()-30);
			}
			else
				$('#solution-menu').css('top', $(window).scrollTop()-30);
		} else
			$('#solution-menu').css('top', 384);
		if((parseInt($('#solution-menu').css('top'))+parseInt($('#solution-menu').css('height'))) > (parseInt($('#page-content').css('height'))+25))
			$('#solution-menu').css('top', parseInt($('#page-content').css('height'))-parseInt($('#solution-menu').css('height'))+25);
	});
	
// top menu
	var text = $('#top-menu li').last().html();
	$('#top-menu li').last().html(text.substr(0,text.length-3));
	
	$('#top-menu .li0').has('ul').mouseover(function(){
		if(!$(this).hasClass('item-empty'))
			$(this).children('ul').show();
	});
	$('#top-menu .li0').has('ul').mouseout(function(){
		$(this).children('ul').hide();
	});
	
// strefa klienta - rejest logowań
	if($('.log-list').length < 10)
		$('#log-nav').hide();
	else{
		$('.log-new').hide();
		$('.log-list').hide();
		$('.log-list').slice(parseInt($('#log-nav').attr('alt')),parseInt($('#log-nav').attr('alt'))+10).each(function(){ $(this).show(); });
		$('.log-new').click(function()
		{
			if(parseInt($('#log-nav').attr('alt')) > 0)
			{
				$('#log-nav').attr('alt', parseInt($('#log-nav').attr('alt'))-10);
				$('.log-list').hide();
				$('.log-list').slice(parseInt($('#log-nav').attr('alt')),parseInt($('#log-nav').attr('alt'))+10).each(function(){
					$(this).show();
				});
			}
			if(parseInt($('#log-nav').attr('alt')) <= 0)
				$('.log-new').hide();
			if(parseInt($('#log-nav').attr('alt')) < ($('.log-list').length-10))
				$('.log-old').show();
		});
		$('.log-old').click(function()
		{
			if(parseInt($('#log-nav').attr('alt')) < ($('.log-list').length-10))
			{
				$('#log-nav').attr('alt', parseInt($('#log-nav').attr('alt'))+10);
				$('.log-list').hide();
				$('.log-list').slice(parseInt($('#log-nav').attr('alt')),parseInt($('#log-nav').attr('alt'))+10).each(function(){
					$(this).show();
				});
			}
			if(parseInt($('#log-nav').attr('alt')) > 0)
				$('.log-new').show();
			if(parseInt($('#log-nav').attr('alt')) >= ($('.log-list').length-10))
				$('.log-old').hide();
		});
	}
	
	
// strefa klienta - wiadomości
	if($('.message').length > 2)
	{
		$('.message-new').hide();
		$('.message').hide();
		$('.message').slice(parseInt($('#message-nav').attr('alt')),parseInt($('#message-nav').attr('alt'))+2).each(function(){ $(this).show(); });
		$('.message-new').click(function()
		{
			if(parseInt($('#message-nav').attr('alt')) > 0)
			{
				$('#message-nav').attr('alt', parseInt($('#message-nav').attr('alt'))-1);
				$('.message').hide();
				$('.message').slice(parseInt($('#message-nav').attr('alt')),parseInt($('#message-nav').attr('alt'))+2).each(function(){
					$(this).show();
				});
			}
			if(parseInt($('#message-nav').attr('alt')) <= 0)
				$('.message-new').hide();
			if(parseInt($('#message-nav').attr('alt')) < ($('.message').length-2))
				$('.message-old').show();
		});
		$('.message-old').click(function()
		{
			if(parseInt($('#message-nav').attr('alt')) < ($('.message').length-2))
			{
				$('#message-nav').attr('alt', parseInt($('#message-nav').attr('alt'))+1);
				$('.message').hide();
				$('.message').slice(parseInt($('#message-nav').attr('alt')),parseInt($('#message-nav').attr('alt'))+2).each(function(){
					$(this).show();
				});
			}
			if(parseInt($('#message-nav').attr('alt')) > 0)
				$('.message-new').show();
			if(parseInt($('#message-nav').attr('alt')) >= ($('.message').length-2))
				$('.message-old').hide();
		});
	}else
		$('#message-nav').hide();

// strefa klienta chowanie struktury
	$('#file-content .inside').addClass('hidden');
	$('#file-content .file').addClass('hidden');
	$('#file-content .cat').eq(0).addClass('selected');
	$('#file-content ul').eq(0).children().removeClass('hidden');
	$('#file-content li').click(function(){
		if($(this).attr('id'))
		{
			var ulId = '.'+$(this).attr('id');
			if($(ulId).hasClass('hidden'))
			{
				$(this).addClass('selected visible');
				$(ulId).removeClass('hidden');
			}else
			{
				$(this).removeClass('selected visible');
				$(ulId).addClass('hidden');
			}
		}
	});
		
// kontakt
	$('#contact-name').focusout(function(){
		if($(this).attr('value')=='')
			$(this).attr('value','Imię i nazwisko lub firma');
	});
	$('#contact-name').focusin(function(){
		$(this).removeClass('red');
		if($(this).attr('value')=='Imię i nazwisko lub firma')
			$(this).attr('value','');
	});
	
	$('#contact-mail').focusout(function(){
		if($(this).attr('value')=='')
			$(this).attr('value','e-mail lub telefon kontaktowy');
	});
	$('#contact-mail').focusin(function(){
		$(this).removeClass('red');
		if($(this).attr('value')=='e-mail lub telefon kontaktowy')
			$(this).attr('value','');
	});
	
	$('#contact-topic').focusout(function(){
		if($(this).attr('value')=='')
			$(this).attr('value','temat zapytania');
	});
	$('#contact-topic').focusin(function(){
		$(this).removeClass();
		if($(this).attr('value')=='temat zapytania')
			$(this).attr('value','');
	});
	
	$('#contact-question').focusout(function(){
		if($(this).text()=='')
			$(this).text('treść zapytania');
	});
	$('#contact-question').focusin(function(){
		$(this).removeClass();
		if($(this).text()=='treść zapytania')
			$(this).text('');
	});
	$('#captchainput').focusout(function(){
		if($(this).attr('value')=='')
			$(this).attr('value','PRZEPISZ TREŚĆ Z OBRAZKA');
	});
	$('#captchainput').focusin(function(){
		$(this).removeClass();
		if($(this).attr('value')=='PRZEPISZ TREŚĆ Z OBRAZKA')
			$(this).attr('value','');
	});
	$('#contact-submit').click(function() 
	{
		if($('#contact-name').attr('value')=='Imię i nazwisko lub firma')
			$('#contact-name').attr('value', '');
		if($('#contact-mail').attr('value')=='e-mail lub telefon kontaktowy')
			$('#contact-mail').attr('value', '');
		if($('#contact-topic').attr('value')=='temat zapytania')
			$('#contact-topic').attr('value', '');
		if($('#contact-question').text()=='treść zapytania')
			$('#contact-question').text('');
	});
	$('#contact-reset').click(function(){
		$('#contact-name').attr('value', 'Imię i nazwisko lub firma');
		$('#contact-mail').attr('value', 'e-mail lub telefon kontaktowy');
		$('#contact-topic').attr('value', 'temat zapytania');
		$('#contact-question').text('treść zapytania');
		$('#captchainput').attr('value', 'PRZEPISZ TREŚĆ Z OBRAZKA');
	});
	$('#captcha').css('cursor', 'pointer');
	$('#captcha').click( function()
	{
		var iPos = this.src.indexOf('?');
		if(iPos>-1)
			this.src = this.src.substring(0,iPos)+'?'+(new Date()).getTime();
		else
			this.src = this.src+'?'+(new Date()).getTime();
		return false;
	});
	
} catch(e) { alert(e); }; });


$(document).ready(function() {
	$('#banner img').last().css('width', $('#banner img').first().css('width'));
	
	$('#reference-items').css('width', 175*($('#reference-items').children().size() + 2));
	$("#reference-scroll").scrollable({items: '#reference-items', next: 'a#reference-arrow-right',prev: 'a#reference-arrow-left', circular: true}).autoscroll({interval: 9000});
	
	$('#implementation-items').css('width', 175*($('#implementation-items').children().size() + 2));
	$("#implementation-scroll").scrollable({items: '#implementation-items', next: 'a#implementation-arrow-right',prev: 'a#implementation-arrow-left', circular: true}).autoscroll({interval: 9000});
});

