function ul_collapse(id)
{
	var ul = document.getElementById(id);
	//alert(ul_display);
	if (ul.style.display=='none')
		ul.style.display='block';
	else
		ul.style.display='none';
}

var previmage = {
	settings: {
		lid_border: 1, // ширина рамки всплывающего слоя
		timeout: 10, // таймаут между шагами
		step: 10, // шаг
		content: "content", // id области внутри которой размечать img
		skip: "skip", // название класса для игнорируемых объектов
		max_width: 500, // максимальная ширина превьюшки
		zIndex:1000 // z-index слоя
	},
	imgs: [], // хешированный массив картинок
	lid: {}, 	// всплывающий слой
	lia: {}, 	// ссылка
	li: {}, 	// картинка
	timeout: {},
	getEl: function ( id ){ if ( document.getElementById( id ) ) return document.getElementById( id ); return false; },
	addEv: function( o, e, a ){
		if ( o.addEventListener ) o.addEventListener( e, a, false ); // was true--Opera 7b workaround!
		else if ( o.attachEvent ) o.attachEvent( "on" + e, a );
		else return null;
	},
	getPos: function ( el, sProp ) {
		// el - element // sProp - Left, Top, Right, Bottom
		var iPos = 0;
		while ( el != null ) {
			iPos += el["offset" + sProp];
			el = el.offsetParent;
		}
		return iPos;
	},
	int: function ( num ){
		num = parseInt( num );
		return ( isNaN( num ) ? 0 : num );
	},
	init: function(){
		var d = document;
		if ( !d.getElementById ) return;
		if ( !previmage.getEl( previmage.settings.content ) ) return;
		var imgs = previmage.getEl( previmage.settings.content ).getElementsByTagName('img');
		var img;
		for ( var i in imgs ){
			img = imgs[i];
			if ( img.src && img.className != 'skip' ){
				if ( img.addEventListener ){
					previmage.addEv( img, "mouseover", function(){ previmage.over( this ); } );
				} else {
					img.onmouseover = function(){ previmage.over( this ); };
				}
			}
		}
		previmage.lid = d.body.appendChild( d.createElement("div") );
		previmage.lia = previmage.lid.appendChild( d.createElement("a") );
		previmage.li = previmage.lia.appendChild( d.createElement("img") );
		if ( previmage.lid.setAttribute && previmage.lia.setAttribute && previmage.li.setAttribute ) {
			previmage.lid.setAttribute('class', 'previmage_div');
			previmage.lid.setAttribute('id', 'previmage_div');
			previmage.li.setAttribute('border', '0');
		} else {
			previmage.lid.className = 'previmage_div';
			previmage.lid.id = 'previmage_div';
			previmage.li.border = '0';
		}
		previmage.li.onmouseout = function( ){
			var imgb = this;
			var scale = Math.floor( previmage.int( imgb.oimg.height ) / previmage.int( imgb.oimg.width ) * 100 ) / 100;
			previmage.size( previmage.int( imgb.oimg.width ), 0, scale );
		}
	},
	over: function ( img ){
		var d = document;
		if ( !img || !img.src || !img.src.length ) return;
		var pathname = img.src.substr( 0, img.src.lastIndexOf(".") );
		var ext = img.src.substr( pathname.length );
		if ( !pathname.length || !ext.length ) return;

		if ( previmage.imgs[img.src] && ( typeof(previmage.imgs[img.src]) === "object" ) ) {
			previmage.s( img, previmage.imgs[img.src] );
		} else if ( previmage.imgs[img.src] !== false ) {
			previmage.imgs[img.src] = false;
			var imgb = new Image();
			imgb.osrc = img.src;
			imgb.title = img.title;
			if (typeof tooltip != "undefined") {
				imgb.tooltip = img.getAttribute('tooltip');
			}
			imgb.alt = img.alt;
			imgb.osrc = img.src;
			imgb.oimg = img;
			imgb.onload = function ( ){
				previmage.imgs[img.src] = imgb;
				previmage.s( img, imgb );
			}
			imgb.src = pathname+"b"+ext;
		}
		
	},
	s: function ( img, imgb ){
		if ( !img || !img.src || !img.src.length ) return;
		if ( !imgb || !imgb.src || !imgb.src.length ) return;
		previmage.h();

		var left = previmage.getPos( img, "Left" ) - previmage.settings.lid_border;
		var top = previmage.getPos( img, "Top" ) - previmage.settings.lid_border;
		var width = img.offsetWidth;
		var height = img.offsetHeight;
		previmage.li.oimg = img;
		previmage.li.src = imgb.src;
		previmage.lid.style.left = left+'px';
		previmage.lid.style.top = top+'px';
		previmage.lid.style.width = width+'px';
		//previmage.lid.style.height = height+'px';
		previmage.lid.style.display = 'block';
		previmage.lid.style.zIndex = previmage.settings.zIndex;
		if (typeof tooltip != "undefined") {
			previmage.li.tooltip = imgb.tooltip;
		}
		if ( previmage.li.setAttribute ) {
			previmage.li.setAttribute('title', imgb.title);
			previmage.li.setAttribute('alt', imgb.alt);
		} else {
			previmage.li.title = imgb.title;
			previmage.li.alt = imgb.alt;
		}
		if ( img.parentNode && img.parentNode.tagName.toLowerCase() == "a" ){
			if ( previmage.li.setAttribute ) {			
				previmage.lia.setAttribute( 'href', img.parentNode.href );
				previmage.lia.setAttribute( 'onclick', img.parentNode.getAttribute( 'onclick' ) );
				previmage.lia.setAttribute( 'target', img.parentNode.target );
			} else {
				previmage.lia.href = previmage.li.parentNode.href;
				previmage.lia.target = previmage.li.parentNode.target;
			}
		}
		if ( typeof tooltip != "undefined" ) {
			var tooltip_title = previmage.li.tooltip; // returns form object if IE & name="title"; then IE crashes; so...
			if ( tooltip_title && typeof tooltip_title != "string" ) tooltip_title = "";
			if ( tooltip_title ){
				previmage.li.setAttribute( "tooltip", tooltip_title );
				tooltip.l( previmage.li, "mouseover", tooltip.s );
				tooltip.l( previmage.li, "mouseout", tooltip.h );
			}
		}
		if ( previmage.timeout ) clearTimeout( previmage.timeout );
		var scale = Math.floor( imgb.width / imgb.height * 100 ) / 100;
		previmage.timeout = setTimeout( 'previmage.size(' + previmage.int( ( imgb.width <= previmage.settings.max_width ? imgb.width : previmage.settings.max_width ) ) + ', 1, ' + scale + ' )', previmage.settings.timeout );
	},
	h: function (){	
		previmage.lid.style.display = 'none';
		previmage.lid.style.left = '-1000px';
		previmage.lid.style.top = '-1000px';
		previmage.lid.style.width = '0px';
		//previmage.lid.style.height = '0px';
		if ( previmage.lia.removeAttribute ) previmage.lia.removeAttribute( 'href' ); else previmage.lia.href = '';
		if ( previmage.li.removeAttribute ) previmage.li.removeAttribute( 'src' ); else previmage.li.src = '';	
	},
	size: function ( iwidth, zoom, scale ){
		var step = previmage.settings.step;
		//var step = Math.floor( ( this.int(iwidth) - this.int(lid.style.width) ) / 10 );
		scale = ( scale > 0 ? scale : 1 );
		if ( zoom ){
			if ( previmage.int( iwidth ) > 0 && previmage.int( previmage.lid.style.width ) + step >= previmage.int( iwidth ) ) step = previmage.int( iwidth ) - previmage.int( previmage.lid.style.width );
			if ( step < 1 ) {
				return;
			}
			var left = previmage.int( previmage.lid.style.left ) - Math.floor( step / 2 );
			var top = previmage.int( previmage.lid.style.top ) - Math.floor( step / scale / 2 );
			var width = previmage.int( previmage.lid.style.width ) + step;
			//var height = previmage.int( previmage.lid.style.height ) + step;
		} else {
			if ( previmage.int( iwidth ) > 0 && previmage.int( previmage.lid.style.width ) - step <= previmage.int( iwidth ) ) step = previmage.int( previmage.lid.style.width ) - previmage.int( iwidth );
			if ( step < 1 ) {
				previmage.h();
				return;
			}
			var left = previmage.int( previmage.lid.style.left ) + Math.floor( step / 2 );
			var top = previmage.int( previmage.lid.style.top ) + Math.floor( step * scale / 2 );
			var width = previmage.int( previmage.lid.style.width ) - step;
			//var height = previmage.int( previmage.lid.style.height ) - step;
		}
		if ( left < 1 && top < 1 ) return;
		previmage.lid.style.left = left + 'px';
		previmage.lid.style.top = top + 'px';
		previmage.lid.style.width = width + 'px';
		//previmage.lid.style.height = height + 'px';
		previmage.lid.style.display = 'block';
		previmage.lid.style.zIndex = previmage.settings.zIndex;
		
		if ( previmage.timeout ) clearTimeout( previmage.timeout );
		previmage.timeout = setTimeout( 'previmage.size(' + previmage.int( iwidth ) + ', ' + zoom + ', ' + scale + ' )', previmage.settings.timeout );
	}
}


/* is dom load ? */


/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)>");
document.write("<\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
        init();
    }
};
/*@end @*/

if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
            delete _timer;
            init(); // call the onload handler
        }
    }, 10);
}
window.onload = init;

hotel_card = false;
function init() {
	// выход из функции, если она уже вызывалась
	if (arguments.callee.done) return;
	// флаг, чтобы не запускать функцию дважды
	arguments.callee.done = true;
	// далее пишите скрипт

	previmage.init();

}