	//PNG24 

function setPNG24(obj) {
  obj.width=obj.height=1;
  obj.className=obj.className.replace(/\bPNG24\b/i,'');
  obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src+"',sizingMethod='image');"
  obj.src='';
  return '';
}


    
    function createCookie(name,value,days) {
	    if (days) {
		    var date = new Date();
		    date.setTime(date.getTime()+(days*24*60*60*1000));
		    var expires = "; expires="+date.toGMTString();
	    }
	    else var expires = "";
	    document.cookie = name+"="+value+expires+"; path=/";
    }

function addToSelection(o,id) {
    $("#selectionBox").fadeOut("slow");
    $("#selectionBox").load("/apartment/selectionAdd?id="+id, function(){
      $("#selectionBox").fadeIn("slow");});
    $("#selectionButtons"+id).html("<button class='appart_button removeSelection' onclick='removeFromSelection(this, "+parseFloat(id)+")'>Remove from my selection</button>");
}

function removeFromSelection(o,id) {
    $("#selectionBox").fadeOut("slow");
    $("#selectionBox").load("/apartment/selectionRemove?id="+id, function(){
      $("#selectionBox").fadeIn("slow");});
    $("#selectionButtons"+id).html("<button class='appart_button addSelection'  onclick='addToSelection(this, "+parseFloat(id)+")'>Add to my selection</button>");
}

$(document).ready(function() {
  (function(){for(var l=document.links,h=window.location.hostname,i=0,a;a=l[i];i++){if(a.hostname!=h){a.target='_blank';}}})();
   $("a.thumbnail").mouseover(function() {
     $("#appart_thumb img").attr("src", $(this).attr("href").replace("w=611", "w=258"));
   });
   $("a.thumbnail").lightBox({fixedNavigation:true});
   $('table.infos tr:odd').addClass('odd');
   $('table.infos tr:even').addClass('even');
   setTimeout("removeFlashMessages()", 8000);

  $("#contact-form").submit(function(){
    var r=true;
    if(!$("#email").attr("value")&&r) {
      r=false;
      alert("The email is required.");
    }
    return r;
  });
  
  $("#practicalinfos h2").click(function(){
	$("#rightColumn").html($("#"+$(this).attr("id")+"-content").html());
	$(".anchors").removeClass("selected");
	$("#anchor-"+$(this).attr("id")).addClass("selected");
	$("#practicalinfos h2").removeClass("selected");
	$(this).addClass("selected");
//	$("#"+$(this).attr("id")+"-content").toggle("slow");
  });
  $(".owner-subnav .anchors").click(function(){
	  setTimeout("ownerSetContent()", 500);
  });
  ownerSetContent();
});

function removeFlashMessages() { $(".fadeout").hide("slow");}

function ownerSetContent() {
	  var url = document.location.toString();
	  if (url.match('#')) {
	    var myAnchor = url.split('#')[1];
	    $('#article-' + myAnchor).click();
	  }
}

function showOwnerVisite(url,o) {
  $("#rightColumnExtras").load(url);
  $("#owner-visites a").removeClass("selected");
  $("#owner-incidents a").removeClass("selected");
  o.addClass("selected");
}

function showOwnerIncident(url,o) {
  $("#rightColumnExtras").load(url);
  $("#owner-visites a").removeClass("selected");
  $("#owner-incidents a").removeClass("selected");
  o.addClass("selected");
}

function proSelectDossier(apt) {
  $("#select-window").html("");
  var btn = $("#btn-select-apt-"+apt);
  var offset = btn.offset();
  $("#select-window").show();
  $("#select-window").css("left", offset.left+btn.width());
  $("#select-window").css("top", offset.top);
  $("#select-window").addClass("selectDossier")
  $("#select-window").html("<iframe width='100%' height='200' src='/pro/dossieradd/apartment/"+apt+"'></iframe>");
  $("#select-window").click(function(){$(this).hide()});
}

function proSelectWindowLoad(url) {
  $("#select-window").load(url);
  return false;
}

