// JQuery functions

$(document).ready(function(){
	
	$("#foot-menu li:last").css({"background":"none"});
	$("#foot-menu li:first").css({"padding-left":"0"});
	$("#banners div.banner:odd").css({"float":"right"});
	
	$("#search").click(function() {
     	var keyword = $(this).val();
     	if (keyword == 'vyhledat...') {
     		$(this).val('');
		}
	});
	
	$("a[rel='external']").attr({target:"_blank"});
	
	$("#photos div.photo:odd").css({"float":"right"});
	
	$("#photos div.photo img").click(function() {
     	
		var big_link = $("#photos div.photo_big img").attr("src");
     	var this_link = $(this).attr("src");
     	
     	$(this).attr({src: big_link});
     	$("#photos div.photo_big img").attr({src: this_link});
     	$("#photos div.photo_big a").attr({href: this_link});
     	
	});
	
	
	function hide_opt(low,high) {
		
		//Initial Reset
		$("select#spot_castka optgroup").each(function() {
			var str1 = $(this).attr("title");
			$(this).replaceWith("<option value=\"" + str1 + "\">" + str1 + "</option>");
		});
		
		
		//Conditional Hide (For IE the <option> tag is renamed to <optgroup>)
		$("select#spot_castka option").each(function() {
			
			var str2 = $(this).val();
			var str3 = str2 / 1000 + ' 000';
			var str4 = $(this).attr("selected");
			var str5 = "selected=\"selected\"";
			if (str4 == false) str5 = "";
			
			if ((str2 >= low) && (str2 <= high)) {
				$(this).replaceWith("<option " + str5 + " value=\"" + str2 + "\">" + str3 + "</option>");
			} else {
				$(this).replaceWith("<optgroup class=\"inactive\" title=\"" + str2 + "\" label=\"" + str3 + "\"></optgroup>");
			};
			
		});
	};
	
	
	/*
	$("select#spot_mesice").change(function() {
			
			$("#spot_mesice option:selected").each(function() {str = $(this).val();});
			
			if (str == "24") {hide_opt(20000,150000);}
			else if (str == "36") {hide_opt(20000,150000);}
			else if (str == "48") {hide_opt(20000,200000);}
			else if (str == "60") {hide_opt(35000,200000);}
			else if (str == "72") {hide_opt(80000,200000);}

	}).change();
	 */
	
	$("form .m2").hide();
	$("form .m3").hide();
	$("form .m4").hide();
	$("form .m1").show();
	
	
	$("input#typ_hypo").click(function(){  $("form .m2").hide(); $("form .m3").hide(); $("form .m4").hide(); $("form .m1").show();  })
	$("input#typ_spotr").click(function(){ $("form .m1").hide(); $("form .m3").hide(); $("form .m4").hide(); $("form .m2").show(); });
	$("input#typ_reality").click(function(){ $("form .m1").hide(); $("form .m2").hide(); $("form .m4").hide(); $("form .m3").show(); });
	$("input#typ_auta").click(function(){ $("form .m1").hide(); $("form .m2").hide(); $("form .m3").hide(); $("form .m4").show();; });
	
	
	
	
	
	
	
	
	
	
 });

