function fixPNG(element)
{
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;
	
    if (element.tagName=='IMG')
    {
      if (/\.png$/.test(element.src))
      {
        src = element.src;
        element.src = path+"/images/blank.gif";
      }
    }
    else
    {
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1];
        element.runtimeStyle.backgroundImage="none";
      }
    }
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
  }
}
function openw(res,title) {
   rand=Math.random().toString().substring(2,15);
   window.open(path + "/lib/show_pic.php?src="+res+"&title="+title, 'new_'+rand, "top=50, left=50, width=640, height=480, channelmode=no, toolbar=no, location=no, status=no, directories=no, menubar=no, resizable=yes, scroll=yes");
}
function open_pic(res,title) {
   rand=Math.random().toString().substring(2,15);
   window.open(path + "/lib/show_pic.php?src="+res+"&title="+title, 'new_'+rand, "top=50, left=50, width=640, height=480, channelmode=no, toolbar=no, location=no, status=no, directories=no, menubar=no, resizable=yes, scrollbars=yes");
}
function get_floor(id,cur) {
   var req = new JsHttpRequest();
   req.onreadystatechange = function() 
   {
      if (req.readyState == 4) {
      	  document.getElementById('search_floor').innerHTML = req.responseText;
      }
   }
   req.open(null, path+'/get_floor.html', true);
   req.send( { id: id, cur: cur } );
}
function get_apartment(id, cur) {
   var req = new JsHttpRequest();
   req.onreadystatechange = function() 
   {
      if (req.readyState == 4) {
      	  document.getElementById('search_apartment').innerHTML = req.responseText;
      }
   }
   req.open(null, path+'/get_apartment.html', true);
   req.send( { id: id, cur: cur } );
}
function go_apartment()
{
	id_ap = document.getElementById("apartment").value;
	if (id_ap > 0)
	{
	   id_korpus = document.getElementById("korpus").value;
	   id_floor = document.getElementById("floor").value;
	   location.href=path+'/apartments/'+id_korpus+'/'+id_floor+'/'+id_ap+'.html';
	}
	else
	{
		alert("Вы должны выбрать апартаменты!");
	}
}
function get_floor_plan(ob,id,pid) {
   var obs = document.getElementsByName('a_floor');
   for (var i=0;i<obs.length;i++)
   {
   	   obs[i].className = 'floor_title';
   }
   document.getElementById('floor_plan_all').className = 'floor_title';
   ob.className = 'floor_title_on';
   
   var req = new JsHttpRequest();
   req.onreadystatechange = function() 
   {
      if (req.readyState == 4) {
      	  document.getElementById('floor_plan').innerHTML = req.responseText;
      }
   }
   req.open(null, path+'/get_floor_plan.html', true);
   req.send( { id: id, pid: pid } );
}
function get_floor_plan_all(ob) {
   var obs = document.getElementsByName('a_floor');
   for (var i=0;i<obs.length;i++)
   {
   	   obs[i].className = 'floor_title';
   }
   ob.className = 'floor_title_on';
   document.getElementById('floor_plan').innerHTML = document.getElementById('floor_plan_all').innerHTML;
}