jQuery(document).ready(function () {
						   
	jQuery("#btnShowAllData").toggle(function () {

		jQuery(this).addClass("none");
		jQuery("#table-all-data").show();
										 
	}, function () {
		
		jQuery(this).removeClass("none");
		jQuery("#table-all-data").hide();
		
	});
	
	jQuery(".open-popup").click( function () {
										   
		window.open(jQuery(this).attr("href"), 'rules', 'width=600,height=500');
		
		return false;
										   
	});
	
	jQuery("#commentForm").submit( function () {
										
		
		//return false;
										
	});
	
	jQuery("#changeCity").change(function () {

		document.location = jQuery("#changeCityHref").val() + jQuery(this).val();
									  
	});

	jQuery("#changeType").change(function () {

		/*if (document.getElementById('changeType').selectedIndex == 0) 
			document.location = jQuery("#aLinkAll").attr("href");
		else { */
			var link_to_cat = jQuery("#changeTypeHref").val();
			link_to_cat = link_to_cat.replace('%%%', jQuery(this).val());

			document.location = link_to_cat;
//		}
		
		return false;

	});
	
	jQuery("#aMoreComments").toggle( function () {

		jQuery("#comments_box LI.hide").addClass("block");

		jQuery(this).html("Mažiau...");
											   
	}, function () {
		
		jQuery("#comments_box LI.block").removeClass("block");
		
		jQuery(this).html("Daugiau...");		
		
	});

	jQuery("#aMorePopular").toggle( function () {
											  
		jQuery("#week_popular LI.hide").addClass("block");

		jQuery(this).html("Mažiau...");
											  
	}, function () {
	
		jQuery("#week_popular LI.block").removeClass("block");
		
		jQuery(this).html("Daugiau...");		
		
	});
	
	jQuery("#foto_gallery a").click( function () {
											   
		var img = new Image();
		
		jQuery(img).load( function () {
									
			jQuery("#photo_cont").css( { height: jQuery("#photo_cont").height(),
										 width: jQuery("#photo_cont").width() });
			
			if (img_h < jQuery("#photo_cont").height()) img_h = jQuery("#photo_cont").height();
			
			jQuery("#photo_cont").animate( { width: img_w, height: img_h }, 400, function () {
																						   
				jQuery("#photo_cont img").before("<img src=\"\" alt=\"\" style=\"position: absolute; display: none\" />");
	
				jQuery("#photo_cont img:first").attr('src', img.src);
				
				jQuery("#photo_cont img:first").fadeIn("fast", function () {
																			

																			
																			});				
				
				jQuery("#photo_cont img:last").remove();

			});
									
		});

		var imgsize = String(jQuery(this).attr('img')).split('-');
		imgsize = imgsize[imgsize.length - 1];
		
		imgsize = imgsize.split('.', 1);
		imgsize = imgsize[0];
		
		imgsize = imgsize.split('x');
		
		var img_w = imgsize[0];
		var img_h = imgsize[1];		
		
		var guid_base = jQuery("#images_dir").val();

		img.src = guid_base + jQuery(this).attr('img');
		
		
	});
	
	jQuery(".iconClick").click( function () {
										  
		jQuery(this).next().click();
										  
	});
	
	jQuery(".house_box_tight").click( function () {

		if (typeof event != "undefined") {

			var target = jQuery(event.target); 
			var href = jQuery(target).attr("href");
		
			if (href != undefined) return true;
			
		} else {
			
			if (jQuery(this).attr("href") != undefined) return true;
			
		}
		
		document.location = jQuery(this).children("A").attr("href");
												
	});
	
	
	jQuery(".house_box_tight").hover( function () {

		window.status = jQuery(this).children("A").attr("href");
												
	}, function () { window.status = ''; } );	
	
	
});

function showMiestai() {
	
	jQuery("#city").hide();
	jQuery("#selectCity").show()
	
	return false;
	
}

function hideMiestai() {
	
	jQuery("#selectCity").hide()
	jQuery("#city").show();	
	
	return false;
	
}

function showTipai() {
	
	jQuery("#type").hide();
	jQuery("#selectType").show()
	
	return false;
	
}

function hideTipai() {
	
	jQuery("#selectType").hide()
	jQuery("#type").show();	
	
	return false;
	
}

