var counter = 2;

if(document.images){
	slidePics = new Array();
	for(var i = 1;i<5;i++) {
		slidePics[i]= new Image();
		slidePics[i].src = "images/IANIM"+i+".jpg"};
}

function rollPics() {
	if(document.images) {
		window.document.images[7].src = slidePics[counter].src;
		counter++;
		if (counter>4) {
			counter=1
		}
		setTimeout('rollPics()',2000);
	}
}

var fBlink;
var poc=0;
var pocet_bliknuti=3;

function ChangeColor( theField, theColor ) {
    theField.style.background = theColor
}

function Blink(fieldName, theColor) {
	var theField=eval(fieldName);
	if (fBlink) {
	  poc++;
		ChangeColor(theField,theColor);   
		if(theColor=="red") {
			setTimeout("Blink(\"" + fieldName + "\",\"#4D4D4D\")",200);
			if (poc>=pocet_bliknuti*2) {
				poc = 0;
				fBlink = false;
			}
		} else {
			setTimeout("Blink(\"" + fieldName + "\",\"red\")",200);
			if (poc>=pocet_bliknuti*2) {
				poc = 0;
				fBlink = false;
			}
		}   
	} else {
		ChangeColor(theField,"#4D4D4D");   
	}
}

function StartBlink(indexOfForm, theField) {
	theField.focus();
	fBlink = true;
	Blink("document.forms["+indexOfForm+"]." + theField.name,"red");
}

function StopBlink() {
	fBlink = false;
}

function zkontroluj_email(adresa) {
	re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$/;
	return adresa.search(re) == 0;
}

function onLoadFocus() {
	document.forms[0].jmeno.focus();
}

function CheckForm(theForm) {
var f;
	f = eval("theForm.jmeno");
	if (f.value=="")	{
		alert("Vyplňte, prosím, svoje jméno a příjmení!");
		StartBlink(0,f);
		return false;
	}

	f = eval("theForm.address");
	if (f.value=="")	{
		alert("Vyplňte, prosím, svoji adresu!");
		StartBlink(0,f);
		return false;
	}

	f = eval("theForm.mail");
	if (f.value=="") {
		alert("Vyplňte, prosím, Váš email!");
		StartBlink(0,f);
		return false;
	} else {
		if (!zkontroluj_email(f.value))	{ 
			alert("Váš email nemá spravný tvar!");
			StartBlink(0,f);
			return false;
		}
	}

	f = eval("theForm.enquiry");
	if (f.value=="") {
		alert("Vyplňte, prosím, Váš dotaz!");
		StartBlink(0,f);
		return false;
	}

	return true;

}

function showDisplay(theDisplay){
	document.getElementById('displaytext').innerHTML = theDisplay;
}

function newWindow(page,width,height) {
	var w = width;
	var h = height;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';

	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='status=1,';
	settings +='scrollbars=yes';

	popupWindow = window.open(page,"popupWin",settings);
	popupWindow.focus();
}
