var maxdelka = 255;
var lock = false;

// omezení délky textarea
function spocitej (form) {
	if (!lock)
	{
		lock = true;

		str = form.value;
		delka= str.length;

		if (delka > maxdelka)
		{
			form.value = str.substr (0, maxdelka);
//			alert("Text je príliš dlouhý!");
		}

		lock = false;
	}
}

function akceform (akce) {
	if (akce == "reset") document.forms[0].reset ();
	if (akce == "submit") document.forms[0].submit ();
}

function swapImage (imgName, fileName) {
	if ((navigator.appName == 'Netscape' && parseFloat(navigator.appVersion) >= 3) || (parseFloat(navigator.appVersion) >= 4)){
			eval ('document.' + imgName + '.src = "' + fileName + '.gif"');
	}
}

function statline () {
	window.status = " ";
	setTimeout ('statline ()', 100);
}

function kontrolapzd (formular) {

	odesli = true;

	if (formular.fVisitPhone.value == '') {
		alert ('Nebyl zadán telefon!');
		formular.fVisitPhone.focus ();
		return false;
	}

	re_mail = new RegExp ('^[0-9a-zA-Z]([._-]*[0-9a-zA-Z])*@{1}[0-9a-zA-Z]{1}[0-9a-zA-Z.-]+[.]{1}[a-zA-Z]{2,4}$');

	if (formular.fVisitEmail.value == '') {
		alert ('Nebyl zadán e-mail!');
		formular.fVisitEmail.focus ();
		return false;
	}

	if (!re_mail.test (formular.fVisitEmail.value)) {
		alert ('Chybně zadán e-mail!');
		formular.fVisitEmail.focus ();
		return false;
	}

	if (formular.fVisitLearnOf.value == 0) {
		alert ('Nebyl vybrán zdroj odkud jste se o nás dozvěděli!');
		formular.fVisitLearnOf.focus ();
		return false;
	}

	return true;

}

function kontroladk (formular) {

	if (formular.f2VisitName.value == '') {
		alert ('Nebylo zadáno jméno!');
		formular.f2VisitName.focus ();
		return false;
	}

	if (formular.f2VisitSurname.value == '') {
		alert ('Nebylo zadáno příjmení!');
		formular.f2VisitSurname.focus ();
		return false;
	}

	if (formular.f2VisitStreet.value == '') {
		alert ('Nebyla zadána ulice!');
		formular.f2VisitStreet.focus ();
		return false;
	}

	re_cislo = new RegExp ('[0-9]');

	if (!re_cislo.test (formular.f2VisitStreet.value)) {
		alert ('Vyplňte prosím i číslo ulice!');
		formular.f2VisitStreet.focus ();
		return false;
	}

	if (formular.f2VisitCity.value == '') {
		alert ('Nebylo zadáno město!');
		formular.f2VisitCity.focus ();
		return false;
	}

	if (formular.f2VisitZipCode.value == '') {
		alert ('Nebylo zadáno PSČ!');
		formular.f2VisitZipCode.focus ();
		return false;
	}

	if ((formular.f2VisitPhone.value == '') && (formular.f2VisitPhone2.value == '')) {
		alert ('Nebyl zadán telefon!');
		formular.f2VisitPhone.focus ();
		return false;
	}

	re_mail = new RegExp ('^[0-9a-zA-Z]([._-]*[0-9a-zA-Z])*@{1}[0-9a-zA-Z]{1}[0-9a-zA-Z.-]+[.]{1}[a-zA-Z]{2,4}$');

	if (formular.f2VisitEmail.value == '') {
		alert ('Nebyl zadán email!');
		formular.f2VisitEmail.focus ();
		return false;
	}

	if (!re_mail.test (formular.f2VisitEmail.value)) {
		alert ('Chybně zadán e-mail!');
		formular.f2VisitEmail.focus ();
		return false;
	}

	if (formular.f2VisitInPackage.selectedIndex == 0) {
		alert ('Nebylo vybrána video kazeta nebo CD!');
		formular.f2VisitInPackage.focus ();
		return false;
	}

	/*
	if (formular.f2VisitPayment.selectedIndex == 0) {
		alert ('Nebyla vybrána forma úhrady!');
		formular.f2VisitPayment.focus ();
		return false;
	}
	*/

	if (formular.f2VisitCountry.value == 'sk' && formular.f2VisitPayment.value == 2) {
		alert ('Pro SR není možná platba kartou!');
		formular.f2VisitPayment.focus ();
		return false;
	}

	return true;

}

var newWin = null;

function createWin (soubor, width, height) {

	newWin = window.open (soubor, 'new_win', 'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=20,left=20');
	newWin.creator = self;
//	alert(newWin.creator.location);
	newWin.focus ();

}

var newWin2 = null;

function createWin2 (soubor, width, height) {

	newWin2 = window.open (soubor, 'new_win', 'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=20,left=20');
	newWin2.creator = self;
//	alert(newWin.creator.location);
	newWin2.focus ();

}
