function showPartner(id, link) {
	Effect.SlideDown(id, { duration: 0.5 });
	setTimeout(function() {window.location = link;}, 3000);
	setTimeout(function() {Effect.SlideUp(id, { duration: 0.5 });}, 4000);
}

window.current = 0;
function showInfo(id) {
	if (id != 0) {
		if (window.current != 0) {
			$('info' + window.current).style.display = 'none';
			clearOptions();
		}
		$('info' + id).style.display = 'block';
		$('pobranieGodzina').show();
		clearOptions();
		getData(id);
		window.current = id;
	}
	else if (window.current != 0 && id != 0) {
		$('info' + window.current).style.display = 'none';
		$('pobranieGodzina').hide();
		clearOptions();
		getData(window.current);
	} else {
		$('pobranieGodzina').hide();
		$('info' + window.current).style.display = 'none';
		window.current = id;
		clearOptions();
	}
	
}

function clearOptions() {
//	opt = $('pobranieGodzina').options;
	opt = $$('#pobranieGodzina option');
	opt.each(function(item) {item.remove();});
}

function getData(id) {
	new Ajax.Request('/ajax', {
		method:'get',
		parameters: {typ: 'pobranieGodziny', id: id},
  		requestHeaders: {Accept: 'application/json'},
  		onSuccess: function(transport){
    		var txt = transport.responseText;
			if(txt.isJSON) {
				var jsn = txt.evalJSON(true);
				jsn.each(function(item) {
					createOption(item.id,item.godziny);
				});
			}
  		},
	    onFailure: function(){ alert('Błąd pobrania danych') }

	});
}

function createOption(val,text) {
	if($('pobranieGodzina') !== null || $('pobranieGodzina') !== undefined) {
		a = document.createElement('option');
		Element.extend(a);
		a.text = text;
		a.value = val;
		$('pobranieGodzina').appendChild(a);
	}
}

function checkPobranie(form) {
	info = 'Znaleziono błędy w formularzu:\n\n';
	err = 0;
	if(form.pobranieId.options[form.pobranieId.selectedIndex].value == 0) {
		err = 1;
		info += "Musisz wybrać datę pobrania.\n";
	}	
	
	if(form.imie.value == '' || form.nazwisko.value == '' || form.adres.value == '' || form.telefon.value == '' || form.zwGatunek.value == '' || form.zwRasa.value == '' || form.zwImie.value == '' || form.zwPlec.value == '' || form.zwWiek.value == '' || form.zwWaga.value == '' || form.zwUmaszczenie.value == '' || form.zwTatuaz.value == '' || form.zwDataPobrania.value == '' || form.zwWscieklizna.value == '' || form.zwWirusowe.value == '' || form.zwOdrobaczenie.value == '' || form.zwOdpchlenie.value == '') {
		err = 1;
		info += "Wszystkie pola formularza muszą być wypełnione.\n";
	}
	
	reg = /^[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]{1,60}@[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]+(\.[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]+)+$/;
    wyn = form.email.value.match(reg);
    if (wyn == null) {
        info += "Proszę podać poprawny adres email.\n";
		err = 1;
    }
	
	if(err == 0) {
		return true;
	} else {
		alert(info);
		return false;
	}


}

