$(document).ready(function() {

/* Panel zapytaj nas*/
$("#openclosepanel, #open_right_panel").click( function() {
	ukryj_diva();
}); 

function ukryj_diva(){
if ($("#openclosepanel").is(":hidden")) {
		$("#panel").animate({ 
			marginRight: "-243px"
			}, 500 );
			$("#panel #openclosepanel").removeClass('open_right_panel').addClass('open_left_panel');
			$("#openclosepanel").show();
	} else {
		$("#panel").animate({ 
			marginRight: "0px"
			}, 500 );
			$("#panel #openclosepanel").removeClass('open_left_panel').addClass('open_right_panel');
			$("#openclosepanel").hide();
	}
}
//animacja boxow strona glowna
/*
$("#id4e575ab502177 #id4e5b4504ae97b #columns #1box").animate({opacity: "1"}, 900)
	.animate({opacity: "1"}, {
		complete:
			function(){	
			$("#id4e575ab502177 #id4e5b4504ae97b #columns #1box").animate({opacity: "0.7", left: "+=330"}, 1100)
			.animate({opacity: "1", left: "0"}, "slow")
			.animate({top: "0"}, "slow");
	
			$("#id4e575ab502177 #id4e5b4504ae97b #columns #2box").animate({opacity: "0.7", right: "+=330"}, 1100)
			.animate({opacity: "1", left: "0"}, "slow")
			.animate({top: "0"}, {
		complete: 
			function(){		
			$("#id4e575ab502177 #id4e5b4504ae97b #columns #1box").animate({opacity: "0.7", left: "+=330"}, 800)
			.animate({opacity: "0.7", top: "+=250"}, "medium")
			.animate({opacity: "1", left: "0"}, "slow")
			.animate({top: "0"}, "slow");
		
			$("#id4e575ab502177 #id4e5b4504ae97b #columns #4box").animate({opacity: "0.7", right: "+=330"}, 800)
			.animate({opacity: "0.7", bottom: "+=250", "easing": "easein"}, "medium")
			.animate({opacity: "1", right: "0"}, "slow")
			.animate({bottom: "0"}, "slow");}
		})
	}
});
*/

/*usuniecie niektorych pol z newsow strona glowna*/
$('#id4e5c88f21a95e div .godzina, #id4e5c88f21a95e div .autor, #id4e5c88f21a95e .stronicowanie').remove();

/*BOXY*/
$('.widget-content').hover(function() {
	$(this).find('img').fadeOut();
	$(this).find('div.caption').fadeIn(200);
},
function() {
	$(this).find('img').fadeIn();	
	$(this).find('div.caption').fadeOut(200);
});


/*FONT*/
Cufon.replace('#id4e5b4504ae97b h3, #id4e5c88f21a18e h3, #id4e5f6d0d49b7a .news .tytul, #id4e7318109a15c h3, #id4e7af0bba513d .tytul, #id4e5f6d0d493a3 .tytul, #panel_zapytaj .panel_tekst h3');


/*LOGA KLIENTOW*/
$("#klienci").smoothDivScroll({autoScroll: "always", autoScrollDirection: "endlessloopleft", autoScrollStep: 1, autoScrollInterval: 45});

$("#klienci").bind("mouseover", function() {
	$(this).smoothDivScroll("stopAutoScroll");
}).bind("mouseout", function() {
	$(this).smoothDivScroll("startAutoScroll");
});

//$("#klienci .scrollWrapper .scrollableArea a").fadeTo("slow", 1.0);
$("#klienci .scrollWrapper .scrollableArea a").hover(function() {
	$(this).fadeTo("slow", 0.6);
}, function() {
    $(this).fadeTo("slow", 1.0);
});


/*menu*/
$('#nav').spasticNav();
$("#nav li:nth-child(8)").css({"background-color":"none","border-right":"0px"});

});

/*MENU*/
(function($) {

	$.fn.spasticNav = function(options) {
	
		options = $.extend({
			overlap : 0,
			speed : 500,
			reset : 500,
			color : '#8e99a3',
			easing : 'easeOutExpo'
		}, options);
	
		return this.each(function() {
		
		 	var nav = $(this),
		 		currentPageItem = $('#selected', nav),
		 		blob,
		 		reset;
		 		
		 	$('<li id="blob"></li>').css({
		 		width : currentPageItem.outerWidth(),
		 		height : currentPageItem.outerHeight() + options.overlap,
		 		left : currentPageItem.position().left,
		 		top : currentPageItem.position().top - options.overlap / 2,
		 		backgroundColor : options.color
		 	}).appendTo(this);
		 	
		 	blob = $('#blob', nav);
		 	
			$('li:not(#blob)', nav).hover(function() {
				// mouse over
				clearTimeout(reset);
				blob.animate(
					{
						left : $(this).position().left,
						width : $(this).width()
					},
					{
						duration : options.speed,
						easing : options.easing,
						queue : false
					}
				);
			}, function() {
				// mouse out	
				reset = setTimeout(function() {
					blob.animate({
						width : currentPageItem.outerWidth(),
						left : currentPageItem.position().left
					}, options.speed)
				}, options.reset);
	
			});
		
		}); // end each
	
	};

})(jQuery);

/*AJAX FORM*/
function wyslij_form(){
var name=jQuery("#name").val();
var email=jQuery("#e-mail").val();
var pytanie=jQuery("#pytanie").val();
var rcpt=jQuery("input[name=rcpt]").val();

	$.ajax({
	type: "POST",
	url:"/187-42036959bdbf4-send_form_html.htm",
	data: "Name="+name+"&e-mail="+email+"&Pytanie="+pytanie+"&rcpt="+rcpt+"&ajax_form_html=1",
	success: function(msg){
	
	jQuery("#name").val('');
	jQuery("#e-mail").val('');
	jQuery("#pytanie").val('');
		$("#panel").animate({ 
			marginRight: "-243px"
			}, 500 );
			$("#panel #openclosepanel").removeClass('open_right_panel').addClass('open_left_panel');
			$("#openclosepanel").show();
	//alert("Wyslano");		
	}
	});
	return false;
}
