$(document).ready(function(){
	/*
	/*
	/* vyrovnavam styly u opery
	*/
	if($.browser.opera) { $( function() {
		$("#original_view #img").attr("style", "margin-top: 10px;");
	});}
	/*
	/*
	/* zjisti rel cestu k souboru
	*/
	function getPath() {
		var str=window.location.pathname;
		var ma=/(\/)([a-zA-Z0-9\-]+)/g;
		var path=str.replace(ma,"$1..");
		return path;
	}
	/*
	/*
	/* nastavuje vysku okna pro fullsize pohled
	*/
	h = screen.availHeight;
	$("#setBoxHeight_show-original_l").height(h - 405);
	$("#setBoxHeight_show-original_l #img").height(h - 408);
	$("#setBoxHeight_show-original").height(h - 405);
	$("#setBoxHeight_show-original #img").height(h - 458);
	$("#setBoxHeight_show-original-browse").height(h - 283);
	$("#setBoxHeight_show-original-browse #img").height(h - 335);
	/*
	/*
	/* pokud nenapise nic do vyhledavaciho policka
	*/
	$("#searchForm").submit( function() {
		str = jQuery.trim($("#searchtext").attr("value"));
		co = str.length;
	  	if(co < 1) {
			alert($(".alert").attr("value"));
			return false;
		}
	});
	/*
	/*
	/* vyhledaci box, pokud zapne hledani podle uzivatele, tak vypinam ostatni a naopak
	*/
	$("#USER").click( function() { 
		$(this).parent().parent().children("label").children("input").removeAttr("checked");
		$(this).attr({checked:"checked"});
	});
	$(".checkbox").click( function() { 
		$("#USER").removeAttr("checked");
		//$(this).attr({checked:"checked"});
	});
	/*
	/*
	/* zavreni hlasky
	*/
	$("#close_err").click( function() { 
		$(this).parent().addClass("dNone");
	});
	$("#close_info").click( function() { 
		$(this).parent().addClass("dNone");
	});
	$("#close_mess").click( function() { 
		$(this).parent().addClass("dNone");
	});
	/*
	/*
	/* focus na user_name pole pri prihlaseni
	*/
	$("#loginBox #user_name").focus();
	/*
	/*
	/* akce pri zaskrtnuti checkboxu na recordu
	*/
	$("input.check").click( function() {
		stav = $(this).attr("checked");
		if(stav) {
			$(this).attr({checked:"checked"});
			$(this).parent().parent().children("a").children("img").addClass("ui-selected");
		} else {
			$(this).attr({checked:""});
			$(this).parent().parent().children("a").children("img").removeClass("ui-selected");
		}
	} );
	/*
	/*
	/* akce pri zaskrtnuti checkall a uncheck
	*/
	$(".checking").livequery(function(){
		$(".checking").click( function() {
			$("#dataBox input").attr("checked","checked");
			$("#dataBox tbody tr td div a img").addClass("ui-selected");
			$("#dataBox span a img").addClass("ui-selected");
			$(this).removeClass("checking");
			$(this).addClass("checked");
		});
    });
	$(".checked").livequery(function(){
		$(".checked").click( function() {
			$("#dataBox input").removeAttr("checked");
			$("#dataBox tbody tr td div a img").removeClass("ui-selected");
			$("#dataBox span a img").removeClass("ui-selected");
			$(this).removeClass("checked");
			$(this).addClass("checking");
		});
   	});
	/*
	/*
	/* akce pri zaskrtnuti checkall a uncheck na send to mail
	*/
	$(".checking").livequery(function(){
		$("#whatTodo .checking").click( function() {
			$("#whatTodo input").attr("checked","checked");
			$(this).removeClass("checking");
			$(this).addClass("checked");
		} );
	 });
	 $(".checked").livequery(function(){
		$("#whatTodo .checked").click( function() {
			$("#whatTodo input").removeAttr("checked");
			$(this).removeClass("checked");
			$(this).addClass("checking");
		} );
	});
	/*
	/*
	/* hodnoceni ostatnich prihlasenych useru
	*/
	$('.auto-submit-star').livequery(function(){
		$('.auto-submit-star').rating({
		  required: true,
		  half: true,
		  callback: function(value, link){
			$.post(getPath() + "index.php", 
				  { jquest:1, get_rating:1, user_vote:value },
				  function(json){
					if(json.search("##__OK__##") != -1) {
						$("#star_rating").empty();
						$("#star_rating").append(json.replace("##__OK__##", ""));
					} else {
						alert(json);
					}
				  }
			 );
		  }
		});
	});
	/*
	/*
	/* hodnoceni prihlaseneho majitele
	*/
	$('.my_own_star').livequery(function(){
		$('.my_own_star').rating({
		  cancel: 'Storno', 
		  half: true,
		  callback: function(value, link){
			v = value != "" ? value : $(this).parent().children("strong").attr("id"); 
			$.post(getPath() + "index.php", 
				  { jquest:1, get_my_own_rating:1, user_vote:v },
				  function(json){
					if(json.search("##__OK__##") == -1) {
						alert(json);
					}
				  }
			 );
		  }
		});
	});
	/*
	/*
	/* drag & drop original image
	*/
	$('#original_view #img img').draggable({
		cursor: 'move'
	});
	/*
	/*
	/* zapinani zobrazeni formulare pro vlozeni commentu
	*/
	$(".add_comment").click( function() { 
		$("#comment_form").css("display", "block");
		$(".add_comment").css("display", "none");
	});
});
