var plik=1;

function prev_img () {
	// Carousel section !
	var wrapper = $('wrap'); // The outer wrapper
	var carousel = $('carousel'); // The inner wrapper
	var items = $$('#carousel li'); // The different elements, this is an array
	var item_width = 195; // The full width of a single item (incl. borders, padding, etc ... if there is any)
	var max_margin = items.length * item_width - item_width;
	
	var animation = new Fx.Tween(carousel, {duration: 500});
	var position = parseInt(carousel.getStyle('left'));
	
	if(position >= 0){
		animation.start('left', 0);
	} else {
		var newposition = position + item_width;
		animation.start('left', newposition);
	}
	return false;
}

function next_img () {
	// Carousel section !
	var wrapper = $('wrap'); // The outer wrapper
	var carousel = $('carousel'); // The inner wrapper
	var items = $$('#carousel li'); // The different elements, this is an array
	var item_width = 195; // The full width of a single item (incl. borders, padding, etc ... if there is any)
	var max_margin = items.length * item_width - item_width;
	
	var animation = new Fx.Tween(carousel, {duration: 500});
	var position = parseInt(carousel.getStyle('left'));
	
	if(position <= -max_margin){
		animation.start('left', 0);
	} else {
		var newposition = position - item_width;
		animation.start('left', newposition);
	}
	return false;
}

function prev_img2 () {
	// Carousel section !
	var wrapper = $('wrap'); // The outer wrapper
	var carousel = $('carousel'); // The inner wrapper
	var items = $$('#carousel li'); // The different elements, this is an array
	var item_width = 227
	; // The full width of a single item (incl. borders, padding, etc ... if there is any)
	var max_margin = items.length * item_width - 4* item_width;
	
	var animation = new Fx.Tween(carousel, {duration: 500});
	var position = parseInt(carousel.getStyle('left'));
	
	if(position >= 0){
		animation.start('left', 0);
	} else {
		var newposition = position + item_width;
		animation.start('left', newposition);
	}
}

function next_img2 () {
	// Carousel section !
	var wrapper = $('wrap'); // The outer wrapper
	var carousel = $('carousel'); // The inner wrapper
	var items = $$('#carousel li'); // The different elements, this is an array
	var item_width = 227; // The full width of a single item (incl. borders, padding, etc ... if there is any)
	var max_margin = items.length * item_width - 4 * item_width;
	
	var animation = new Fx.Tween(carousel, {duration: 500});
	var position = parseInt(carousel.getStyle('left'));
	
	if(position <= -max_margin){
		animation.start('left', 0);
	} else {
		var newposition = position - item_width;
		animation.start('left', newposition);
	}
}

function jump_img2 (ile) {
	// Carousel section !
	var wrapper = $('wrap'); // The outer wrapper
	var carousel = $('carousel'); // The inner wrapper
	var items = $$('#carousel li'); // The different elements, this is an array
	var item_width = 227; // The full width of a single item (incl. borders, padding, etc ... if there is any)
	var max_margin = items.length * item_width - 4 * item_width;
	
	var animation = new Fx.Tween(carousel, {duration: 500});
	var position = parseInt(carousel.getStyle('left'));

	var newposition = -(ile * item_width);
	
	if (newposition <= -max_margin)
	     newposition = -max_margin;
	animation.start('left', newposition);
}

function openW(strona,width_,height_,sc){
         new_window = window.open(strona,'strona','width='+width_+',height='+height_+',toolbars=no,resizeble="no",scrollbars='+sc);
}

function nowe_okno (url,szerokosc,wysokosc) {
         var Win = window.open(url,"","scrollbars=yes,resizable=0,width="+szerokosc+",height="+wysokosc+",menubar=no" );
         Win.moveTo((screen.width / 2) - szerokosc/2,(screen.height / 2) - wysokosc/2);
         Win.focus();
}
 
function Focus(control) {
  control.focus();
  control.select();
}

function IsEmailCorrect(email) {
  return email.match(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$/)!=null;
}

function IsEmpty(pole) {
  if (pole=='') 
  	return true
	else
	return false
}

function kontakt()
{
if (IsEmpty(document.getElementById('imie').value)) {
    alert('Proszę podać imię i nazwisko.');
    Focus(document.getElementById('imie'));
    return false;
  }
if (IsEmpty(document.getElementById('temat').value)) {
    alert('Proszę podać temat wiadomości.');
    Focus(document.getElementById('temat'));
    return false;
  }
if (!IsEmailCorrect(document.getElementById('email').value))	{
    alert('Proszę podać poprawny adres e-mail.');
    Focus(document.getElementById('email'));
	return false;
	}
if (IsEmpty(document.getElementById('tresc').value)) {
    alert('Proszę podać treść.');
    Focus(document.getElementById('tresc'));
    return false;
  }
return true;
}

function dodaj_plik()
{
	plik++;
	$('pliki'+plik).removeClass('hidden');
	if (plik==10) $('button_pliki').style.display='none';
	return false;
}
