function defined(x){
	return typeof(x) != 'undefined' && x != null;
}

function ntpHotel(id) {
	img = document.getElementById('nti'+id);
	rldr = document.getElementById('ntr'+id);
	
	if (img.attributes['chk'].value==1) {
		rldr.src = '/user/notepad/hotel/json?al='+id+'&chk='+0+'&rnd='+Math.random();
		img.attributes['chk'].value = 0;		
		img.src = '/i/chf.gif';
	} else {
		rldr.src = '/user/notepad/hotel/json?al='+id+'&chk='+1+'&rnd='+Math.random();
		img.attributes['chk'].value = 1;		
		img.src = '/i/cht.gif';
	}	
}


function ShowWin(url,x,y,name,isscrollbars) {
	cx=screen.width / 2 - (x / 2);
	cy=(screen.height/2-(y/2));
    
    isscrollbars=(isscrollbars=="no")?"no":"yes";
	window.open(url,name,"toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);
}

function ntpOffer(id) {
	img = document.getElementById('nti'+id);
	rldr = document.getElementById('ntr'+id);
	
	if (img.attributes['chk'].value==1) {
		rldr.src = '/user/notepad/offer/json?oid='+id+'&chk='+0+'&rnd='+Math.random();
		img.attributes['chk'].value = 0;		
		img.src = '/i/chf.gif';
	} else {
		rldr.src = '/user/notepad/offer/json?oid='+id+'&chk='+1+'&rnd='+Math.random();
		img.attributes['chk'].value = 1;		
		img.src = '/i/cht.gif';
	}	
}


function ShowPropWin(url,x,y) {
	x = Math.round(screen.width*(x/100));
	y = Math.round(screen.height*(y/100));
	var cx = (screen.width/2 - (x/2));
	var cy = (screen.height/2-(y/2));    
    var isscrollbars="yes";
    
	window.open(url,"","toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);
}




// Создание контейнера для подгрузки изображения
function loadPhoto(imgSrc){
  photo1= new Image();
  photo1.src=imgSrc;
  Control(imgSrc);
}
// Контроль предварительной загрузки изображения
function Control(imgSrc){
  if((photo1.width!=0)&&(photo1.height!=0)){
    viewFoto(imgSrc);
  }
  else{
    tmpInterval=setTimeout("Control('"+imgSrc+"');",20);
  }
}

// Вывод изображения
function viewFoto(imgSrc){
	w=photo1.width;
	h=photo1.height;
	tmpString="top="+((screen.height-h)/2)+",left="+((screen.width-w)/2)+",height="+h+",width="+w+",toolbar=no,scrollbars=no,directories=no,status=no,menubar=no,resizable=yes";
	fin = window.open("","photo",tmpString);
	fin.document.open();
	fin.document.write("<html><head><title>Фотогалерея</title></head><body style=\'margin:0;padding:0\'>"+
	"<a href=\'javascript: window.close();\'><img src=\'"+imgSrc+"\' border=0 alt=\'Кликните, чтобы закрыть\' title=\'Кликните, чтобы закрыть\'></a></body></html>");
	fin.document.close();
	fin.focus();
}

function addListener(element, event, func){
	if(element.attachEvent)
		element.attachEvent('on' + event, function(){ func(window.event) });
	else if(element.addEventListener)
		element.addEventListener(event, func, false);
}