﻿function delcart() {
var c = document.forms[0].hidCartId;
var vyber = '';
if (c.length==undefined) {vyber = c.value;}
	for (i=0; i < c.length; i++) {
		if (c[i].checked) {vyber = c[i].value;}
	}
	if (vyber == '') { alert ("Nevybrali ste nehnuteľnosť (krúžok vedľa značky), ktorú sa má odznačiť!");} 
	else { 
	document.forms[0].hidmycartId.value = vyber;
	document.forms[0].submit();
	}
}
function checkSearchForm() {
	with (window.document.frmSearchProduct) {
		if (cboCategory.selectedIndex == -1) {
			alert('Vyberte kategóriu nehnuteľnosti!');
			cboCategory.focus();
			return;
		} else {submit();}
	}
}
function checkInsertForm() {
	with (window.document.frmSearchProduct) {
		if ((txttxt.value == "") || (txtpriezvisko.value == "") || (txtadresa.value == "") || (txttelefon.value == "") || (txtemail.value == ""))  {
			alert('Vyplňte prosím všetky povinné položky (všade, kde je pri názve hviezdička)!');
			return;
		} else {
			if (code.value == "")	 {
				alert('Nezadali ste text na obrázku!');
				return;
			} else {	
				var mm = document.getElementById('txtemail').value;
				if ((mm.indexOf(".") > 2) && (mm.indexOf("@") > 0)) {				
					submit();
				} else {
					alert('Zadaná kontaktná adresa nezodpovedá pravidlám pre e-mailové adresy! Prekontrolujte prosím jej správnosť!');
					return;
				}
			}
		}
	}
}
function checkKontaktForm() {
	with (window.document.myform) {
		if ((odosielatel.indexOf(".") > 2) && (odosielatel.indexOf("@") > 0)) {
			document.getElementById('priloha').value=document.getElementById('abc').innerHTML;
			submit();
		} else {
			alert('Zadaná kontaktná adresa nezodpovedá pravidlám pre e-mailové adresy! Prekontrolujte prosím jej správnosť!');
			odosielatel.focus();
			return;
		}
	}
}
function checkRegForm() {
	with (window.document.frmRegt) {
		if ((regemail.value == "") || (regcode.value == "")) {
			alert('Nezadali ste všetky požadované hodnoty!');
			return;
		} else {submit();}
	}
}
function checkNumber(textBox) {
var v = textBox.value;v=v.replace(",",".");v=v.replace(" ","");v=v.replace("..",".");
while (v.length > 0 && isNaN(v)) v = v.substring(0, v.length - 1);
textBox.value=v;
}
function ShowPicture(kam) {
	document.getElementById('ciel').src = kam;	
}
function strpresun(stranka) {
	document.getElementById('strana').value = stranka;
	window.document.frmSearchProduct.submit();
}
var xmlhttp;var kamto; var odkialto;
function showTerm(str,typ) {
if (typ==1) {kamto = "txtTerm";odkialto ="abcslovnik"; var params = "x=1&a=" + str;
} else {kamto = "txtHint";odkialto ="btnhl"; var params = "x=2&q=" + str;}
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null) {
  alert ("Vas prehliadac nepodporuje tuto funkcionalitu!");
  return;
}
document.getElementById(odkialto).style.cursor = "wait";
var url="x1";
xmlhttp.onreadystatechange = stateChanged;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.setRequestHeader("Content-Length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);  
}
function stateChanged() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById(kamto).innerHTML=xmlhttp.responseText;
document.getElementById(odkialto).style.cursor = "default";
}}
function GetXmlHttpObject() {
if (window.XMLHttpRequest) {return new XMLHttpRequest();}
if (window.ActiveXObject) {return new ActiveXObject("Microsoft.XMLHTTP");}
return null;
}