function openw( url, name, width, height ) {
  
  if ( height < 100 ) height = 100; if ( width < 100 ) height = 100;
  var top = screen.availHeight / 2 - height / 2;
  var left = screen.availWidth / 2 - width / 2;
  var w = window.open( url, name,
    'resizable=no,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no' +
    ',top='+top+',left='+left+',height='+height+',width='+width );
  w.focus();
  return true;
}

isFrmld = true;
isFLoad = false;

load_timer = 0;

isMainPage = false;

function block(param){   
   isFrmld=false;
   isFLoad=false;   
   block_ext(param);
}

function unblock(param){
   isFrmld=true;
   load_timer = 0;
   unblock_ext(param);
}

function block_ext(){
}
   
function unblock_ext(){
}


function check_iframe(time){
	load_timer += time;
	if(load_timer > 15000){
		window.location.reload(true);
	}
}
function add_to_compare(room_id){	
   if(isFrmld){	
      form = document.frames("c_frame").document.forms("c_form");
      form.object_id.value = room_id;
      form.action.value    = "add_compare";
      form.submit();
      block_ext = vitrina_compare_block_handler;
      unblock_ext = vitrina_compare_unblock_handler;
      unblock();
   } else {
		setTimeout("add_to_compare("+room_id+")", 50);
		check_iframe(50);
	}      
}

function hideMessage(){
   with(document.all.mess){
      innerHTML =  "";
      style.visibility = "hidden";
      style.color = "black";
   }
}

function createMessage(text, color, time_to_show){
	
		ie = (document.all)? true : false;
		
		w = window.innerWidth;
		h = Math.round(window.innerHeight/2-100)+window.pageYOffset;
		
		if (ie) {
			w = document.body.offsetWidth;
			h = Math.round(document.body.offsetHeight/2-100)+document.body.scrollTop;
		}

   with(document.all.mess){
      document.all.mess.style.visibility = "visible";
      document.all.mess.innerHTML        = text;
      document.all.mess.style.color      = color;
	  document.all.mess.style.top  		 = h;	  
   }
   if(time_to_show > 0)
      setTimeout("hideMessage()", time_to_show);
}

/*-----------------РАСШИРЕНИЕ ОБРАБОТКИ ОТВЕТА СЕРВЕРА::СРАВНЕНИЕ------------------------*/
  /*разблокировака фрейма*/
  function vitrina_compare_unblock_handler(){
    if(!isFLoad){  	
      var d = document;
      var comp_kolvo = parseInt(d.frames("c_frame").document.forms("c_form").num_param.value);      
      /*обрабатываем ответ сервера по поводу результата действия*/
      var errCode = parseInt(d.frames("c_frame").document.forms("c_form").resop.value);
      switch(errCode){
        case 1:{
          createMessage("Номер добавлен в папку сравнения!<br> Номеров в сравнении: <span style='color:red'>" + comp_kolvo + "</span>", "#4f4f4f", 4000);
          break;
        }
        case 0:{
          createMessage("Номер уже есть в папке сравнения!", "#4f4f4f", 2000);
          break;
        }
      }
    }
  }
  function vitrina_compare_block_handler(){    
    createMessage("Минуточку...", "#4f4f4f",2000);
  }  
