var cType, finalStep = false, showType = false, numPhoto, tagLen, registration, defModel, defBrand, defFuel, defDistrict, defDistrict2 = "", defFuel, fuelChange = false, modelChange = false, lastChkEl = "", HIGHLIGHTED = "#f4f4f4", UNHIGHLIGHTED = "transparent", insertAd = true;function hideGarage() {  document.getElementById("garageDiv").style.visibility = "hidden";}function hideGarage2(ref) {}function hideDeselected() {  var ref = document.forms["f1"], allElements = ref.elements;    for(var i = 0, curEl, iLen = allElements.length; i < iLen; i++) {    curEl = allElements[i];    if(curEl.type == "checkbox" && !curEl.checked) {      curEl.style.display = "none";    }  } }function showDeselected() {  var ref = document.forms["f1"], allElements = ref.elements;    for(var i = 0, curEl, iLen = allElements.length; i < iLen; i++) {    curEl = allElements[i];    if(curEl.type == "checkbox" && !curEl.checked) {      curEl.style.display = "inline";    }  } }function setZoomPhoto(url) {  document.getElementById("photozoom2").src = url;}function safeDecode(str) {  str = str.replace(/\|X1\|/g,'\n');  str = str.replace(/\|X2\|/g,'"');  str = str.replace(/\|X3\|/g,"'");  return str;  }function addFavourite() {  window.external.AddFavorite("http://www.xauto.sk", "xauto.sk - inzertný portál");}function setHome() {  document.body.style.behavior="url(#default#homepage)";  document.body.setHomePage("http://www.xauto.sk");}function setPrevadzka(ref) {  setCombo(document.getElementById("prevadzka"), ref.options[ref.options.selectedIndex].value); }function ps(format) {  window.location = "?q=82&format=" + format;}function cb(curEl, val, custom) {  var ref = document.forms["f1"], ref2 = document.getElementById("conbutt"),       el = ref.elements, diff;  for(var i = 0, j = 0, iLen = el.length - 2; i < iLen; i++) {    if(el[i].checked) {      j++;    }  }  if(custom == 0) {    diff = val - j;    document.getElementById("noads").innerHTML = diff;    if(diff > 0) {      showDeselected();      ref2.style.display = "none";    }    else {      if(diff == 0) {        hideDeselected();        ref2.style.display = "inline";      }    }    }   else {    if(j > 0) {      ref2.style.display = "inline";    }    else {      ref2.style.display = "none";    }      document.getElementById("noads").innerHTML = j;      document.getElementById("noads2").value = j;    }}function hideEl(ref) {  document.getElementById(ref).style.display = "none";}/* zoom */function openPhotoZoom(url) {  document.getElementById('photozoom2').src = document.getElementById('photothumb').src;}function openPhotoZoom2(url) {  document.getElementById('photozoom2').src = "http://www.xauto.sk/data/800x600/" + url + ".jpg";}function closePhotoZoom() {  document.getElementById('photozoom').style.display = "none";}function replaceZoom(newphoto) {  document.getElementById("photozoom2").src = newphoto;} /* ad detail */function changeContact(n) {  if(n == 1) {    /*document.getElementById("d1").src = "./img/layout/detailad/d11.gif";    document.getElementById("d2").src = "./img/layout/detailad/d2.gif";    document.getElementById("d3").src = "./img/layout/detailad/d3.gif";*/	document.getElementById("pl1").className = "polozka_aktual";	  if(document.getElementById("pl2")) {    document.getElementById("pl2").className = "polozka";  }	document.getElementById("pl3").className = "polozka";	document.getElementById("pl4").className = "polozka_cervena";    document.getElementById("contactdetail").style.display = "none";    document.getElementById("photodetail").style.display = "block";    document.getElementById("rightbox").style.display = "block";    document.getElementById("frame").style.display = "block";    document.getElementById("frame2").style.display = "none";    document.getElementById("yt_video_frame").style.display = "none";    document.getElementById("reklama_g").style.display = "block";	  }  if(n == 3) {	/*document.getElementById("d1").src = "./img/layout/detailad/d1.gif";    document.getElementById("d2").src = "./img/layout/detailad/d2.gif";    document.getElementById("d3").src = "./img/layout/detailad/d31.gif";*/	document.getElementById("pl1").className = "polozka";  if(document.getElementById("pl2")) {  	document.getElementById("pl2").className = "polozka";  }	document.getElementById("pl3").className = "polozka_aktual";	document.getElementById("pl4").className = "polozka_cervena";    document.getElementById("contactdetail").style.display = "none";    document.getElementById("photodetail").style.display = "none";    document.getElementById("rightbox").style.display = "none";    document.getElementById("frame").style.display = "none";    document.getElementById("frame2").style.display = "block";    document.getElementById("yt_video_frame").style.display = "none";    document.getElementById("reklama_g").style.display = "none";  }  if(n == 2) {    /*document.getElementById("d1").src = "./img/layout/detailad/d1.gif";    document.getElementById("d2").src = "./img/layout/detailad/d21.gif";    document.getElementById("d3").src = "./img/layout/detailad/d3.gif";*/	document.getElementById("pl1").className = "polozka";  if(document.getElementById("pl2")) {	  document.getElementById("pl2").className = "polozka_aktual";	}	document.getElementById("pl3").className = "polozka";	document.getElementById("pl4").className = "polozka_cervena";    document.getElementById("contactdetail").style.display = "block";    document.getElementById("photodetail").style.display = "none";    document.getElementById("rightbox").style.display = "block";    document.getElementById("frame").style.display = "block";    document.getElementById("frame2").style.display = "none";    document.getElementById("yt_video_frame").style.display = "none";    document.getElementById("reklama_g").style.display = "block";  }  if(n == 4) {    /*document.getElementById("d1").src = "./img/layout/detailad/d1.gif";    document.getElementById("d2").src = "./img/layout/detailad/d21.gif";    document.getElementById("d3").src = "./img/layout/detailad/d3.gif";*/	document.getElementById("pl1").className = "polozka";  if(document.getElementById("pl2")) {  	document.getElementById("pl2").className = "polozka";  }	document.getElementById("pl3").className = "polozka";	document.getElementById("pl4").className = "polozka_aktual";    document.getElementById("contactdetail").style.display = "none";    document.getElementById("photodetail").style.display = "none";    document.getElementById("rightbox").style.display = "none";    document.getElementById("frame").style.display = "none";    document.getElementById("frame2").style.display = "none";    document.getElementById("yt_video_frame").style.display = "block";    document.getElementById("reklama_g").style.display = "block";  }}function openPhotoThumb(url) {  document.getElementById('photothumb').src = url;  $('#lupa').css("background-image",'url(' + url + ')');  changeContact(1);}function openSendFriend() {  var ref = document.getElementById("sendfriend");  if(ref.style.display == "none") {    ref.style.display = "inline";  }  else {    ref.style.display = "none";  }}function openSendSeller() {  var ref = document.getElementById("sendseller");  if(ref.style.display == "none") {    ref.style.display = "inline";  }  else {    ref.style.display = "none";  }}// inicializacia po nahrati strankyfunction init() {  MM_preloadImages('./img/layout/car/car.gif', './img/layout/lorry/lorry.gif', './img/layout/motorcycle/motorcycle.gif', './img/layout/replacement/replacement.gif', './img/layout/directory/directory.gif', './img/layout/information/information.gif');  setOnSubmit();}function init2() {  MM_preloadImages('./img/layout/login/vysvetlivky2.gif', './img/layout/login/pridajinzerat2.gif', './img/layout/login/ponuka2.gif', './img/layout/login/garaz2.gif', './img/layout/login/kredit2.gif', './img/layout/login/casopis2.gif', './img/layout/login/kontakty2.gif');}window.onload = init;// -- koniec inicializacie// praca s fotografiamifunction addPhoto() {  showPhotoLayer();}function closePhoto() {  unshowPhotoLayer();}function writePhotoText3(str, state) {  var ref = document.getElementById("phototext3");   ref.value = str;  if(state) {    ref.disabled = false;    ref.style.backgroundColor = "#D8261A";    ref.style.color = "white";    document.getElementById("hourglass").style.display = "none";  }  else {    ref.disabled = true;    ref.style.backgroundColor = document.forms["f2"].bg.value;    ref.style.color = "black";    document.getElementById("hourglass").style.display = "inline";  }}function disablePhoto() {  if(numPhoto > 0) {    document.getElementById("photobutton").disabled = true;    document.getElementById("photobutton").style.display = "none";    document.getElementById("phototext").style.display = "inline";    document.getElementById("phototext").innerHTML = "&nbsp;&nbsp;<strong>Počet fotografií: " + numPhoto + "</strong>";    writePhotoText3(addstr1 + " INZERÁT (odosielam fotografie, prosím čakajte)", false);  }}function showPhotoLayer() {  document.getElementById("infoform").style.display = "none";  document.getElementById("photoform").style.display = "inline";}function unshowPhotoLayer() {  document.getElementById("photoform").style.display = "none";  document.getElementById("infoform").style.display = "inline";}function usePhoto() {  finalStep = true; numPhoto = 0;  if(checkPhotoExtension(1, 7)) {    closePhoto();    disablePhoto();    if(numPhoto > 0) {      document.forms["f2"].submit();    }  }  else {    finalStep = false;  }}function showPreview(ref) {  var refId = ref.id, photoNum = parseInt(refId.substr(1), 10), ref1 = document.getElementById("preview" + photoNum),      ref2 = document.getElementById(refId + "c").style;  if(!checkPhotoExtension(photoNum, photoNum + 1)) {    if(BrowserDetect.browser == "Explorer") {      ref1.style.display = "none";    }    return false;  }  else {    ref2.backgroundColor = document.getElementById("bg").value;    ref2.border = "1px solid #a0a0a0";    if(BrowserDetect.browser == "Explorer") {      document.getElementById(refId + "preview").src = ref.value;      ref1.style.display = "inline";    }    return true;  }}function showPreview2(ref) {  var refId = ref.id, photoNum = parseInt(refId.substr(1), 10), ref1 = document.getElementById("previewlogo");  if(!checkPhotoExtension(photoNum, photoNum + 1)) {    if(BrowserDetect.browser == "Explorer") {      ref1.style.display = "none";    }    return false;  }  else {    if(BrowserDetect.browser == "Explorer") {      document.getElementById(refId + "preview2").src = ref.value;      ref1.style.display = "block";    }    return true;  }}function checkPhotoExtension(a, b) {  for(var i = a, str, err = ""; i < b; i++) {    str = document.getElementById("p" + i).value;    if(str.length == 0 || str.length < 8) {      continue;    }    else {      str = str.toLowerCase();      if((str.indexOf(".jpg") < 1) && (str.indexOf(".jpeg")<1)) {        err += "Fotografia č." + i + " nie je vo formáte JPG\n";      }      else {        if(finalStep) {          numPhoto++;        }      }    }  }  if(err!="") {    window.alert(err);    return false;  }  else {    return true;  }}// zmena typ podla vybrateho modelufunction changeType1(ref) {  removeComboOptions("type");  ajax.load("?q=17&m_id=" + ref.options[ref.options.selectedIndex].value, changeType2, "xml", "GET"); }function changeType2(data) {  var i, record, tagRecords = data.getElementsByTagName("type");  tagLen = tagRecords.length;  enableCombo("type");  if(tagLen > 0) {    for(i = 0; i < tagLen; i++) {      record = tagRecords[i];      addOption("type", record.getElementsByTagName("name")[0].firstChild.nodeValue, record.getElementsByTagName("id")[0].firstChild.nodeValue);     }    addOption("type", "iný", 0);  }  else {    disableCombo("type");    var ref = document.getElementById("model").options;    if(ref[ref.selectedIndex].text == "iný") {      showCustomModel();    }  }  if(showType) {    var combo = document.getElementById("type"), comboLen = combo.length;    for(i = 0; i < comboLen; i++) {      if(combo.options[i].text == cType) {        combo.selectedIndex = i;        break;      }      }   }}function changeTypeCombo(refType) {  var ref = document.getElementById("type");  if(!(ref.options[ref.options.selectedIndex].text == "iný" || tagLen == 0)) {    refillFields(refType);  }}function refillFields(refType) {  var str, refForm, parts, sI = refType.options.selectedIndex;  if(sI > 0) {    str     = refType.options[sI].text;    refForm = document.forms["newad"];    parts   = str.split(",");    switch(refType.name) {      case "c_type": {        refForm.c_volume.value = parts[0].trim();        setCombo(refForm.c_chassis, parts[1].trim());        setCombo(refForm.c_gear, parts[2].trim());        setCombo(refForm.c_fuel, parts[3].trim());        setComboPower(refForm.c_power1, refForm.c_power2, parts[4].trim());        setComboDoor(refForm.c_door, parts[5].trim());        if(parts[6]) {          refForm.c_newvolume.value = parseInt(parts[6].trim(), 10);        }        break;      }      case "l_type": {        refForm.l_volume.value = parts[0].trim();        setCombo(refForm.l_chassis, parts[1].trim());        setCombo(refForm.l_gear, parts[2].trim());        setCombo(refForm.l_fuel, parts[3].trim());        setComboPower(refForm.l_power1, refForm.l_power2, parts[4].trim());        setComboDoor(refForm.l_door, parts[5].trim());        if(parts[6]) {          refForm.l_newvolume.value = parseInt(parts[6].trim(), 10);        }        break;      }      case "m_type": {        refForm.m_volume.value = parts[0].trim();        setCombo(refForm.m_design, parts[1].trim());        setCombo(refForm.m_gear, parts[2].trim());        setCombo(refForm.m_fuel, parts[3].trim());        setComboPower(refForm.m_power1, refForm.m_power2, parts[4].trim());        if(parts[6]) {          refForm.m_newvolume.value = parseInt(parts[6].trim(), 10);        }        break;      }    }  }}function setCombo(ref, val) {  for(var i = 0, iLen = ref.options.length; i < iLen; i++) {    if(ref.options[i].text == val) {      ref.options.selectedIndex = i;      break;    }  }}function changePower1() {  var power1 = document.getElementById("power1"), power2 = document.getElementById("power2"), val = Math.round(power1.value / 0.7355);   if(val == 0) {    power2.value = "";  }  else {    if(power1.value == "-") {      power2.value = "-";    }    else {      power2.value = val;    }  } }function changePower2() {  var power1 = document.getElementById("power1"), power2 = document.getElementById("power2"), val = Math.round(power2.value * 0.7355);   if(val == 0) {    power1.value = "";  }  else {    if(power2.value == "-") {      power1.value = "-";    }    else {      power1.value = val;    }  } }function setComboPower(ref1, ref2, val) {  var str1, str2 = val.split("kW");  ref1.value = str2[0];  changePower1();}function setComboDoor(ref, val) {  var str1, str2 = val.split("dver.");  for(var i = 0, iLen = ref.options.length; i < iLen; i++) {    str1 = ref.options[i].text;    if(str1 == str2[0]) {      ref.options.selectedIndex = i;      return;    }  }  ref.options.selectedIndex = 0;}function showCustomModel() {  var ref1 = document.getElementById("model"), ref2 = document.getElementById("model2");   if(ref1 && ref2) {    ref1.style.display = "none";    ref2.value = "";    ref2.style.display = "inline";    ref2.focus();  }}function unshowCustomModel() {  var ref1 = document.getElementById("model"), ref2 = document.getElementById("model2");   if(ref1 && ref2) {    ref2.style.display = "none";    ref2.value = "";    ref1.style.display = "inline";  }}// zmena modelu podla vybratej znackyfunction changeModel1(ref) {  unshowCustomModel();  removeComboOptions("model");  ajax.load("?q=10&b_id=" + ref.options[ref.options.selectedIndex].value, changeModel2, "xml", "GET"); }function changeModel2(data) {  var i, record, tagRecords = data.getElementsByTagName("model");  tagLen = tagRecords.length;  enableCombo("model");  if(tagLen > 0) {    for(i = 0; i < tagLen; i++) {      record = tagRecords[i];      addOption("model", record.getElementsByTagName("name")[0].firstChild.nodeValue, record.getElementsByTagName("id")[0].firstChild.nodeValue);     }  }  if(insertAd) {      addOption("model", "iný", 0);  }    var combo = document.getElementById("model"), comboLen = combo.length;  for(i = 0; i < comboLen; i++) {    if(combo.options[i].value == defModel) {      combo.selectedIndex = i;      break;    }    }   if(showType) {    changeType1(document.getElementById('model'));  }  if(fuelChange) {    changeFuel1(document.getElementById("vehicle"));  } }// zmena znacky podla vybranej kategoriefunction changeBrand1(ref) {  removeComboOptions("brand");  removeComboOptions("model");  disableCombo("model");  unshowCustomModel();  ajax.load("?q=15&b_type=" + ref.options[ref.options.selectedIndex].value, changeBrand2, "xml", "GET"); }function changeBrand2(data) {  var i, record, tagRecords = data.getElementsByTagName("brand");  tagLen = tagRecords.length;  if(tagLen == 0) {    disableCombo("brand");  }  else {    enableCombo("brand");    for(i = 0; i < tagLen; i++) {      record = tagRecords[i];      addOption("brand", record.getElementsByTagName("name")[0].firstChild.nodeValue, record.getElementsByTagName("id")[0].firstChild.nodeValue);     }  }  var combo = document.getElementById("brand"), comboLen = combo.length;  for(i = 0; i < comboLen; i++) {    if(combo.options[i].value == defBrand) {      combo.selectedIndex = i;      break;    }    }   if(modelChange) {    changeModel1(document.getElementById("brand"));  } }function lockType() {  removeComboOptions("type");  disableCombo("type");}// zmena paliva podla vybranej kategoriefunction changeFuel1(ref) {  removeComboOptions("fuel");  disableCombo("fuel");  ajax.load("?q=20&b_type=" + ref.options[ref.options.selectedIndex].value, changeFuel2, "xml", "GET"); }function changeFuel2(data) {  var i, record, tagRecords = data.getElementsByTagName("type");  tagLen = tagRecords.length;  if(tagLen == 0) {    disableCombo("fuel");  }  else {    enableCombo("fuel");    for(i = 0; i < tagLen; i++) {      record = tagRecords[i];      addOption("fuel", record.getElementsByTagName("name")[0].firstChild.nodeValue, record.getElementsByTagName("id")[0].firstChild.nodeValue);     }  }  var combo = document.getElementById("fuel"), comboLen = combo.length;  for(i = 0; i < comboLen; i++) {    if(combo.options[i].value == defFuel) {      combo.selectedIndex = i;      break;    }    } }function enableCombo(ref) {  var obj           = document.getElementById(ref);  obj.disabled      = false;  obj.selectedIndex = 0;}function disableCombo(ref) {  var ref2 = document.getElementById(ref);  if(ref2) {    ref2.disabled = true;  }}function addOption(obj, txt, val) {  var no   = new Option(), ref = document.getElementById(obj);  no.value = val;  no.text  = txt;  ref.add(no, document.all ? ref.length : null);}function removeComboOptions(obj) {  var ref = document.getElementById(obj);  if(ref) {    var len = ref.length;    for (var i = 0; i < len - 1; i++) {      ref.options[1] = null;    }  }}// zmena kraja po zmene krajinyfunction changeDistrict1(ref) {  var country = ref.options[ref.options.selectedIndex].value;  if(ref.id == "country") {    removeComboOptions("district");    ajax.load("?q=25&u_country=" + country + registration, changeDistrict2, "xml", "GET");   }  else {    removeComboOptions("district2");    ajax.load("?q=25&u_country=" + country + registration, changeDistrict20, "xml", "GET");   }}function changeDistrict2(data) {  changeDistrict0("district", data.getElementsByTagName("type"));}function changeDistrict20(data) {  changeDistrict0("district2", data.getElementsByTagName("type"));}function changeDistrict0(registrationDistrict, tagRecords) {  var i, record;  tagLen = tagRecords.length;  if(tagLen == 0) {    disableCombo(registrationDistrict);  }  else {    enableCombo(registrationDistrict);    for(i = 0; i < tagLen; i++) {      record = tagRecords[i];      addOption(registrationDistrict, record.getElementsByTagName("name")[0].firstChild.nodeValue, record.getElementsByTagName("id")[0].firstChild.nodeValue);     }  }  var combo = document.getElementById(registrationDistrict), comboLen = combo.length;  for(i = 0; i < comboLen; i++) {    if(combo.options[i].value == defDistrict) {      combo.selectedIndex = i;      break;    }    }   if(defDistrict2 != "") {    defDistrict = defDistrict2;    defDistrict2 = "";    changeDistrict1(document.getElementById('country'));  }}// prepinanie dizajnufunction switchNewAds() {  document.getElementById("q1").src = "./img/layout/title/newads2.gif";  document.getElementById("q2").src = "./img/layout/title/topads1.gif";  document.getElementById("q3").src = "./img/layout/title/newresellers1.gif";}function switchTopAds() {  document.getElementById("q1").src = "./img/layout/title/newads1.gif";  document.getElementById("q2").src = "./img/layout/title/topads2.gif";  document.getElementById("q3").src = "./img/layout/title/newresellers1.gif";}function switchNewResellers() {  document.getElementById("q1").src = "./img/layout/title/newads1.gif";  document.getElementById("q2").src = "./img/layout/title/topads1.gif";  document.getElementById("q3").src = "./img/layout/title/newresellers2.gif";}function MM_preloadImages() {  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_swapImgRestore() {  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_findObj(n, d) {  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);  if(!x && document.getElementById) x=document.getElementById(n); return x;}function MM_swapImage() {  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}// ajaxova multibrowserova vrstva var ajax = {	http:false,	format:'text',	callback:function(data){},	error:false,	getHTTPObject : function() {		var http = false;		if(typeof ActiveXObject != 'undefined') {			try {http = new ActiveXObject("Msxml2.XMLHTTP");}			catch (e) {				try {http = new ActiveXObject("Microsoft.XMLHTTP");}				catch (E) {http = false;}			}		} else if (XMLHttpRequest) {			try {http = new XMLHttpRequest();}			catch (e) {http = false;}		}		return http;	},	load : function (url,callback,format) {		this.init();		if(!this.http||!url) return;		if (this.http.overrideMimeType) this.http.overrideMimeType('text/xml');		this.callback=callback;		if(!format) var format = "text";		this.format = format.toLowerCase();		var ths = this;				if (this.http.overrideMimeType) this.http.overrideMimeType('text/xml');		var now = "uid=" + new Date().getTime();		url += (url.indexOf("?")+1) ? "&" : "?";		url += now;		this.http.open("GET", url, true);		this.http.onreadystatechange = function () {			if(!ths) return;			var http = ths.http;			if (http.readyState == 4) {				if(http.status == 200) {					var result = "";          if(ths.format == "xml") result = http.responseXML;          else result = http.responseText;					if(ths.callback) ths.callback(result);				} else { 					if(ths.error) ths.error();				}			}		}		this.http.send(null);	},	init : function() {this.http = this.getHTTPObject();}}function hl(ref) {  setBg(ref, HIGHLIGHTED);}function unhl(ref) {  setBg(ref, UNHIGHLIGHTED);}function setBg(ref, col) {  ref.style.backgroundColor = col; }function really(txt, url) {  if (window.confirm(txt)) {    location = url;  }}function setOnSubmit() {	for (var a = 0, frm = document.forms, aLen = frm.length; a < aLen; a++) {		frm[a].onsubmit = valFrm;	}}function valFrm() {  errNote = "";	for (var curEl, frm = this.elements, a = 0, aLen = frm.length; a < aLen; a++) {		curEl = frm[a];     curElClass = curEl.className;		if (curElClass != "") { checkFld(frm, curElClass.split(" "), curEl); }	}  lastChkEl = "";  var ref = this.elements["afterCheck"];  if (ref) {    eval("errNote += " + ref.value + "();");   }	if (errNote == "") { return true;	}	else { window.alert(errNote); return false; }}function checkFld(frm, rls, fld) {	for (var curRule, curLen, a = 0, aLen = rls.length; a < aLen; a++) {		curRule = rls[a];		switch (curRule) {			case "el_required": {				switch (fld.type) {					case "textarea": case "text": case "password":  {						if (fld.value == "") { errNote += "Pole: " + fld.title + " je potrebné vyplniť\n"; return; }						break;					}					case "radio": {						if (fld.name != lastChkEl) {							lastChkEl = fld.name;							for (var elChecked = false, p = 0, pLen = frm.length; p < pLen; p++) {								curEl = frm[p];								if (curEl.type == "radio" && curEl.name == fld.name && curEl.checked) { elChecked = true; }							}							if (!elChecked) { errNote += "V poli: " + fld.title + " je potrebné zaškrtnúť jednu z možností\n"; return; }						}						break;					}          case "checkbox": {  					if (!fld.checked) { errNote += "Pole: " + fld.title + " je potrebné zaškrtnúť\n"; return; }  					break;          }					case "select-one": {						if (fld.options.selectedIndex == 0) {	errNote += "Z poľa: " + fld.title + " je potrebné si vybrať jednu možnosť\n";	return;	}						break;					}         case "select-multiple": {						if (fld.options.selectedIndex == -1) { errNote += "Z poľa: " + fld.title + " je potrebné si vybrať min. jednu možnosť\n"; return; }						break;					}				}				break;			}			case "el_digit": {				switch (fld.type) {					case "text": case "password": case "textarea": {						var fldVal = fld.value;						if (!isDigit(fldVal)) { errNote += "V poli: " + fld.title + " sa môžu vyskytovať iba číslice\n"; return; }						break;					}				}				break;			}			case "el_natural": {				switch (fld.type) {					case "textarea": case "text": case "password": {						var fldVal = fld.value;						if (isNaN(fldVal) || !isInt(fldVal) || fldVal < 1) { errNote += "Do poľa: " + fld.title + " je potrebné zadať prirodzené číslo\n"; return; }						break;					}				}				break;			}			case "el_float": {				switch (fld.type) {					case "textarea": case "text": case "password": {						fld.value = replaceComma(fld.value);						if (isNaN(fld.value) || !isFloat(fld.value)) { errNote += "Do poľa: " + fld.title + " je potrebné zadať reálne číslo\n"; return; }						break;					}				}				break;			}			case "el_email": {				switch (fld.type) {					case "textarea": case "text": case "password": {						var fldVal = fld.value;						if (!isEmail(fldVal)) { errNote += "V poli: " + fld.title + " je zadaná neplatná e-mailová adresa\n"; return; }						break;					}				}				break;			}			default: {				if (curRule.indexOf("_min") > 0) {					curLen = curRule.substr(6);					if (fld.value.length < curLen) { errNote += "Min. povolený počet znakov v poli: " + fld.title + " je " + curLen + "\n"; return; }				}				else {					if (curRule.indexOf("_max") > 0) {						curLen = curRule.substr(6);						if (fld.value.length > curLen) { errNote += "Max. povolený počet znakov v poli: " + fld.title + " je " + curLen + "\n"; return; }					}				}				break;			}		}	}}function replaceComma(n) {  return n.replace(/,/gi, ".");}function isDigit(n) {	for (var a = 0, aLen = n.length; a < aLen; a++) {		if (isNaN( n.charAt(a))) { return false; }	}	return true;}function isInt(n) {	var o = parseInt(n, 10);	if (isNaN(o)) { return false; }  else { return n == o && n.toString() == o.toString(); }}function isFloat(n) {	var o = parseFloat(n);	if (isNaN(o)) { return false; }  else { return n == o && n.toString() == o.toString(); }}function isEmail(eml) {  return /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$/.test(eml);}function xwwwCheck() {  var dir = document.getElementById("xautowww").value;  if (dir == "" || /^([_a-zA-Z0-9-]+)$/.test(dir)) {    return "";  }  else {    return "Zadaná adresa obsahuje neprípustné znaky.\nPovolené sú: písmená bez diakritiky, číslice a znaky _ a -";  }}function sameLogin() {  var errMsg = "Používateľ s rovnakým loginom už existuje.";  document.getElementById("loginText").style.color      = "red";  document.getElementById("loginText").style.fontWeight = "bold";  document.getElementById("errorArea").style.display = "inline";  document.getElementById("errorText").innerHTML     = errMsg + "<br>Zvoľte si prosím iný login.";  window.alert(errMsg);}function badAuthCode() {  document.getElementById("errorArea").style.display = "inline";  document.getElementById("errorText").innerHTML     = "Zadali ste nesprávny autorizačný kód.";}function telephoneCheck() {  var tel = document.getElementById("telephone2").value,      mob = document.getElementById("cellphone2").value;  if (tel == "" && mob == "") {    return "Je nutné, aby bolo vyplnené pole: Telefón alebo Mobil";  }  else {    return "";  }}String.prototype.trim = function() {	return this.replace(/^\s+|\s+$/g,"");}String.prototype.ltrim = function() {	return this.replace(/^\s+/,"");}String.prototype.rtrim = function() {	return this.replace(/\s+$/,"");}var BrowserDetect = {	init: function () {		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";		this.version = this.searchVersion(navigator.userAgent)			|| this.searchVersion(navigator.appVersion)			|| "an unknown version";		this.OS = this.searchString(this.dataOS) || "an unknown OS";	},	searchString: function (data) {		for (var i=0;i<data.length;i++)	{			var dataString = data[i].string;			var dataProp = data[i].prop;			this.versionSearchString = data[i].versionSearch || data[i].identity;			if (dataString) {				if (dataString.indexOf(data[i].subString) != -1)					return data[i].identity;			}			else if (dataProp)				return data[i].identity;		}	},	searchVersion: function (dataString) {		var index = dataString.indexOf(this.versionSearchString);		if (index == -1) return;		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));	},	dataBrowser: [		{ 	string: navigator.userAgent,			subString: "OmniWeb",			versionSearch: "OmniWeb/",			identity: "OmniWeb"		},		{			string: navigator.vendor,			subString: "Apple",			identity: "Safari"		},		{			prop: window.opera,			identity: "Opera"		},		{			string: navigator.vendor,			subString: "iCab",			identity: "iCab"		},		{			string: navigator.vendor,			subString: "KDE",			identity: "Konqueror"		},		{			string: navigator.userAgent,			subString: "Firefox",			identity: "Firefox"		},		{			string: navigator.vendor,			subString: "Camino",			identity: "Camino"		},		{		// for newer Netscapes (6+)			string: navigator.userAgent,			subString: "Netscape",			identity: "Netscape"		},		{			string: navigator.userAgent,			subString: "MSIE",			identity: "Explorer",			versionSearch: "MSIE"		},		{			string: navigator.userAgent,			subString: "Gecko",			identity: "Mozilla",			versionSearch: "rv"		},		{ 		// for older Netscapes (4-)			string: navigator.userAgent,			subString: "Mozilla",			identity: "Netscape",			versionSearch: "Mozilla"		}	],	dataOS : [		{			string: navigator.platform,			subString: "Win",			identity: "Windows"		},		{			string: navigator.platform,			subString: "Mac",			identity: "Mac"		},		{			string: navigator.platform,			subString: "Linux",			identity: "Linux"		}	]};BrowserDetect.init();function fillInput(frm, el, val) {  getRef(frm, el).value = val;}function fillInput2(frm, el, val) {  getRef(frm, el).value = safeDecode(val);}function fillCombo(frm, el, val) {  for(var i = 0, curEl, ref = getRef(frm, el), refOptions = ref.options, refLen = refOptions.length; i < refLen; i++) {    curEl = refOptions[i];    if(curEl.value == val) {      refOptions.selectedIndex = i;      break;    }  }}function fillCheckbox(frm, el, val) {  var ref = getRef(frm, el)  if(val == 1) {    ref.checked = true;  }  else {    ref.checked = false;  }}function fillRadio(frm, el, val) {	for (var i = 0, curEl, ref = getRef(frm, el), refLen = ref.length; i < refLen; i++) {    curEl = ref[i];    if(curEl.value == val) {      curEl.checked = true;      break;    }	}}function getComboText(frm, el) {  var ref = getRef(frm, el);  return ref.options[ref.options.selectedIndex].text;}function getInputValue(frm, el) {  return getRef(frm, el).value;}function getRef(frm, el) {  eval('var ref = document.forms["' + frm + '"].' + el);  return ref;}function setGrey(ref) {  setBg(ref, "#DEDEDC");}function unsetGrey(ref) {  setBg(ref, "transparent");}function setBg(ref, col) {  document.getElementById(ref).style.backgroundColor = col;}/****  Base64 encode / decode*  http://www.webtoolkit.info/***/var Base64 = {    // private property    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",    // public method for encoding    encode : function (input) {        var output = "";        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;        var i = 0;        input = Base64._utf8_encode(input);        while (i < input.length) {            chr1 = input.charCodeAt(i++);            chr2 = input.charCodeAt(i++);            chr3 = input.charCodeAt(i++);            enc1 = chr1 >> 2;            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);            enc4 = chr3 & 63;            if (isNaN(chr2)) {                enc3 = enc4 = 64;            } else if (isNaN(chr3)) {                enc4 = 64;            }            output = output +            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);        }        return output;    },    // public method for decoding    decode : function (input) {        var output = "";        var chr1, chr2, chr3;        var enc1, enc2, enc3, enc4;        var i = 0;        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");        while (i < input.length) {            enc1 = this._keyStr.indexOf(input.charAt(i++));            enc2 = this._keyStr.indexOf(input.charAt(i++));            enc3 = this._keyStr.indexOf(input.charAt(i++));            enc4 = this._keyStr.indexOf(input.charAt(i++));            chr1 = (enc1 << 2) | (enc2 >> 4);            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);            chr3 = ((enc3 & 3) << 6) | enc4;            output = output + String.fromCharCode(chr1);            if (enc3 != 64) {                output = output + String.fromCharCode(chr2);            }            if (enc4 != 64) {                output = output + String.fromCharCode(chr3);            }        }        output = Base64._utf8_decode(output);        return output;    },    // private method for UTF-8 encoding    _utf8_encode : function (string) {        string = string.replace(/\r\n/g,"\n");        var utftext = "";        for (var n = 0; n < string.length; n++) {            var c = string.charCodeAt(n);            if (c < 128) {                utftext += String.fromCharCode(c);            }            else if((c > 127) && (c < 2048)) {                utftext += String.fromCharCode((c >> 6) | 192);                utftext += String.fromCharCode((c & 63) | 128);            }            else {                utftext += String.fromCharCode((c >> 12) | 224);                utftext += String.fromCharCode(((c >> 6) & 63) | 128);                utftext += String.fromCharCode((c & 63) | 128);            }        }        return utftext;    },    // private method for UTF-8 decoding    _utf8_decode : function (utftext) {        var string = "";        var i = 0;        var c = c1 = c2 = 0;        while ( i < utftext.length ) {            c = utftext.charCodeAt(i);            if (c < 128) {                string += String.fromCharCode(c);                i++;            }            else if((c > 191) && (c < 224)) {                c2 = utftext.charCodeAt(i+1);                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));                i += 2;            }            else {                c2 = utftext.charCodeAt(i+1);                c3 = utftext.charCodeAt(i+2);                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));                i += 3;            }        }        return string;    }}// Obmedzenie riadkov a znakov v textareavar alert_title='Obmedzdenie vstupných dát';function limitTextarea(el,maxLines,maxChar){if(!el.x){el.x=uniqueInt();el.onblur=function(){clearInterval(window['int'+el.x])}}window['int'+el.x]=setInterval(function(){var lines=el.value.replace(/\r/g,'').split('\n'),i=lines.length,lines_removed,char_removed;if(maxLines&&i>maxLines){alert('Nemôžete zadať viac\nako '+maxLines+' riadky textu');lines=lines.slice(0,maxLines);lines_removed=1}if(maxChar){i=lines.length;while(i-->0)if(lines[i].length>maxChar){lines[i]=lines[i].slice(0,maxChar);char_removed=1}if(char_removed)alert('Nemôžete zadať viac\nako '+maxChar+' znakov na riadok')}if(char_removed||lines_removed)el.value=lines.join('\n')},50);}function uniqueInt(){var num,maxNum=100000;if(!uniqueInt.a||maxNum<=uniqueInt.a.length)uniqueInt.a=[];do num=Math.ceil(Math.random()*maxNum);while(uniqueInt.a.hasMember(num))uniqueInt.a[uniqueInt.a.length]=num;return num}Array.prototype.hasMember=function(testItem){var i=this.length;while(i-->0)if(testItem==this[i])return 1;return 0};function set_ie_alert(){window.alert=function(msg_str){vb_alert(msg_str)}}        function updateHTML(elmId, value) {          document.getElementById(elmId).innerHTML = value;        }         function setytplayerState(newState) {          updateHTML("playerstate", newState);        }         function onytplayerStateChange(newState) {          setytplayerState(newState);        }         function onPlayerError(errorCode) {          alert("An error occured: " + errorCode);        }         function updateytplayerInfo() {          updateHTML("bytesloaded", getBytesLoaded());          updateHTML("bytestotal", getBytesTotal());          updateHTML("videoduration", getDuration());          updateHTML("videotime", getCurrentTime());          updateHTML("startbytes", getStartBytes());          updateHTML("volume", getVolume());        }         // functions for the api calls        function loadNewVideo(id, startSeconds) {          if (ytplayer) {            ytplayer.loadVideoById(id, parseInt(startSeconds));          }        }         function cueNewVideo(id, startSeconds) {          if (ytplayer) {            ytplayer.cueVideoById(id, startSeconds);          }        }         function play() {          if (ytplayer) {            ytplayer.playVideo();          }        }         function pause() {          if (ytplayer) {            ytplayer.pauseVideo();          }        }         function stop() {          if (ytplayer) {            ytplayer.stopVideo();          }        }         function getPlayerState() {          if (ytplayer) {            return ytplayer.getPlayerState();          }        }         function seekTo(seconds) {          if (ytplayer) {            ytplayer.seekTo(seconds, true);          }        }         function getBytesLoaded() {          if (ytplayer) {            return ytplayer.getVideoBytesLoaded();          }        }         function getBytesTotal() {          if (ytplayer) {            return ytplayer.getVideoBytesTotal();          }        }         function getCurrentTime() {          if (ytplayer) {            return ytplayer.getCurrentTime();          }        }         function getDuration() {          if (ytplayer) {            return ytplayer.getDuration();          }        }         function getStartBytes() {          if (ytplayer) {            return ytplayer.getVideoStartBytes();          }        }         function mute() {          if (ytplayer) {            ytplayer.mute();          }        }         function unMute() {          if (ytplayer) {            ytplayer.unMute();          }        }                function getEmbedCode() {          alert(ytplayer.getVideoEmbedCode());        }         function getVideoUrl() {          alert(ytplayer.getVideoUrl());        }                function setVolume(newVolume) {          if (ytplayer) {            ytplayer.setVolume(newVolume);          }        }         function getVolume() {          if (ytplayer) {            return ytplayer.getVolume();          }        }         function clearVideo() {          if (ytplayer) {            ytplayer.clearVideo();          }        }
