<!--
function countTotal() {
	var total = 0;
	$('span.row').each(function(){
		var add = (
			(
			//parseInt($(this).find('input.pack').val()) +
			parseInt($(this).find('input.price').val())
			)
			* parseInt($(this).find('input.rowcount').val())
		);

		if(isNaN(add))add = 0;
		total += add;
	});

	$('input#d_total').val(total);
}

function activateFoods() {
	//pocitani polozek
	$('span.row input.rowcount').keyup(function(){
		countTotal();
	});
}

$(document).ready(function(){
	//fotogalerie
	var gal = $('div#gallery a');

	if(gal.length) {
		gal.click(function(){
			$('body div.flash').each(function(){
				$(this).data('defHtml', $(this).html());

				var html = $(this).html();

				html = html.replace('<param name="movie"', '<param name="wmode" value="transparent" /><param name="movie"');
				html = html.replace('<PARAM NAME="Movie"', '<param name="wmode" value="transparent" /><PARAM NAME="Movie"');

				html = html.replace('<embed', '<embed wmode="transparent"');
				html = html.replace('<EMBED', '<EMBED wmode="transparent"');

				$(this).html(html);
			});
		});

		gal.prettyPhoto({
			theme:'dark_rounded',
			callback: function(){
				$('body div.flash').each(function(){
					$(this).html($(this).data('defHtml'));
				});
			}
		});
	}

	//obednavky jidel
	if($('select#giftrest').length) {
		$('select#giftrest').change(function(event){
			if($(this).val() == 16) {
				$('td.giftSel').css('display', 'table-cell');
			} else {
				$('td.giftSel').css('display', 'none');
			}
		});
	}

	if($('input#d_order_date').length) {
		//kalendar
		$("input#d_order_date").attr('readonly', 'readonly');
		$('.stdSubmit').hide();

		if(jsLan == 'cs') {
			$("input#d_order_date").datepicker({
				monthNames: ['leden','únor','březen','duben','květen','červen','červenec','srpen','září','říjen','listopad','prosinec'],
				monthNamesShort: ['led','úno','bře','dub','kvě','čer','čvc','srp','zář','říj','lis','pro'],
				dayNames: ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'],
				dayNamesShort: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
				dayNamesMin: ['ne','po','út','st','čt','pá','so'],
				firstDay: 1
			});

		} else {
			$("input#d_order_date").datepicker();
		}

		$("input#d_order_date").datepicker('option', {dateFormat: 'dd.mm. yy'});
		$("input#d_order_date").datepicker('option', {
			minDate: new Date(calStart[0], calStart[1] -1, calStart[2]),
			maxDate: new Date(calEnd[0], calEnd[1]-1, calEnd[2]),
			onSelect: function(dateText, inst) {
				$.get(
					'get_menu.inc.php',
					{
						'ajax': "true",
						'place': $('input#d_place').val(),
						'formdate': dateText,
						'LANG': $('input#d_lang').val()
					},
					function(data){
						$('div#foodselection').html(data);
						activateFoods();
					}
				);
			}
		});

		$("input#d_order_date").datepicker('setDate', new Date(calDef[0], calDef[1]-1, calDef[2]));

		activateFoods();
		countTotal();
	}
});

$(window).load(function () {
});

function count_certif_total() {
	var total = 0,
		val_500 = document.getElementById('val_500').value,
		num_500 = document.getElementById('num_500').value,

		val_1000 = document.getElementById('val_1000').value,
		num_1000 = document.getElementById('num_1000').value;

/*		val_5000 = document.getElementById('val_5000').value,
		num_5000 = document.getElementById('num_5000').value,

		own_val = document.getElementById('own_val').value,
		num_own_val = document.getElementById('num_own_val').value; */

	total = (num_500 * val_500) + (num_1000 * val_1000);
//	total = (num_500 * val_500) + (num_1000 * val_1000) + (num_5000 * val_5000) + (own_val * num_own_val);
	document.getElementById('total_cost').value = total;
}

function m_on(eleId){
	if(m_perm == false){
		for(x = 0; x < menu.length; ++x){
			if(menu[x][0] == eleId){
				document.getElementById(eleId).src = menu[x][2];
			}
		}
	}
}

function m_off(eleId){
	if(m_perm == false){
		for(x = 0; x < menu.length; ++x){
			if(menu[x][0] == eleId){
				document.getElementById(eleId).src = menu[x][1];
			}
		}
	}
}

function m_pon(eleId){
	m_perm = true;
	for(x = 0; x < menu.length; ++x){
		if(menu[x][0] == eleId){
			document.getElementById(eleId).src = menu[x][2];
		}
	}
}

function m_poff(eleId){
	m_perm = false;
	for(x = 0; x < menu.length; ++x){
		if(menu[x][0] == eleId){
			document.getElementById(eleId).src = menu[x][1];
		}
	}
}

function show_elem(eleId) {
	document.getElementById(eleId).style.display = 'block';
}

function hide_elem(eleId) {
	document.getElementById(eleId).style.display = 'none';
}

function blick(eleId){
	if(document.getElementById(eleId).style.display == 'none'){
		document.getElementById(eleId).style.display = 'block';
	}else{
		document.getElementById(eleId).style.display = 'none';
	}
}

function del_values(firma_id, oddel_id, pozice_id) {
	document.getElementById(firma_id).value = '';
	document.getElementById(oddel_id).value = '';
	document.getElementById(pozice_id).value = '';
}

function check_flip(eleId){
	if(document.getElementById(eleId).checked != 1){
		document.getElementById(eleId).checked = 1;
	}else{
		document.getElementById(eleId).checked = 0;
	}
}

function check(eleId){
	document.getElementById(eleId).checked = 1;
}

function getMouseXY(e) {
	if (IE) {
		mouse['x'] = event.clientX + document.body.scrollLeft;
		mouse['y'] = event.clientY + document.body.scrollTop;
	}
	else {
		mouse['x'] = e.pageX;
		mouse['y'] = e.pageY;
	}

	if (mouse['x'] < 0) {
		mouse['x'] = 0;
	}
	if (mouse['y'] < 0) {
		mouse['y'] = 0;
	}

	return true
}

function map_window(place, title) {
	var map_width = 265,
		map_height = 191,
		doc_width = 0,
		doc_height = 0,
		doc_x_offset = 0,
		doc_y_offset = 0,
		rest_x = 0,
		rest_y = 0,
		off_x = 0,
		off_y = 0;

	if (IE) {
		doc_width = document.body.offsetWidth;
		doc_height = document.body.offsetHeight;
		scroll_top = document.body.scrollTop;
		scroll_left = document.body.scrollLeft;
	}
	else {
		doc_width = innerWidth;
		doc_height = innerHeight;
		scroll_top = window.pageYOffset;
		scroll_left = window.pageXOffset;
	}

	doc_x_offset = screen.width - doc_width;
	doc_y_offset = screen.height - doc_height;

	rest_x = screen.width - doc_x_offset - mouse['x'] + scroll_left;
	rest_y = screen.height - doc_y_offset - mouse['y'] + scroll_top;

	if (rest_x > map_width) {
		off_x = mouse['x'] - scroll_left + doc_x_offset;
	}
	else {
		off_x = mouse['x'] - scroll_left + doc_x_offset - map_width;
	}

	if (rest_y > map_height) {
		off_y = mouse['y'] - scroll_top + doc_y_offset - 60;
		// - 60 : cca. browser bottom panel
	}
	else {
		off_y = mouse['y'] - scroll_top + doc_y_offset - map_height - 90;
		// - 60 cca. browser bottom panel + (-30) cca. top panel of new window
	}

	window.open('map_window.php?place='+place+'&title='+title+'', 'picwindow', 'width='+map_width+', height='+map_height+', left='+off_x+', top='+off_y+'');
}

function pic_window(picfile, title, popis, picwidth, picheight){
	picheight += 100;
	window.open('pic_window.php?pic='+picfile+'&title='+title+'&popis='+popis+'', 'picwindow', 'width='+picwidth+',height='+picheight+'');
}

function pic_window2(picfile, title, picwidth, picheight){
	window.open('pic_window2.php?pic='+picfile+'&title='+title+'', 'picwindow', 'width='+picwidth+',height='+picheight+'');
}

function pic_window_unique(picfile, title, picwidth, picheight){
	wincap = 'picwindow_'+(basename(picfile));
	wincap = wincap.split('.');
	window.open('pic_window2.php?pic='+picfile+'&title='+title+'', wincap[0], 'width='+picwidth+',height='+picheight+'');
}

function pic_window_resizable(picfile, title){
	window.open('pic_window2.php?pic='+picfile+'&title='+title+'', 'picwindow');
}

function scrollable_window(file, width, height){
	window.open(file, 'scwindow', 'width='+width+',height='+height+',scrollbars=yes');
}

function gift_window(picfile, title, picwidth, picheight){
	picwidth += 16;
	window.open('pic_window2.php?pic='+picfile+'&title='+title+'', 'picwindow', 'width='+picwidth+',height='+picheight+', scrollbars=yes');
}

function dtimer(){
	window.setTimeout(delay_submit, 500);
}

function form_submit(eleId){
	document.getElementById(eleId).submit();
}

function delay_submit(){
	document.getElementById('kolik').form.submit();
}

function chbgcolor(eleId){
	document.getElementById(eleId).bgColor = '#FCFAE3';
}

function chbgcolorb(eleId){
	document.getElementById(eleId).bgColor = '#FFFFFF';
}

function go_parent(go_link) {
		opener.document.location.href = go_link;
}

function basename(path){
	parsed = path.split('/');
	return parsed[parsed.length - 1];
}
//-->