$(document).ready(function(){
	//$(document).pngFix();
	$('#left_menu_slides').slideshow({playframe:false,width:177,height:150,time:7000,imgresize:false,imgzoom:false,imgcenter:true,effect:'random',panel:false,title:false}).playSlide();
	
});

function menu(num,pc){
	$.cookie('menu',num);
	$.post("menu.php",{num:num,pc:pc},function(data){
		$('#menu_obsah').html(data);
		if(num==6){
			$('table.tr_17px td').css("white-space","nowrap");
			$('table.tr_17px').css("background-color","white");
		}
		if(num==1)
			prepocitaj();
		if(num==4){
			$('#CustomSlideshow').slideshow({playframe:false,width:640,height:480,imgresize:false,imgzoom:false,imgcenter:true,effect:'random'}).playSlide();
			$('table.tr_17px').css("background-color","white");
		}
		if(num==2){
			$('table.tr_17px').css("background-color","white");
		}
		if(num==3){
			$('table.tr_17px').css("background-color","white");
		}
		if(num==5){
			doprava();
		}
	});
	
}

function doprava(){
	$.cookie('doprava',$('#doprava_select').val());$('#doprava').html($.cookie('doprava')+' €');
	$.post("format.php",{val:(Number($.cookie('doprava'))+$.cookie('cena')*1.19)},function(data){
		$('#vysledna_cena').html(data + ' €');
	});
	
	
}

function odosli_objednavku(){
	$.post("odosli_objednavku.php?"+$('form').serialize(),{send:'send',cookies:document.cookie},function(data){
		//alert(data);
		if(data.substring(0,2)=='ok'){
			alert('Vaša objednávka bola úspešne odoslaná.\nBudeme Vás kontaktovať čo najskôr!');
		}else{
			alert('Vyplňte, prosím správne formulár!');
		}
		//alert(data);
	});
	
}

function validate(){
	$.post("validate.php?"+$('form').serialize(),{send:'send'},function(data){
		//alert(data);
		if(data.substring(0,2)=='ok'){
			alert('Vaša správa bola úspešne odoslaná.\nBudeme Vás kontaktovať čo najskôr!');
		}else{
			alert('Vyplňte, prosím správne formulár!');
		}
		
	});
	
	
}
/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
*/
function prepocitaj(){
	var suma=0,cena;
	var basic_price=$('#basic_cena').val();
	
	$("select").each(function(){
		cena	=	$(this).val().split('|')[1];
		suma	+=	Number(cena);
		$.cookie(this.id,$(this).val().split('|')[0]);
	});
	suma		+=	Number(basic_price);
	
	$.cookie("cena",suma);
	$.post("format.php",{val:suma},function(data){
		$('#cena').html(data+' € / <span style="font-size:10px;">'+Math.floor(suma*119)/100+' €</span>');
	});
}

function menu_change(id){
	$('#main_text_podrobnosti').css('background','url(images/konfiguracia_'+id+'.jpg) no-repeat');
}