Event.observe(window, 'load', function() { if($('full') !== undefined && $('full') !== null) { $('full').style.display = 'none'; }});
window.on = 0;
function showFull() {
	if (window.on == 0) {
		window.on = 1;
		$('wiecej').style.display = "none";
		Effect.SlideDown('full', {
			duration: 0.5
		});
	} else {
		window.on = 0;
		$('wiecej').style.display = "block";
		Effect.SlideUp('full', {
			duration: 0.5
		});
	}
}

function goTo(url) {
	window.location = url;
}

if(window.json !== undefined) {
	var img = json.evalJSON(true); 
	var current = 0;	// starting index
	var time = 6.5;	// execution time
	Event.observe(window, 'load', function() { if(img.length > 1 && ($('galeriaTop') !== null || $('galeriaLeft') !== null)) new PeriodicalExecuter(updateTopImage, time); });	
}

function updateTopImage() {
	next = window.current+1;
	if (img[next] === undefined)	next = 0;
	
	if($('gNazwa') !== null) $('gNazwa').fade();
	if($('gImg') !== null) $('gImg').fade();
	if($('gPodpis') !== null) $('gPodpis').fade();
	
	if($('gNazwa') !== null) window.gNazwa = img[next].galeria_nazwa;
	if($('gImg') !== null) window.gImg = '<a href="/galeria/'+img[next].galeria_id+','+img[next].galeria_url+'"><img src="'+img[next].galeria_katalog+'/'+img[next].zdjecie_img+'" alt="'+img[next].zdjecie_podpis+'" /></a>';
	if($('gPodpis') !== null) window.gPodpis = img[next].zdjecie_podpis;
		
	if($('gNazwa') !== null) setTimeout("$('gNazwa').innerHTML = window.gNazwa; $('gNazwa').appear(); $('gZobacz').href = '/galeria/"+img[next].galeria_id+","+img[next].galeria_url+"';",1010);
	if($('gImg') !== null) setTimeout("$('inImg').innerHTML = window.gImg; $('gImg').appear();",1110);
	if($('gPodpis') !== null) setTimeout("$('gPodpis').innerHTML = window.gPodpis; $('gPodpis').appear();",1210);
	window.current = next;
}

function validateNws(AForm) {
    reg = /^[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]{1,60}@[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]+(\.[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]+)+$/;
    wyn = AForm.email.value.match(reg);
    if (wyn == null) {
        alert("Proszę podać poprawny adres email.");
        return false;
    }
	else if((AForm.imie.value == '')) {
		alert("Podaj imię.");
        return false;
	}
    else {
		return true;
    }
};

function checkValue(element, elementValue) {
	if(element.value == elementValue) element.value = '';
	else if(element.value == '') element.value = elementValue;
}
