function hover(id,type) {
	if (type === 1) {
		$('babel' + id).style.display = 'block';
		$('menu' + id).addClassName('hover');
		Cufon.refresh('#menu' + id);
	} else if (type === 0) {
		$('babel' + id).style.display = 'none';
		$('menu' + id).removeClassName('hover');
		Cufon.refresh('#menu' + id);
	}
}

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

var imgRolety = new Array('/media/pokaz/rolety/rolety1.png','/media/pokaz/rolety/rolety2.png','/media/pokaz/rolety/rolety3.png'); // images array
var currentRolety = 0;	// starting index
var timeRolety = 7.5;	// execution time
Event.observe(window, 'load', function() { if(imgRolety.length > 1 && $('rozetaRolety') !== null) new PeriodicalExecuter(updateTopImage, timeRolety); });
function updateTopImage() {
	next = window.currentRolety+1;
	if (imgRolety[next] === undefined)	next = 0;
	if(next != 0)
		new Effect.Move('rozetaRolety', {x: 320, y: 0, mode: 'relative',duration: 2 });
	else
		new Effect.Move('rozetaRolety', {x: -640, y: 0, mode: 'relative',duration: 3 });
	window.currentRolety = next;
}


var imgMarkizy = new Array('/media/pokaz/markizy/markizyD1.jpg','/media/pokaz/markizy/markizyD2.jpg','/media/pokaz/markizy/markizyD3.jpg'); // images array
var currentMarkizy = 0;	// starting index
var timeMarkizy = 6;	// execution time
Event.observe(window, 'load', function() { if(imgMarkizy.length > 1 && $('rozetaMarkizy') !== null) new PeriodicalExecuter(updateTopImageMarkizy, timeMarkizy); });
function updateTopImageMarkizy() {
	next2 = window.currentMarkizy+1;
	if (imgMarkizy[next2] === undefined)	next2 = 0;
	if(next2 != 0)
		new Effect.Move('rozetaMarkizy', {x: 430, y: 0, mode: 'relative',duration: 2 });
	else
		new Effect.Move('rozetaMarkizy', {x: -860, y: 0, mode: 'relative',duration: 3 });
	window.currentMarkizy = next2;
}

/*var imgMarkizy = new Array('/media/pokaz/markizy/markizy1.png','/media/pokaz/markizy/markizy2.png','/media/pokaz/markizy/markizy3.png'); // images array
var currentMarkizy = 0;	// starting index
var timeMarkizy = 3;	// execution time
Event.observe(window, 'load', function() { if(imgMarkizy.length > 1 && $('rozetaMarkizy') !== null) new PeriodicalExecuter(updateTopImageMarkizy, timeMarkizy); });
function updateTopImageMarkizy() {
	next2 = window.currentMarkizy+1;
	if (imgMarkizy[next2] === undefined)	next2 = 0;
	prev2 = window.currentMarkizy;
	a2 = document.createElement('img');
	Element.extend(a2);
	a2.style.display = 'none';
	$('rozetaMarkizy').appendChild(a2);
	a2.src = imgMarkizy[next2];
	a2.id = 'm'+next2;
	$('m'+window.currentMarkizy).fade();
	$('m'+next2).appear();
	window.currentMarkizy = next2;
	setTimeout("$('m'+prev2).remove()",1010);
}*/

var imgRefleksole = new Array('/media/pokaz/refleksole/refleksoleD1.jpg','/media/pokaz/refleksole/refleksoleD2.jpg','/media/pokaz/refleksole/refleksoleD3.jpg'); // images array
var currentRefleksole = 0;	// starting index
var timeRefleksole = 6.5;	// execution time
Event.observe(window, 'load', function() { if(imgRefleksole.length > 1 && $('rozetaRefleksole') !== null) new PeriodicalExecuter(updateTopImageRefleksole, timeRefleksole); });
function updateTopImageRefleksole() {
	next3 = window.currentRefleksole+1;
	if (imgRefleksole[next3] === undefined)	next3 = 0;
	if(next3 != 0)
		new Effect.Move('rozetaRefleksole', {x: 320, y: 0, mode: 'relative',duration: 2 });
	else
		new Effect.Move('rozetaRefleksole', {x: -640, y: 0, mode: 'relative',duration: 3 });
	window.currentRefleksole = next3;
	new Effect.Move('re'+prev3, { x: 287, y: 0, mode: 'relative',duration: 2 });
	window.currentRefleksole = next3;
}

var imgZaluzje = new Array('/media/pokaz/zaluzje/zaluzje1.png','/media/pokaz/zaluzje/zaluzje2.png','/media/pokaz/zaluzje/zaluzje3.png'); // images array
var currentZaluzje = 0;	// starting index
var timeZaluzje = 7.2;	// execution time
Event.observe(window, 'load', function() { if(imgZaluzje.length > 1 && $('rozetaZaluzje') !== null) new PeriodicalExecuter(updateTopImageZaluzje, timeZaluzje); });
function updateTopImageZaluzje() {
	next4 = window.currentZaluzje+1;
	if (imgZaluzje[next4] === undefined)	next4 = 0;
	if(next4 != 0)
		new Effect.Move('rozetaZaluzje', {x: 320, y: 0, mode: 'relative',duration: 2 });
	else
		new Effect.Move('rozetaZaluzje', {x: -640, y: 0, mode: 'relative',duration: 3 });
	window.currentZaluzje = next4;
}

var imgZaslony = new Array('/media/pokaz/zaslony/zaslony1.png','/media/pokaz/zaslony/zaslony2.png','/media/pokaz/zaslony/zaslony3.png'); // images array
var currentZaslony = 0;	// starting index
var timeZaslony = 7.8;	// execution time
Event.observe(window, 'load', function() { if(imgZaslony.length > 1 && $('rozetaZaslony') !== null) new PeriodicalExecuter(updateTopImageZaslony, timeZaslony); });
function updateTopImageZaslony() {
	next5 = window.currentZaslony+1;
	if (imgZaslony[next5] === undefined)	next5 = 0;
	if(next5 != 0)
		new Effect.Move('rozetaZaslony', {x: 320, y: 0, mode: 'relative',duration: 2 });
	else
		new Effect.Move('rozetaZaslony', {x: -640, y: 0, mode: 'relative',duration: 3 });
	window.currentZaslony = next5;
}

var imgOkiennice = new Array(); // images array
var currentOkiennice = 0;	// starting index
var timeOkiennice = 8.2;	// execution time
Event.observe(window, 'load', function() { if(imgOkiennice.length > 1 && $('rozetaOkiennice') !== null) new PeriodicalExecuter(updateTopImageOkiennice, timeOkiennice); });
function updateTopImageOkiennice() {
	next6 = window.currentOkiennice+1;
	if (imgOkiennice[next6] === undefined)	next6 = 0;
	if(next6 != 0)
		new Effect.Move('rozetaOkiennice', {x: 320, y: 0, mode: 'relative',duration: 2 });
	else
		new Effect.Move('rozetaOkiennice', {x: -640, y: 0, mode: 'relative',duration: 3 });
	window.currentOkiennice = next6;
}

currentTxt = 0;
function moveBack() {
	var nodes = getNodes('.txtPage');
	var max = nodes.length-1;
	if(window.currentTxt > 0) {
		next = window.currentTxt-1;
		$('txt'+window.currentTxt).style.visibility = 'hidden';
		$('txt'+next).style.visibility = 'visible';
		$('goForward').style.visibility = 'visible';
		if(next < 1) $('goBack').style.visibility = 'hidden';
		window.currentTxt = next;
	}
}

function moveForward() {
	var nodes = getNodes('.txtPage');
	var max = nodes.length-1;
	if(window.currentTxt < max) {
		next = window.currentTxt+1;
		$('txt'+window.currentTxt).style.visibility = 'hidden';
		$('txt'+next).style.visibility = 'visible';
		$('goBack').style.visibility = 'visible';
		if(next == max) $('goForward').style.visibility = 'hidden';
		window.currentTxt = next;
	}
}

function moveBackPr() {
	if(pr.pmenu2Id === null) pr.produkty = menu[pr.pmenuId].produkty;
	else pr.produkty = menu[pr.pmenuId].podmenu[pr.pmenu2Id].produkty;
	
	pr.ids = Object.keys(pr.produkty);
	
	var nodes = getNodes('.txtPage');
	var max = nodes.length;
	if(window.currentTxt >= -1) {
		next = window.currentTxt-1;
		$('txt'+window.currentTxt).style.visibility = 'hidden';
		if($('txt'+next)) $('txt'+next).style.visibility = 'visible';
		$('goForward').style.visibility = 'visible';
		if (next < 0 && pr.ids[pr.prevIdIndex] !== undefined) {
			$('txt').update('<h1>'+ pr.produkty[pr.ids[pr.prevIdIndex]].text_header +'</h1>'+pr.produkty[pr.ids[pr.prevIdIndex]].ajaxTxt);
			nodes = getNodes('.txtPage');
			nodes.each(function(item) {item.style.visibility = 'hidden'});
			max = nodes.length-1;
			window.currentTxt = max;
			$('txt'+window.currentTxt).style.visibility = 'visible';
			pr.nextIdIndex--;
			pr.prevIdIndex--;
			pr.currentIdIndex--;
		} else if(next < 1 && pr.ids[pr.prevIdIndex] === undefined) {
			$('goBack').style.visibility = 'hidden';
			window.currentTxt = next;
		} else
			window.currentTxt = next;
	}
}

function moveForwardPr() {	
	if(pr.pmenu2Id === null) pr.produkty = menu[pr.pmenuId].produkty;
	else pr.produkty = menu[pr.pmenuId].podmenu[pr.pmenu2Id].produkty;
	
	pr.ids = Object.keys(pr.produkty);
	
	var nodes = getNodes('.txtPage');
	var max = nodes.length;
	if(window.currentTxt <= max) {
		next = window.currentTxt+1;
		$('txt'+window.currentTxt).style.visibility = 'hidden';
		if($('txt'+next)) $('txt'+next).style.visibility = 'visible';
		$('goBack').style.visibility = 'visible';
		if (next == max && pr.ids[pr.nextIdIndex] !== undefined) {
			$('txt').update('<h1>'+ pr.produkty[pr.ids[pr.nextIdIndex]].text_header +'</h1>'+pr.produkty[pr.ids[pr.nextIdIndex]].ajaxTxt);
			window.currentTxt = 0;
			pr.nextIdIndex++;
			pr.prevIdIndex++;
			pr.currentIdIndex++;
		} else if (next == max-1 && pr.ids[pr.nextIdIndex] === undefined) {
			$('goForward').style.visibility = 'hidden';
			window.currentTxt = next;
		} else
			window.currentTxt = next;
	}
	
}

function getNodes(className) {
	return $$(className);
}

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 validatePomiar(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 if((AForm.telefon.value == '')) {
		alert("Podaj telefon.");
        return false;
	}
	else if((AForm.adres.value == '')) {
		alert("Podaj adres.");
        return false;
	}
	else if((AForm.termin.value == '')) {
		alert("Podaj proponowany termin.");
        return false;
	}
	else if((AForm.produkt.value == 0)) {
		alert("Musisz wybrac produkt.");
        return false;
	}
	else if((AForm.agree.value != 'on')) {
		alert("Musisz wyrazić zgodę na przetwarzanie danych.");
        return false;
	}
    else {
		return true;
    }
};

function validateZapytaj(AForm) {
    reg = /^[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]{1,60}@[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]+(\.[a-zA-Z0-9ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\-\_\.]+)+$/;
    wyn = AForm.email.value.match(reg);
    if (AForm.produkt.value == 0) {
        alert("Proszę wybrać produkt.");
        return false;
    }
	else if (wyn == null) {
        alert("Proszę podać poprawny adres email.");
        return false;
    }
	else if((AForm.imie.value == '')) {
		alert("Podaj imię.");
        return false;
	}
	else if((AForm.telefon.value == '')) {
		alert("Podaj telefon.");
        return false;
	}
	else if((AForm.adres.value == '')) {
		alert("Podaj adres.");
        return false;
	}
	else if((AForm.tresc.value == '')) {
		alert("Podaj dane potrzebne do wyceny.");
        return false;
	}
	else if((AForm.agree.value != 'on')) {
		alert("Musisz wyrazić zgodę na przetwarzanie danych.");
        return false;
	}
    else {
		return true;
    }
};
