$(document).ready(function() {

	url = window.location.href;
	
	height_content = $("#content").height();
	if(height_content < 386){
		 $("#content").css("height",386);
	}
	
	$(".checkbox_search").click(function() {
  		$(".checkbox_search").each(function(index) {
    		$(this).attr('checked', false);
  		});
	});

	url = window.location.href;
	url_without_param = url.split('?');
	url_without_param = url_without_param[0];
	if(url_without_param == "http://www.gratisa.ch/resultat-recherche/"){
		var reg_price = new RegExp('(\\?|&|^)price=(.*?)(&|$)');
		matches = url.match(reg_price);
		if(matches != null){
			price = getParamValue("price",url);	
			price_tab = price.split(',');
			for(var x in price_tab){	
  				$("#price_"+price_tab[x]).attr('checked', 'true');
			}
		}
		var reg_object = new RegExp('(\\?|&|^)object=(.*?)(&|$)');
		matches = url.match(reg_object);
		if(matches != null){
			object = getParamValue("object",url);
			object_tab = object.split(',');
			for(var x in object_tab){	
  				$("#object_"+object_tab[x]).attr('checked', true);
			}
		}	
	}

	
	$(".caract table tr").each(function(i){
   		$(this).children('td').eq(0).css("width", 316);
   		$(this).children('td').eq(1).css("width", 30);
   		$(this).children('td').eq(1).css("text-align", "right");
 	});
	
	height_object_txt = $("#object_txt").height();
	if(height_object_txt < 346){
		$("#object_txt").height(346);
	}
		 
 	$('form#fourthExample select').styledSelect();
     
    $('.anythingSlider').anythingSlider({
        easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 	// This turns off the entire FUNCTIONALY, not just if it starts running or not
        startStopped: false,          	// If autoPlay is on, this can force it to start stopped
        delay: 5000,                    	// How long between slide transitions in AutoPlay mode
        animationTime: 1000,       	// How long the slide transition takes
        hashTags: true,                 	// Should links change the hashtag in the URL?
        buildNavigation: false,      	// If true, builds and list of anchor links to link to each slide
        pauseOnHover: false,         	// If true, and autoPlay is enabled, the show will pause on hover
        startText: "",             			// Start text
        stopText: "",              	 	// Stop text
        navigationFormatter: null  	// Details at the top of the file on this use (advanced use)
	});
	
	$('.anythingSlider').corner("cc:#434345 10px");
	$('#home_construction').corner("cc:#434345 10px");
	$('#home_sell').corner("cc:#434345 10px");
	$('#sidebar').corner("cc:#434345 10px");
	$('#search_sell').corner("cc:#434345 10px");
	$('.house_block').corner("cc:#434345 10px");
	$('.house_block_without_margin').corner("cc:#434345 10px");
	$('#object_txt').corner("cc:#434345 10px");
	$('#object_gallery').corner("cc:#434345 10px");
	$('#object_informations').corner("cc:#434345 10px");
	$('#send_search').corner("cc:#E3E4E4 10px");

	setTimeout(function(){
		$("div#object_gallery").slideView(); 
	}, 500)
	
	$(document).pngFix();
	
	price = getParamValue("price", url);
	object = getParamValue("object", url);
	
	if(price == 0){
		$("#check_"+object).attr('checked', true);
	}else{
		$("#check_"+object+"_"+price).attr('checked', true);
	}
});

function getParamValue(param,url)
{
	var u = url == undefined ? document.location.href : url;
	var reg = new RegExp('(\\?|&|^)'+param+'=(.*?)(&|$)');
	matches = u.match(reg);
	return matches[2] != undefined ? decodeURIComponent(matches[2]).replace(/\+/g,' ') : '';
}

