$(document).submit(function() {
	document.getElementById("loader_form").className = "loader_form_pokaz";
  	$("select").css("visibility","hidden");
	$("#loader_form").css("top", (($(window).height() - $("#loader_form").height()) / 2) + $(window).scrollTop());
	$("#loader_form").css("left", ($(window).width() - $("#loader_form").width()) / 2);	
});	


function btnZmOver (nazwa, plik) {
	document.getElementById(nazwa).src=plik;
}

function btnZmOut (nazwa, plik) {
	document.getElementById(nazwa).src=plik;
}

function kursor (ob) {
  	ob.style.cursor = "pointer";
}

function fota_pokaz_podglad (id) {
	document.getElementById(id).className = 'podglad_foty_pokaz'; 
}
function fota_ukryj_podglad (id) {
	document.getElementById(id).className = 'podglad_foty_ukryj'; 
}

function otworz_zamknij (id) {
  	if (document.getElementById(id).className == 'ukryj')
  		document.getElementById(id).className = '';
	else
		document.getElementById(id).className = 'ukryj';
}


function wlacz_wylacz_stan_magazynowy (ob, nr) {
  	if (ob.checked){
    	document.getElementById("ID_czy_dostepne"+nr).disabled = true; 
    	document.getElementById("ID_stan_magazynowy"+nr).disabled = false; 
    	document.getElementById("ID_stan_magazynowy_dodaj"+nr).disabled = false; 
    	document.getElementById("ID_blok_koszGdy0wMag"+nr).disabled = false; 
    	
    	
    	
    	document.getElementById("ID_kolA"+nr).style.backgroundColor = "#E5B4B4";
    	document.getElementById("ID_kolB"+nr).style.backgroundColor = "#BFD8BF";
    	
    	document.getElementById("ID_czy_dostepne"+nr).style.backgroundColor = "#E5B4B4";
    	document.getElementById("ID_stan_magazynowy"+nr).style.backgroundColor = "#BFD8BF"; 
    	document.getElementById("ID_stan_magazynowy_dodaj"+nr).style.backgroundColor = "#BFD8BF"; 
    	document.getElementById("ID_blok_koszGdy0wMag"+nr).style.backgroundColor = "#BFD8BF"; 
	} else {
    	document.getElementById("ID_stan_magazynowy_dodaj"+nr).disabled = true; 
    	document.getElementById("ID_stan_magazynowy"+nr).disabled = true; 
    	document.getElementById("ID_blok_koszGdy0wMag"+nr).disabled = true;
    	document.getElementById("ID_czy_dostepne"+nr).disabled = false; 

    	document.getElementById("ID_kolA"+nr).style.backgroundColor = "#BFD8BF";
    	document.getElementById("ID_kolB"+nr).style.backgroundColor = "#E5B4B4";

    	document.getElementById("ID_czy_dostepne"+nr).style.backgroundColor = "#BFD8BF"; 
    	document.getElementById("ID_stan_magazynowy"+nr).style.backgroundColor = "#E5B4B4";
    	document.getElementById("ID_stan_magazynowy_dodaj"+nr).style.backgroundColor = "#E5B4B4"; 
    	document.getElementById("ID_blok_koszGdy0wMag"+nr).style.backgroundColor = "#E5B4B4";     
  	}
}



function otworz_zamknij_jquery (id) {

	$('#'+id).animate(
		{	height: 'toggle'},
		{	duration: 1000, 
			specialEasing: {
				height: 'easeOutBounce'}, 
				complete: function() { 
				  //alert(document.getElementById('stan_RZ_'+id).value);
				  	if (document.getElementById('stan_RZ_'+id).value == '0')
				  		document.getElementById('stan_RZ_'+id).value = 'off';
				  	else
				  		document.getElementById('stan_RZ_'+id).value = '0';
		    		$(this).after('<div class="ukryj_RZ"></div>'),
		    		rob(id)
		  }
	});
}
function rob (id) {
  	
	//alert(document.getElementById('stan_RZ_'+id).value);
}





//animacja dla boxy - realizacje ===============================================
var B_ile = 0;
var akt_B = 1;
var nr_krok = 1;
var petla = 1;
var ost = 0;
var blokuj = false;
function animuj_boxy () {

  	if (blokuj) {
  	  	akt_B = ost;
  	  	blokuj = false;
 		przenikanie_boxow ();
     
   	} else {
		if ((akt_B+1) <= B_ile) B_akt_next = akt_B+1; else B_akt_next = 1; 	
 		if (B_akt_next != akt_B) przenikanie_boxow ();
	}	 	
}

function przenikanie_boxow () {
  	var css1 = '';
  	var css2 = '';
  	ost = B_akt_next;

  	switch (nr_krok) {
    	case 1: css1 = 'box_pokaz'; css2 = 'box_ukryj'; break;
    	case 2: css1 = 'box_pokaz80'; css2 = 'box_pokaz20'; break;
    	case 3: css1 = 'box_pokaz60'; css2 = 'box_pokaz40'; break;
    	case 4: css1 = 'box_pokaz40'; css2 = 'box_pokaz60'; break;
    	case 5: css1 = 'box_pokaz20'; css2 = 'box_pokaz80'; break;
    	case 6: css1 = 'box_ukryj'; css2 = 'box_pokaz'; break;
	}
  	document.getElementById("BS_"+akt_B).className = css1; 
  	document.getElementById("BS_"+B_akt_next).className = css2;  
  	
  	nr_krok += 1;
	if (nr_krok == 7) {
	  	akt_B = B_akt_next;
	  	nr_krok = 1;
	  	kolejny_box();
	} else
	  	setTimeout("przenikanie_boxow()",50);
}


function kolejny_box () {
  	petla++;
  	if (petla >= 300) {
  	  	petla = 0;
 		setTimeout("animuj_boxy()",10);
 	} else
	 	setTimeout("kolejny_box()",10);	
}

function next_box () {
  	if ((akt_B+1) <= B_ile) kolejny = akt_B+1; else kolejny = 1; 	
	kolejny_box_nr(kolejny);
}
function prev_box () {
  	if ((akt_B-1) <= 0) kolejny = B_ile; else kolejny = akt_B-1; 	
	kolejny_box_nr(kolejny);
}  
  
function kolejny_box_nr (nr) {
  	if (nr == ost) return;
  	blokuj = true;
  	B_akt_next = nr;  	
  	petla = 300;
}

function liczba_boxow (b1) {
  	B_ile = b1;
  	setTimeout("animuj_boxy ()",1000);
}

