$(document).ready(function(){
	$("#choices img").each(function(){
		$(this).click(function(){
			if ($(this).attr('src') == '/images/radio-active.gif')
			    {
				$(this).attr('src', '/images/radio-inactive.gif');
				view_state(this.id, false);
			    }
			else
			    {
				$(this).attr('src', '/images/radio-active.gif');
				view_state(this.id, true);
			    }
		    });
	    });
    });

function view_state(id, state)
{
    alert(id + ': ' + state);
}

$(document).ready(function(){
  $("#choices li").each(function(){
    $(this).click(function(){
      if($(this).children("img").attr('src') == 'images/radio-active.gif'){
        $(this).children("img").attr('src', 'images/radio-inactive.gif');
        view_state(this.id, false);
      }
      else{
        $("#choices img").attr('src', 'images/radio-inactive.gif');
        $(this).children("img").attr('src', 'images/radio-active.gif');
        view_state(this.id, true);
      }
  });
  });
});

function view_state(id, state){
  //alert(id + ': ' + state);
  if(id == "houses" && state == true){    
   $(document).ready(function(){
     $("ul.objects").load("sort_obj.php?objtype=0");
     $("h1.header").html("Villor");     
   });
  }
  if(id == "houses" && state == false){
   $(document).ready(function(){
     $("ul.objects").load("sort_obj.php?objtype=");
     $("h1.header").html("Alla objekt");
   });
  }
  if(id == "holiday_house" && state == true){
   $(document).ready(function(){
     $("ul.objects").load("sort_obj.php?objtype=1-11");
     $("h1.header").html("Fritidshus");
   });
  }
  if(id == "holiday_house" && state == false){
   $(document).ready(function(){
     $("ul.objects").load("sort_obj.php?objtype=");
     $("h1.header").html("Alla objekt");
   });
  }
  if(id == "area" && state == true){
   $(document).ready(function(){
     $("ul.objects").load("sort_obj.php?objtype=4");
     $("h1.header").html("Tomter");
   });
  }
  if(id == "area" && state == false){
   $(document).ready(function(){
     $("ul.objects").load("sort_obj.php?objtype=");
     $("h1.header").html("Alla objekt");
   });
  }
}

function popit(url, height, width){
  var left = parseInt((screen.availWidth/2) - (width/2));
  var top = parseInt((screen.availHeight/2) - (height/2));
  var windowFeatures = "width=" + width + ",height=" + height + ",status,scrollbars=1,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
  window.open(url, "subWind", windowFeatures);
}
