<!--
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

function submenu(idn, on, item) {
	obj = document.getElementById(idn);
	obj.style.visibility = "hidden";


	var cc = item.childNodes['length'];
	var xx = 0;
	for (i = 0; i < cc; i++) {
		if (item.childNodes[i].nodeName == "A") {
			xx = i;
			break;
		}
	}


	item.childNodes[xx].style.backgroundColor = "rgb(255,239,214)";
	item.childNodes[xx].style.color = "rgb(178,0,0)";

	//item.childNodes[xx].style.zIndex = 1000;

	if (on) {
		obj.style.visibility = "visible";
		item.childNodes[xx].style.backgroundColor = "rgb(255,84,0)";
		item.childNodes[xx].style.color = "rgb(255,255,255)";
	}
}

var url="http://www.nakupovat.sk/";
var title="Nakupovať.sk - Obchody, Foto & Kamery";

function favorites(url,title){
  if(document.all)
  window.external.AddFavorite(url,title)
}

function vote(pollid,choiceid) {
        var url = "poll.vote.php?pollid="+pollid+"&aid="+choiceid;

        newwin = window.open(url,'Vote','width=350,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
        newwin.focus();
     }

function viewresults(pollid) {
        var url = "poll.results.php?pollid="+pollid;

        newwin = window.open(url,'ViewResults','width=350,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
        newwin.focus();
}

function CK_Region(){

   //submitne form v ktorom sa v selekt boxe vybera mainlocationid pre skriptik main_setmainlocation.php,
   myChoice1    = document.RegForm.mainlocationidsubmit.selectedIndex;
   mySelection1 = document.RegForm.mainlocationidsubmit.options[myChoice1].value;

   if (parseInt(mySelection1)>0) {
	  //location="index.php";
      document.RegForm.submit();
   }

}

function CK_Region2(){

   //submitne form v ktorom sa v selekt boxe vybera mainlocationid pre skriptik main_setmainlocation.php,
   myChoice1    = document.RegForm2.mainlocationidsubmit.selectedIndex;
   mySelection1 = document.RegForm2.mainlocationidsubmit.options[myChoice1].value;

   if (parseInt(mySelection1)>0) {
	  //location="index.php";
      document.RegForm2.submit();
   }

}

function Bool2F(val) {
 if (val) return '1'; else return '';
}

function IsValidTime(timeStr) {

	var sep = /\s*[;,]\s*/;
	var intervals = timeStr.split(sep);
	var timePat = /^\s*(\d{1,2}):(\d{2})\s*[-]\s*(\d{1,2}):(\d{2})$/;

	for (i in intervals) {
		if (intervals[i].length==0) continue;
		var matchArray = intervals[i].match(timePat);
		if ((matchArray == null) || (matchArray.length < 5)) {
			alert("Nesprávny formát času.\nSprávne je napr: 8:00 - 12:00, 16:00 - 3:00");
			return false;
		}
		hour1 = matchArray[1];
		minute1 = matchArray[2];
		hour2 = matchArray[3];
		minute2 = matchArray[4];

		if (hour1 < 0  || hour1 > 24 || hour2 < 0  || hour2 > 24) {
			alert("Hodina musí byť číslo v intervale 0..24 ");
			return false;
		}
		if (minute1<0 || minute1 > 59 || minute2<0 || minute2 > 59) {
			alert ("Minúta musí byť číslo v intervale 0..59");
			return false;
		}
	}
	return true;
}

    // Tato funkcia predstavuje call-back, je vyvolana po tom, co server vrati odpoved
	function do_osRefreshBox_cb(z) {
		document.getElementById("osbox").innerHTML = z;
	}

	// Tato funkcia poziada server o odpoved a skonci (na odpoved necaka)
	function do_osRefreshBox() {
		x_osRefreshBox(do_osRefreshBox_cb);
	}

 	// Tato funkcia poziada server o odpoved a skonci (na odpoved necaka)
	function do_osMenuAdd(menuitemid, amountAdd, name, portion) {
		var restid = document.getElementById('restid').value;
		var elementName = 'pocet' + menuitemid;
		var elementValue = document.getElementById(elementName).value;
		if (portion == null) {
			if (document.getElementById('activePortion') == null){
				portion = 0;
			} else {
				portion = document.getElementById('activePortion').value - 1;
			}
		}
		var portionName = 'portion'+portion+'-'+menuitemid;
		var portionAmount;
		if (document.getElementById(portionName) == null)
			portionAmount = 0;
		else
			portionAmount = document.getElementById(portionName).value;
		portionName = 'portion' + portion + '-' + menuitemid;
		var portionValue;
		if (document.getElementById(portionName) == null)
			portionValue = 0;
		else
			portionValue = parseInt(document.getElementById(portionName).value);
		var amount;
		if ((elementValue+0) == 0) {
			amount = parseInt(parseInt(elementValue+0)+0);
		} else {
			amount = parseInt(elementValue);
		}
		x_osMenuAdd(menuitemid, amountAdd, portion, restid, do_osMenuAdd_cb);
		if ((portionValue + amountAdd) >= 0) {
			document.getElementById(elementName).value = parseInt(amount+amountAdd);
			if (document.getElementById(portionName) != null)
				document.getElementById(portionName).value = parseInt(portionValue+amountAdd);
			else {
				element = document.createElement('input');
				element.setAttribute("type", "hidden");
				element.setAttribute("name", "portion"+portion+'-'+menuitemid);
				element.setAttribute("value", portionValue+amountAdd);
			}
			var name2 = name.substr(0, 30);
        	if (name.length > 30){
            	name2 += "...";
            }
            var text = '';
            if (portionAmount >= 1) {
            	text = '<br />TIP: vložte ho do <a href="os.menu.php?restid='+restid+'&action=newportion&itemid='+menuitemid+'">»samostatnej porcie«</a> (zobrazuje sa v pravej lište).';
				document.getElementById('com_line_text').style.height = "37px";
				document.getElementById('com_line_text_left').style.height = "20px";
        document.getElementById('com_line_text_right').style.height = "27px";
        document.getElementById('com_line_text_left').style.marginBottom = "-4px";
//				document.getElementById('com_line_left_image').setAttribute('src', 'imgs/os_leftborder2.png');
//				document.getElementById('com_line_right_image').setAttribute('src', 'imgs/os_rightborder2.png');
            } else {
				document.getElementById('com_line_text').style.height = "17px";
				document.getElementById('com_line_text_left').style.height = "0px";
        document.getElementById('com_line_text_right').style.height = "7px";
        document.getElementById('com_line_text_left').style.marginBottom = "-9px";        
//           	document.getElementById('com_line_text').className = 'comlineborder';
//				document.getElementById('com_line_left_image').setAttribute('src', 'imgs/os_leftborder.png');
//				document.getElementById('com_line_right_image').setAttribute('src', 'imgs/os_rightborder.png');
			}
			if (amountAdd > 0) {
				document.getElementById('com_line_text').innerHTML = 'Práve ste pridali do objednávky '+amountAdd+' x '+name2+'.' + text;
			} else {
				document.getElementById('com_line_text').style.height = "17px";
				document.getElementById('com_line_text_left').style.height = "0px";
        document.getElementById('com_line_text_right').style.height = "7px"; 
//            	document.getElementById('com_line_text').className = 'comlineborder';
//				document.getElementById('com_line_left_image').setAttribute('src', 'imgs/os_leftborder.png');
//				document.getElementById('com_line_right_image').setAttribute('src', 'imgs/os_rightborder.png');
//				document.getElementById('com_line_text').innerHTML = 'Práve ste ubrali z objednávky 1 x '+name2+'.';
			}
			document.getElementById('os_comline').style.display = "block";
			if ((amount + amountAdd) == 0) {
				document.getElementById('item'+menuitemid).innerHTML = '';
			} else {
				document.getElementById('item'+menuitemid).innerHTML = parseInt(amount+amountAdd) + ' x';
			}
		}
	}

   // Tato funkcia predstavuje call-back, je vyvolana po tom, co server vrati odpoved
	function do_osMenuAdd_cb(z) {
	    if (z=='true') {
	       // teraz vyvolame refresh praveho panelu, opat asynchronne:
	       do_osRefreshBox();
	    } else if (z=='error'){
	    	alert('V tejto porcii sa nenachádza dané jedlo, preto ho nemôžete odstrániť.');
	    } else if (z=='badrest') {
	    	alert('Jedlo/nápoj nebolo pridané, pretože si vyberáte z ponuky inej reštaurácie.');
	    } else {
	       // vyprsala session? clovek nie je prihlaseny?
	       alert ('Pri pokuse o uloženie položky nastala neznáma chyba. Skúste sa odhlásiť a zopakovať celú akciu znova');
	    }
	}

	function do_osPortionAdd_cb(z) {
	    if (z=='true')
	       do_osRefreshBox();
	    else if (z=='empty')
	       alert('Aktuálna porcia je prázdna, je zbytočné pridávať ďalšiu.');
	    else{
	       // vyprsala session? clovek nie je prihlaseny?
	       alert ('Pri pokuse o uloženie položky nastala neznáma chyba. Skúste sa odhlásiť a zopakovať celú akciu znova');
	    }
	}

	function do_osCancelOrder(){
		var ans = confirm('Naozaj chcete zmazať objednávku?');
		if (ans)
			x_osCancelOrder(do_osCancelOrder_cb);
	}

	function do_osCancelOrder_cb(z){
	    if (z=='true')
	       location.href = "os.service.list.php";
	    else{
	       // vyprsala session? clovek nie je prihlaseny?
	       alert ('Pri pokuse o uloženie položky nastala neznáma chyba. Skúste sa odhlásiť a zopakovať celú akciu znova');
	    }

	}
	function do_osActivatePortion(p){
		x_osActivatePortion(p, do_osActivatePortion_cb);
	}

	function do_osActivatePortion_cb(z){
	    if (z>=0){
	    	document.getElementById('activePortion').value = z;
	    	do_osRefreshBox();
	    }
	    else{
	       // vyprsala session? clovek nie je prihlaseny?
	       alert ('Pri pokuse o uloženie položky nastala neznáma chyba. Skúste sa odhlásiť a zopakovať celú akciu znova');
	    }
	}

	function isInteger(s){
		for (var n = 0; n < s.length; n++){
			var c = s.charAt(n);
			if (((c < "0") || (c > "9"))){
				alert("Zle zadaný počet!");
				return false;
			}
		}
		return true;
	}

	function changeDisplay(id, v){
		var vid = id + 'vis';
		var icon = id + '_icon';
		var visibility = document.getElementById(vid).value;

		if (visibility == 0){
			document.getElementById(id).style.display = 'block';
			document.getElementById(vid).value = 1;
			document.getElementById(icon).src = "imgs/os.Double-Arrow-Dn.gif";
		}
		else {
			document.getElementById(id).style.display = 'none'
			document.getElementById(vid).value = 0;
			document.getElementById(icon).src = "imgs/os.Double-Arrow-Up.gif";
		}
	}



/* getElementById shortcut */
function gE(el) {
  return document.getElementById(el);
}

/* returns selected Value of <select> */
function gV(el) {
 return document.getElementById(el).options[document.getElementById(el).selectedIndex].value;
}

/* returns selected option of <select> */
function gO(el) {
 return document.getElementById(el).options[document.getElementById(el).selectedIndex].text;
}

function isMail(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Nezadali ste správne Vašu e-mailovú adresu!");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Nezadali ste správne Vašu e-mailovú adresu!");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Nezadali ste správne Vašu e-mailovú adresu!");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Nezadali ste správne Vašu e-mailovú adresu!");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Nezadali ste správne Vašu e-mailovú adresu!");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Nezadali ste správne Vašu e-mailovú adresu!");
		    return false;
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Nezadali ste správne Vašu e-mailovú adresu!");
		    return false;
		 }
 		 return true;
	}
	function isPhone(s){
		for (var n = 0; n < s.length; n++){
			var c = s.charAt(n);
			if (((c >= "0") && (c <= "9")) || (c == " ") || (c == "/") || (c == "+"))
				continue;
			else {
				alert('Zadali ste neplatné telefónne číslo!');
				return false;
			}
		}
		return true;
	}
function urlencode(str) {
	str = new String(str);
	var str2 = '';
	var hash_map = {}, letters = new Array();

	hash_map['Š'] = '%8A'; letters.push('Š');
	hash_map['Ť'] = '%8D'; letters.push('Ť');
	hash_map['Ž'] = '%8E'; letters.push('Ž');
	hash_map['š'] = '%9A'; letters.push('š');
	hash_map['ť'] = '%9D'; letters.push('ť');
	hash_map['ž'] = '%9E'; letters.push('ž');
	hash_map['ľ'] = '%BE'; letters.push('ľ');
	hash_map['Á'] = '%C1'; letters.push('Á');
	hash_map['Ä'] = '%C4'; letters.push('Ä');
	hash_map['Ĺ'] = '%C5'; letters.push('Ĺ');
	hash_map['Č'] = '%C8'; letters.push('Č');
	hash_map['É'] = '%C9'; letters.push('É');
	hash_map['Í'] = '%CD'; letters.push('Í');	
	hash_map['Ď'] = '%CF'; letters.push('Ď');
	hash_map['Ň'] = '%D2'; letters.push('Ň');
	hash_map['Ó'] = '%D3'; letters.push('Ó');
	hash_map['Ô'] = '%D4'; letters.push('Ô');
	hash_map['Ú'] = '%DA'; letters.push('Ú');
	hash_map['á'] = '%E1'; letters.push('á');
	hash_map['ä'] = '%E4'; letters.push('ä');
	hash_map['ĺ'] = '%E5'; letters.push('ĺ');
	hash_map['č'] = '%E8'; letters.push('č');
	hash_map['é'] = '%E9'; letters.push('é');
	hash_map['í'] = '%ED'; letters.push('í');	
	hash_map['ď'] = '%EF'; letters.push('ď');
	hash_map['ň'] = '%F2'; letters.push('ň');
	hash_map['ó'] = '%F3'; letters.push('ó');
	hash_map['ô'] = '%F4'; letters.push('ô');
	hash_map['ú'] = '%FA'; letters.push('ú');
	hash_map[' '] = '%20'; letters.push(' ');

	for (i = 0; i < str.length; i++) {
		if (in_array(str.charAt(i), letters)) {
			str2 += hash_map[str.charAt(i)];
		} else {
			str2 += str.charAt(i);
		}
	}

	return str2;
}

function in_array(needle, haystack) {
	var n = haystack.length;
	for ( var i = 0; i < n; i++) {
		if (haystack[i] == needle) {
			return true;
		}
	}
	return false;
}

// -->
