function menu(id){
	if(document.getElementById(id).style.display == 'inline')
		document.getElementById(id).style.display = 'none';
	else 	
		document.getElementById(id).style.display = 'inline';
}

function show(name,width,height) {
		
	no=window.open('', 'zoomv', 'width='+width+', height='+height+', toolbar=no, menubar=no,'+
				'scrollbars=no, resizable=no, copyhistory=no');
	with (no.document)
	{
		open();
		writeln("<html>\n<title>Fotogalerie</title>\n<body topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0' bgcolor='#000000'>\n<center>");
		writeln('<img style="cursor: hand; cursor: pointer;" src='+name+' border="0" onclick="window.close()"></a>');
		writeln("</center>\n</body>\n</html>");
	}
} 



function select_all() {
	
	users_select = document.getElementById('email_select');
	
	for(i = 0; i < users_select.length; i++) {
		users_select[i].selected = true;
	}

}


function unselect_all() {
	
	users_select = document.getElementById('email_select');
	
	for(i = 0; i < users_select.length; i++) {
		users_select[i].selected = false;
	}

}

function delete_children() {
	
	var payment_table = document.getElementById('payment');
	
	var kids = payment_table.childNodes;
	var numKids = kids.length;
	var i = 0;
	
	//alert(numKids)
	
	for(i = numKids; i > 1; i--) {
		
		//alert(kids[i]+'node '+i+' pruchod '+i);
		if(kids[i] != null) payment_table.removeChild(kids[i]);
	}
}


function postalPrice(price) {
	
	var postal_price = document.getElementById('postal_price');
	postal_price.value = price;
	
}

function setPayment(price,currency_name) {

	var payment = document.getElementById('payment_price');
	payment.value = price+' '+currency_name;
	
	update_price_all(currency_name)
	
}

//funkce aktualizuje celkovou cenu
function update_price_all(currency_name) {
	
	var products_price = document.getElementById('products_price');
	var postal_price = document.getElementById('postal_price');
	var payment_price = document.getElementById('payment_price');
	var price_all = document.getElementById('price_all');
	
	var products = products_price.value;
	var postal = postal_price.value;
	var payment = payment_price.value;
	var all = 0;
	
	products = products.split(' ');
	postal = postal.split(' ');
	payment = payment.split(' ');
	
	all += parseFloat(products[0]);
	all += parseFloat(postal[0]);
	all += parseFloat(payment[0]);
	
	price_all.value = all+' '+currency_name;
}



//funkce generuje tabulku moznosti typu plaby
function getPayment(id,price,currency_name) {
	var select = document.getElementById('select');
	
	if(select.value != 0) {
		var invisible = document.getElementById('payment_'+select.value);
		invisible.style.display = 'none';
	}

	var payment = document.getElementById('payment_'+id);
	payment.style.display = 'inline';
	
	select.value = id;
	
	postalPrice(price+' '+currency_name);
	update_price_all(currency_name);
	
}


//zkontroluje zda jsou vybrane vsechny moznosti
function checkData(message) {
	
	var postal = document.getElementById('step_2');
	var checked = false;
	
	for(i = 0; i < postal.elements['poslat'].length; i++) {
		
		if(postal.elements['poslat'][i].checked == true) checked = true;
	}
	
	
	
	if(postal.elements['payment'] != null) {
		checked = false;
		
		/*for(i = 0; i < postal.elements['payment'].length; i++) {
			
			alert('Ahoj 2');
			if(postal.elements['payment'][i].checked == true) checked = true;
		}*/
		
		if(postal.elements['payment'].checked == true) checked = true;
	}
	
	
	if(checked == true) return true;
	else {
		alert(message);
		return false;
	}
}

function copy_address() {
	document.getElementById('pname').value = document.getElementById('name').value;
	document.getElementById('paddress').value = document.getElementById('address').value;
	document.getElementById('ptown').value = document.getElementById('town').value;
	document.getElementById('pcompany').value = document.getElementById('company').value;
	document.getElementById('pzip').value = document.getElementById('zip').value;
	document.getElementById('pcountry').value = document.getElementById('country').value;
	
}

