
$(document).ready(function() {

	$(".tab_box span a").click(function() {
		var this_box = $(this).parents(".tab_box");
		
		var href = $(this).attr('href').replace('?', '');
		var tab = this;
		
		if(!$(tab).hasClass('active')) {
			$(this_box).find(" > span > a").removeClass('active');
			
			$(this_box).find(" > div").each(function() {
				if("#"+this.id == href) {
					$(this).fadeIn('slow');
					$(tab).addClass('active');
				} else {
					$(this).hide();
				}
			});
		}
		
		//return false;
	});
	
	$('#default_search_btn').click(function() {
		var $form = $('#realestate_search_form');
		
		$form.find('label[for=price_from]').html('Verð ');
		
		$form.find('input[name=rent]').val('');
		
		$form.find('.hide_for_rent').show();
		
		$form.find('.hide_for_default').hide();
		$form.find('.hide_for_default input[type=text]').val('');
		$form.find('.hide_for_default input[type=checkbox]').check('off');
		
		var preset = $('#form_presets .default_price_options').html();
		$form.find('#price_from, #price_to').html(preset);
	});
	
	$('#rent_search_btn').click(function() {
		var $form = $('#realestate_search_form');
		
		$form.find('label[for=price_from]').html('Leiga ');
		
		$form.find('input[name=rent]').val('true');
		
		$form.find('.hide_for_rent').hide();
		$form.find('.hide_for_rent input[type=text]').val('');
		$form.find('.hide_for_rent input[type=checkbox]').check('off');
		
		$form.find('.hide_for_default').show();
		
		var preset = $('#form_presets .rent_price_options').html();
		$form.find('#price_from, #price_to').html(preset);
	});
	
	
	$(".tab_box > span a[href="+window.location.hash+"]").click();
	
	
	$('.tab_eign > .tab_eyda > a').click(function() {		
		$.get($(this).attr('href'));
		
		//$(this).parent().parent().css('background-color', 'red');
		//$(this).parent().parent().css('color', 'red');
		$(this).parent().parent().fadeOut();
		
		return false;
	});
	
	$('tr > td.tab_eyda > a').click(function() {		
		$.get($(this).attr('href'));
		
		//$(this).parent().parent().css('color', 'red');
		$(this).parent().parent().fadeOut();
		
		return false;
	});
});











