function login() {
	$("#ajax").show("fast");
	$.post('/shop/login/',{
		user:$("input[name='user']").val(),
		pass:$("input[name='pass']").val()
	},
		function(xml) {
			if(xml == "OK") {
				$("#login-ok").show("fast");
				$("#login").hide("fast");
				$("#basket-links").show("fast");
				$("#basket-top").load("/shop/get/login");
				$("#basket").load("/shop/get/basket");
			}
			else {
				alert("Přihlášení se nezdařilo. Špatné jméno nebo heslo.");
			}
			$("#ajax").hide("fast");
		}
	)
};
function logout() {
	$("#ajax").show("fast");
	$.get('/shop/logout/',
		function(xml) {
			if(xml == "OK") {
				$("#login").show("fast");
				$("#login-ok").hide("fast");
				$("#basket-links").hide("fast");
				$("#basket-top").load("/shop/get/login");
				$("#basket").load("/shop/get/basket");
			}
			else {
				alert("Odhlášení se nezdařilo");
			}
			$("#ajax").hide("fast");
		}
	)
};

function addToBasket(polozka_id,ajax){
	$("#ajax").show("fast");
	$.post('/shop/doKosiku/',{
	id:polozka_id,
	varianta:ajax,
	count:$("input[name='pocet']").val()
	},
		function(xml) {
			$("#basket").html(xml);
			$("#ajax").hide("fast");
		}
	);
};

function rmFromBasket(index) {
	$("#ajax").show("fast");
	$.post('/shop/zKosiku/',{
	index:index
	},
		function(xml) {
			$("#basket").load("/shop/get/basket");
			$("#ajax").hide("fast");
		}
	);
};

function obj(id) {
	if ($("#"+id).attr("class") == "hide") {
		$("#"+id).show("fast");
		$("#"+id).attr("class","");
		$("#"+id+"-text").html("Skrýt");
	}
	else {
		$("#"+id).hide("fast");
		$("#"+id).attr("class","hide");
		$("#"+id+"-text").html("Zobrazit");
	}
};

function loadCost(ajax,id){
	$("#ajax").show("fast");
	values = ajax;
	$("#cost").load("/shop/detail/"+id+"/cost/"+values);
	$("#store").load("/shop/detail/"+id+"/store/"+values);
	$("#ajax").hide("fast");
};

function showVar(){
	$("#showvar").hide("slow")
	$("#hidevar").show("slow")
	$("#vardetails").show("slow")
};

function hideVar(){
	$("#showvar").show("slow")
	$("#hidevar").hide("slow")
	$("#vardetails").hide("slow")
};

function sendComment(){
	$("#commenterror").hide();
	$.post('/gallery/addComment/',{
		id:$("input[name='id']").val(),
		author:$("input[name='name']").val(),
		text:$("textarea[name='text']").val()
		},
		function(xml) {
			if(xml == "1") {
			}
				else {
			}
		}
		);
};

function showObj(){
	$("#objbutton").hide("slow")
	$("#obj").show("slow")
	chdoprava();
};
function showReg(){
	$("#regbuttonoff").show("slow")
	$("#regbuttonon").hide("slow")
	$("#regtext").show("slow")
	$("#reg").show("slow")
	$("input[name='reg']").val("1")
};
function hideReg(){
	$("#regbuttonoff").hide("slow")
	$("#regbuttonon").show("slow")
	$("#regtext").hide("slow")
	$("#reg").hide("slow")
	$("input[name='reg']").val("0")
};
function showFirma(){
	$("#firmabuttonoff").show("slow")
	$("#firmabuttonon").hide("slow")
	$("#firmatext").show("slow")
	$("#firma").show("slow")
	$("input[name='fir']").val("1")
};
function hideFirma(){
	$("#firmabuttonoff").hide("slow")
	$("#firmabuttonon").show("slow")
	$("#firmatext").hide("slow")
	$("#firma").hide("slow")
	$("input[name='fir']").val("0")
};
function showFakUdaje(){
	$("#fakudajebuttonoff").show("slow")
	$("#fakudajebuttonon").hide("slow")
	$("#fakudajetext").show("slow")
	$("#fakudaje").show("slow")
	$("input[name='fak']").val("1")
};
function hideFakUdaje(){
	$("#fakudajebuttonoff").hide("slow")
	$("#fakudajebuttonon").show("slow")
	$("#fakudajetext").hide("slow")
	$("#fakudaje").hide("slow")
	$("input[name='fak']").val("0")
};

function passwd(){
	$("#ajax").show("fast");
	$.post('/shop/heslo/',{
		oldpass:$("input[name='oldpass']").val(),
		newpass1:$("input[name='newpass1']").val(),
		newpass2:$("input[name='newpass2']").val()
	},
		function(xml) {
			$("#ajax").hide("fast");
			if(xml != "OK") {
				$("#errors").html(xml);
			}
			else {
				document.location = "/shop/text/passok";
			}
		}
	);
};

function reg(){
	$("#ajax").show("fast");
	$.post('/shop/registrovat/',{
		jmeno:$("input[name='jmeno']").val(),
		email:$("input[name='email']").val(),
		telefon:$("input[name='telefon']").val(),
		ulice:$("input[name='ulice']").val(),
		mesto:$("input[name='mesto']").val(),
		psc:$("input[name='psc']").val(),
		zeme:$("input[name='zeme']").val(),
		fakulice:$("input[name='fakulice']").val(),
		fakmesto:$("input[name='fakmesto']").val(),
		fakpsc:$("input[name='fakpsc']").val(),
		fakzeme:$("input[name='fakzeme']").val(),
		firma:$("input[name='firma']").val(),
		ic:$("input[name='ic']").val(),
		dic:$("input[name='dic']").val(),
		fir:$("input[name='fir']").val(),
		fak:$("input[name='fak']").val()
	},
		function(xml) {
			$("#ajax").hide("fast");
			if(xml != "OK") {
				$("#errors").html(xml);
			}
			else {
				document.location = "/shop/text/regok";
			}
		}
	);
};

function order(){
	$("#ajax").show("fast");
	$.post('/shop/objednat/',{
		jmeno:$("input[name='jmeno']").val(),
		email:$("input[name='email']").val(),
		telefon:$("input[name='telefon']").val(),
		ulice:$("input[name='ulice']").val(),
		mesto:$("input[name='mesto']").val(),
		psc:$("input[name='psc']").val(),
		zeme:$("select[name='zeme']").val(),
		fakulice:$("input[name='fakulice']").val(),
		fakmesto:$("input[name='fakmesto']").val(),
		fakpsc:$("input[name='fakpsc']").val(),
		fakzeme:$("select[name='fakzeme']").val(),
		firma:$("input[name='firma']").val(),
		ic:$("input[name='ic']").val(),
		dic:$("input[name='dic']").val(),
		uzivatel:$("input[name='uzivatel']").val(),
		heslo1:$("input[name='heslo1']").val(),
		heslo2:$("input[name='heslo2']").val(),
		reg:$("input[name='reg']").val(),
		fir:$("input[name='fir']").val(),
		fak:$("input[name='fak']").val(),
		doprava:$("select[name='doprava']").val()
	},
		function(xml) {
			$("#ajax").hide("fast");
			if(xml != "OK") {
				$("#errors").html(xml);
			}
			else {
				document.location = "/shop/text/ok";
			}
		}
	);
};

function chLogoText(text) {
	$("#logo-text").hide().text(text).slideDown("slow");
};

function chPrewImg(url1,url2) {
	$("#prewimg").attr({src:url1});
	$("#aprew").attr({href:url2});
};

function chdoprava() {
	id = $("select[name='doprava']").val();
	$("#doprava_td").load("/shop/get/doprava/"+id)
	$("#celkem").load("/shop/get/price/"+id)

};


