$(document).ready(function(){

	name_pola = new Array();
	value_pola = new Array();
	$("#form_kontakt :text,#form_kontakt textarea").each(function (i) {
		name_pola[i]=$("#form_kontakt :text,#form_kontakt textarea").eq(i).attr('name');
		value_pola[i]=$("#form_kontakt :text,#form_kontakt textarea").eq(i).val();
		
		$("#form_kontakt :text,#form_kontakt textarea").eq(i).focus(function () {
			if(this.value==value_pola[i])this.value='';
			//alert('i '+(i-1))
			//alert('eq '+$(this).eq())
		})
		//$("input[name='"+name_pola+"']").
		$("#form_kontakt :text,#form_kontakt textarea").eq(i).blur(function () {
			if(this.value=='')this.value=value_pola[i];
		})
    });
	
	
    var options_wyslij = {
          //target:        '#myList',   // target element(s) to be updated with server response
          //beforeSubmit:  showRequest,  // pre-submit callback
          url: 'ajax.php',
		  resetForm: true,
          success:       showResponse_tekst
    };
	function showResponse_tekst(responseText, statusText)  {
		alert(responseText);
	}

	$(".ajax").submit(function(){
		$(this).ajaxSubmit(options_wyslij);
	    return false;
	});	

	//$(".lightbox").lightbox();
	//$("html").css({"overflow-y":"scroll"});
	var obl = ($(window).width()-988)/2+734;
	$("#logowanie_top .zakladka").css({"left":obl});
	$("#logowanie_top .zakladka").slideDown(500);
	
	
	$("#logowanie_top .zakladka a").click(function(){
		var offset = $("#logowanie_top").offset();
		if(offset.top==-70)
		{
			$("#logowanie_top").animate({"top": "0"}, "slow");
		}
		else
		{
			$("#logowanie_top").animate({"top": "-70px"}, "slow");		
		}
		return false;
	})

	$("#logowanie_top a.close").click(function(){
		$("#logowanie_top").animate({"top": "-70px"}, "slow");		
		return false;
	})
	
	$(window).resize(function() {
		if($(window).width()<=988)
		{
			$("#logowanie_top").width(988);
			//var obl = ($(window).width()-988)/2+734;
			$("#logowanie_top .zakladka").css({"left":734});
		}
		else
		{
			$("#logowanie_top").width($(window).width());
			var obl = ($(window).width()-988)/2+734;
			$("#logowanie_top .zakladka").css({"left":obl});	
		}
		//$('body').prepend('<div>' + $(window).width() + '</div>');
		
		//var position = $("#logowanie_top .zakladka").position();
		//var poz = ", left: " + position.left + ", top: " + position.top;
		//$("#srodek").html("window width: "+$(window).width()+"<br>obl: "+obl+poz);
		//alert("resize");
	});

});

//$(window).load(function () {
	$(function () {
		$('.anythingSlider').anythingSlider({
      	easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
         autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
         StartStopButton: false,
         delay: 5000,                    // How long between slide transitions in AutoPlay mode
         startStopped: false,            // If autoPlay is on, this can force it to start stopped
         animationTime: 600,             // How long the slide transition takes
         hashTags: true,                 // Should links change the hashtag in the URL?
         buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        	NextBackButtons: false,
			pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        	startText: "Go",             	  // Start text
		   stopText: "Stop",               // Stop text
		   navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
      });
      
		$("#slide-jump").click(function(){
      	$('.anythingSlider').anythingSlider(1);
      });
            
   });
//})


function formatText(index, panel) {
		return "<span>"+index+"</span>";
}   

