function set(){
	if(navigator.appName == 'Microsoft Internet Explorer'){
		setInterval("blink1IE()",5000);
		setInterval("blink2IE()",6000);
	}else{
		setInterval("blink1()",5000);
		setInterval("blink2()",6000);
	}
	$(document).ready(function() {
		loaded();
	});
	$('button').click(function(){
		$('button').parent().fadeOut('slow');
	});
	$(document).ready(function() {
		$('div.additional_info div').css('display','none');
	});
	$('a.details').click(function(){
		$(this).parent().find('div:visible').first().hide(200);
		$(this).parent().find('div:hidden').first().show(200);
	});
	$('#mailingmail').focusin(function(){
		if($(this).val()=='Wpisz adres e-mail'){
			$(this).val('');
		}
	});
	$('#mailingmail').focusout(function(){
		if($(this).val()==''){
			$(this).val('Wpisz adres e-mail');
		}
	});
	$('#content_scroll').css('overflow','hidden');
	$('#content_scroll').mousewheel(function(event, delta) {
		var val=$('#scroll').slider( "option", "value");
		var newVal;
		if(delta>0){
			newVal=val+10;
			if(newVal>100)newVal=100;
		}else if(delta<0){
			newVal=val-10;
			if(newVal<0)newVal=0;
		}
		$('#scroll').slider( "option", "value", newVal);
		moveContent();
		return false;
	});
	$('#scroll').slider({min:0, max:100, orientation: 'vertical'});
	$('#scroll').bind('slide', moveContent);  
	$('#scroll').bind('change', moveContent);
	$('#scroll').slider( "option", "value", 100 );
	$('.ui-slider-handle').corner('2px');
}
function moveContent(e, ui) {
    var v;
    if (typeof ui != 'undefined' && ui != null)
        v = 100-ui.value;
    else if (typeof $('#scroll').data('slider') != 'undefined')
        v = 100-$('#scroll').data('slider').value();
    var w = $("#page").height() - $("#content").height();
    $('#page').css('top', (-v * w /100) + 'px');
}
/*
function setScroll(){
	$(document).ready(function() {
		$("#content_scroll").mousewheel(function(event, delta) {
			moveContent(event, delta);
			if(delta>0){
				scrollUp(120, 100);
			}else if(delta<0){
				scrollDown(120, 100);
			}
			//return false;
		});
	});
}
*/
function scrollDown(move, time){
	var offset=parseInt($('#page').css('top'));
	var height=parseInt($('#page').height());
	var parentHeight=parseInt($('#page').parent().height());
	//document.write(height);
	var newoffset=offset-move;
	if(newoffset<-(height-parentHeight)){
		newoffset=-(height-parentHeight);
	}
	$('#page').animate({
		top: newoffset
	}, time );
	return false;
}

function scrollUp(move, time){
	var offset=parseInt($('#page').css('top'));
	var height=parseInt($('#page').height());
	var parentHeight=parseInt($('#page').parent().height());
	//document.write(height);
	var newoffset=offset+move;
	if(newoffset>0){
		newoffset=0;
	}
	$('#page').animate({
		top: newoffset
	}, time );
	return false;
}

function blink1() {
$("#image").animate({
		opacity: 0.1
	}, 75 ).delay(50).animate({
		opacity: 1
	}, 75 ).delay(50).animate({
		opacity: 0.2
	}, 25 ).delay(50).animate({
		opacity: 1
	}, 50 );
}

function blink2() {
	$("#light").animate({
		opacity: 0.5
	}, 10 ).delay(25).animate({
		opacity: 1
	}, 10 ).delay(25).animate({
		opacity: 0.5
	}, 10 ).delay(25).animate({
		opacity: 1
	}, 10 ).delay(1000).animate({
		opacity: 0.8
	}, 500 ).delay(100).animate({
		opacity: 1
	}, 700 ).delay(500).animate({
		opacity: 0.4
	}, 25 ).delay(25).animate({
		opacity: 1
	}, 50 );
}

function blink1IE() {
	$("#image").animate({
		'filter': 'alpha(opacity=20)'
	},100).delay(200).animate({
		'filter': ''
	},50).delay(100).animate({
		'filter': 'alpha(opacity=0)'
	},10).delay(50).animate({
		'filter': ''
	},200);
}

function blink2IE(){
	$("#light").animate({
		'filter': 'alpha(opacity=0)'
	},10).delay(200).animate({
		'filter': ''
	},10).delay(50).animate({
		'filter': 'alpha(opacity=0)'
	},10).delay(400).animate({
		'filter': ''
	},10).delay(50).animate({
		'filter': 'alpha(opacity=0)'
	},10).delay(100).animate({
		'filter': ''
	},10);
}

function preload(){
	$('#preload').css('position', 'fixed');
	$('#preload').css('width', '100%');
	$('#preload').css('height', '100%');
	$('#preload').css('z-index', '3');
	$('#preload').css('background', '#25800b');
	$('#preload div').css('position', 'absolute');
	$('#preload div').css('top', '40%');
	$('#preload div').css('bottom', '40%');
	//$('#preload div').css('left', '40%');
	//$('#preload div').css('right', '40%');
	$('#preload div').css('color', '#ffffff');
	$('#preload div').css('width', '100%');
	$('#preload div').css('height', '20%');
	$('#preload div').css('text-align', 'center');
	
	$('#preload div').html('<img src="img/loading.gif"/><br/>Ładowanie strony...<br/><br/><span style="font-size: 12px; color: #2222bb; cursor: pointer; text-decoration: underline;" onclick="loaded()">Za wolno? Kliknij.</span>');
}

function loaded(){
	$("#preload").fadeOut(2000);
}
