function calculateTotal(){
	var yellow_jednotka = $('#yellow_jednotka').val();
	var orange_jednotka = $('#orange_jednotka').val();
	var green_jednotka = $('#green_jednotka').val();
	var blue_jednotka = $('#blue_jednotka').val();
	
	var yellow_kusu = $('#yellow_kusu').val();
	var orange_kusu = $('#orange_kusu').val();
	var green_kusu = $('#green_kusu').val();
	var blue_kusu = $('#blue_kusu').val();
	
	var total =(+yellow_jednotka * +yellow_kusu) + (+orange_jednotka * +orange_kusu) + (+green_jednotka * +green_kusu) + (+blue_jednotka * +blue_kusu);
	//var total = ((+yellow_jednotka * +yellow_kusu) + (+orange_jednotka * +orange_kusu) + (+green_jednotka * +green_kusu) + (+blue_jednotka * +blue_kusu));
	var total_dph = total * 1.20;
	total = $().number_format(total, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});
	total_dph = $().number_format(total_dph, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});									   
	$("#total").text(total);
	$("#total_dph").text(total_dph);
}

function calculateYellow(){
	var yellow_jednotka = $('#yellow_jednotka').val();
	var yellow_aktivace = $('#yellow_aktivace').val();
	var yellow_poplatek = $('#yellow_poplatek').val();
	var yellow_kusu = $('#yellow_kusu').val();
	var total = (+yellow_jednotka + +yellow_aktivace + +yellow_poplatek) * +yellow_kusu;
	var total_dph = ((+yellow_jednotka + +yellow_aktivace + +yellow_poplatek) * +yellow_kusu) * 1.20;
	//alert(total);
	$("#yellow_total_hide").val(total);
	$("#yellow_total_dph_hide").val(total_dph);
	total = $().number_format(total, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});
	total_dph = $().number_format(total_dph, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});									   
	$("#yellow_total").text(total);
	$("#yellow_total_dph").text(total_dph);
}

function calculateOrange(){
	var orange_jednotka = $('#orange_jednotka').val();
	var orange_aktivace = $('#orange_aktivace').val();
	var orange_poplatek = $('#orange_poplatek').val();
	var orange_kusu = $('#orange_kusu').val();
	var total = (+orange_jednotka + +orange_aktivace + +orange_poplatek) * +orange_kusu;
	var total_dph = ((+orange_jednotka + +orange_aktivace + +orange_poplatek) * +orange_kusu) * 1.20;
	//alert(total);
	$("#orange_total_hide").val(total);
	$("#orange_total_dph_hide").val(total_dph);
	total = $().number_format(total, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});
	total_dph = $().number_format(total_dph, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});		
	$("#orange_total").text(total);
	$("#orange_total_dph").text(total_dph);
}

function calculateGreen(){
	var green_jednotka = $('#green_jednotka').val();
	var green_aktivace = $('#green_aktivace').val();
	var green_poplatek = $('#green_poplatek').val();
	var green_kusu = $('#green_kusu').val();
	var total = (+green_jednotka + +green_aktivace + +green_poplatek) * +green_kusu;
	var total_dph = ((+green_jednotka + +green_aktivace + +green_poplatek) * +green_kusu) * 1.20;
	//alert(total);
	$("#green_total_hide").val(total);
	$("#green_total_dph_hide").val(total_dph);	
	total = $().number_format(total, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});
	total_dph = $().number_format(total_dph, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});		
	$("#green_total").text(total);
	$("#green_total_dph").text(total_dph);
}

function calculateBlue(){
	var blue_jednotka = $('#blue_jednotka').val();
	var blue_aktivace = $('#blue_aktivace').val();
	var blue_poplatek = $('#blue_poplatek').val();
	var blue_kusu = $('#blue_kusu').val();
	var total = (+blue_jednotka + +blue_aktivace + +blue_poplatek) * +blue_kusu;
	var total_dph = ((+blue_jednotka + +blue_aktivace + +blue_poplatek) * +blue_kusu) * 1.20;
	//alert(total);
	$("#blue_total_hide").val(total);
	$("#blue_total_dph_hide").val(total_dph);	
	total = $().number_format(total, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});
	total_dph = $().number_format(total_dph, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});		
	$("#blue_total").text(total);
	$("#blue_total_dph").text(total_dph);
}

function calculateSecuritas(){
	var securitas_jednotka = $('#securitas_jednotka').val();
	var securitas_kusu = $('#securitas_kusu').val();
	var total_dph = (+securitas_jednotka) * +securitas_kusu;
	var total = ((+securitas_jednotka) * +securitas_kusu) / 1.20;
	//alert(total);	
	total = $().number_format(total, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});
	total_dph = $().number_format(total_dph, {
									   numberOfDecimals:2,
									   decimalSeparator: ',',
									   thousandSeparator: ' '});		
	$("#securitas_total").text(total);
	$("#securitas_total_dph").text(total_dph);
}

// JavaScript Document
			$(document).ready(function(){
				//Examples of how to assign the ColorBox event to elements.
				/*$('a[@rel*=lightbox]').colorbox({transition:"fade"});*/
				$("a[rel='example1']").colorbox({transition:"fade"});
				$(".colorbox").colorbox({iframe:true, width:500, height:500});	
				
				calculateYellow();
				calculateOrange();
				calculateGreen();
				calculateBlue();
				calculateTotal();
				calculateSecuritas();
				
				$('#yellow_kusu').keyup(function() {
					calculateYellow();
					calculateTotal();
				});
				$('#orange_kusu').keyup(function() {
					calculateOrange();
					calculateTotal();
				});
				$('#green_kusu').keyup(function() {
					calculateGreen();
					calculateTotal();
				});
				$('#blue_kusu').keyup(function() {
					calculateBlue();
					calculateTotal();
				});
				$('#securitas_kusu').keyup(function() {
					calculateSecuritas();
				});
							
				$('#dropdown > li').hover(
					function(){
						$(this).find('ul').slideDown('fast');
						$(this).find('a:eq(0)').addClass('activated');												
					},
					function(){
						$(this).find('ul').slideUp(0.001);
						$(this).find('a:eq(0)').removeClass('activated');	
					}
				);
				
				$('.menu_item').hover(
					function(){
						$(this).find('.sub_menu').show();
						//$(this).find('.sub_menu').slideDown('fast');
						//$(this).find('.sub_menu').css('display', 'block');
						$(this).find('a:eq(0)').addClass('activated');
					},
					function(){
						$(this).find('.sub_menu').slideUp('fast');
						//$(this).find('.sub_menu').slideUp(0.001);
						//$(this).find('.sub_menu').css('display', 'none');
						$(this).find('a:eq(0)').removeClass('activated');
					}
				);				
				
				/*
				$('.menu_item').hover(
					  function () {
						//$('.menu_first', this).addClass('slide-down'); 
						$('.menu_list', this).slideDown(100);
					  }, 
					  function () {
						obj = this;
						$('.menu_list', this).slideUp(100);
					  }
				);	*/	
				
				//onclick reset input value
				$('.form_input').focus(
					function() {
						if (this.value == this.defaultValue) {
							this.value = '';
						}
					}
					);
				$('.form_input').blur(
					function() {
						if (this.value == '') {
							this.value = this.defaultValue;
						}
					}
				);	
				
				$('.form_input_small').focus(
					function() {
						if (this.value == this.defaultValue) {
							this.value = '';
						}
					}
					);
				$('.form_input_small').blur(
					function() {
						if (this.value == '') {
							this.value = this.defaultValue;
						}
					}
				);					
				
				$('.form_textarea').focus(
					function() {
						if (this.value == this.defaultValue) {
							this.value = '';
						}
					}
					);
				$('.form_textarea').blur(
					function() {
						if (this.value == '') {
							this.value = this.defaultValue;
						}
					}
				);
				
				
				$(".tip").tooltip({
					cssClass:"tooltip"
				});
				
				$("#eng").click(
					function(){
					alert("Stránky se připravují | Pages are prepared");	
				});
				
				jQuery('a.email').each(function(i) {
					var text = $(this).text();
					var title = $(this).attr("title");
					var title_address = title.replace("(na)", "@");
					var text_address = text.replace("(na)", "@");
					$(this).attr('href', 'mailto:' + title_address);
						$(this).text(text_address);
						$(this).attr("title",title_address);
				});
				
				//autodoplnovani	
					//otherInput is the hidden text input
					jQuery('input:text[name=nazev_firmy]').keyup(function () {
						if (jQuery('.bill_ship:checked').attr('checked')) {
						  var value = jQuery(this).val();
						  jQuery('input:text[name=nazev_firmy_shipping]').val(value);
						}
					}).keyup();		
					jQuery('input:text[name=ulice]').keyup(function () {
						if (jQuery('.bill_ship:checked').attr('checked')) {
						  var value = jQuery(this).val();
						  jQuery('input:text[name=ulice_shipping]').val(value);
						}
					}).keyup();	
					jQuery('input:text[name=mesto]').keyup(function () {
						if (jQuery('.bill_ship:checked').attr('checked')) {
						  var value = jQuery(this).val();
						  jQuery('input:text[name=mesto_shipping]').val(value);
						}
					}).keyup();	
					jQuery('input:text[name=psc]').keyup(function () {
						if (jQuery('.bill_ship:checked').attr('checked')) {
						  var value = jQuery(this).val();
						  jQuery('input:text[name=psc_shipping]').val(value);
						}
					}).keyup();	
					
					jQuery(".bill_ship").click(function () {			
							if (jQuery('.bill_ship:checked').attr('checked')) {
								jQuery('input:text[name=nazev_firmy_shipping]').val(jQuery('input:text[name=nazev_firmy]').val());
								jQuery('input:text[name=ulice_shipping]').val(jQuery('input:text[name=ulice]').val());
								jQuery('input:text[name=mesto_shipping]').val(jQuery('input:text[name=mesto]').val());
								jQuery('input:text[name=psc_shipping]').val(jQuery('input:text[name=psc]').val());						
							}
							else{
								jQuery('input:text[name=nazev_firmy_shipping]').val('');
								jQuery('input:text[name=ulice_shipping]').val('');
								jQuery('input:text[name=mesto_shipping]').val('');
								jQuery('input:text[name=psc_shipping]').val('');
							}
					});						
			});	
			
	  function initialize() {
		var latlng = new google.maps.LatLng(49.57676, 17.23272);
		var myOptions = {
		  zoom: 14,
		  scrollwheel: false,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
		  var marker = new google.maps.Marker({
			  position: latlng, 
			  map: map, 
			  title:"Hello World!"
		  });	
	  }				
