/*
 *	(c) TURY.ru
 */
if ( true/*self.trr_common_included == null*/ ) {
self.trr_common_included = true;

var trr_included_modules = new Array ();

function trr_Included ( module_name ) {
	return	false;//trr_included_modules [module_name] != null;
}

function trr_RegisterInclusion ( module_name ) {
	trr_included_modules [module_name] = true;
}

/*
 *  Standard objects extension
 */
String.prototype.trim = function () {
	return	this.replace ( /^\s+|\s+$/g, '' );
}

Object.concat = function ( obj1, obj2 ) {
	var obj = new Object ();
	
	for ( var key in obj1 )
		obj [key] = obj1 [key];
	
	for ( var key in obj2 )
		obj [key] = obj2 [key];
	
	return	obj;
}

Object.search = function ( obj, val ) {
	for ( var key in obj )
		if ( obj [key] == val )
			return	key;
	
	return	-1;
}

Object.duplicate = function ( obj ) {
	var new_obj = new Object ();
	
	for ( var key in obj )
		new_obj [key] = obj [key];
	
	return	new_obj;
}

Object.extend = function ( dst, src ) {
	for ( var key in src )
		if ( dst [key] == undefined )
			dst [key] = src [key];
	
	return	dst;
}

Array.search = function ( arr, val ) {
	for ( var key in arr )
		if ( arr [key] == val )
			return	key;
	
	return	-1;
}

Array.duplicate = function ( arr ) {
	var new_arr = new Array ();
	
	for ( var key in arr )
		new_arr [key] = arr [key];
	
	return	new_arr;
}

/*
 *  static class trr_Common {
 */
function trr_Common () {}

trr_Common.Browser = {
	IE           : !!( window.attachEvent && !window.opera ),
	Opera        : !!window.opera,
	WebKit       : navigator.userAgent.indexOf ( 'AppleWebKit/' ) > -1,
	Gecko        : navigator.userAgent.indexOf ( 'Gecko' ) > -1 && navigator.userAgent.indexOf ( 'KHTML' ) == -1,
	MobileSafari : !!navigator.userAgent.match ( /Apple.*Mobile.*Safari/ )
};

trr_Common.unsetImageSizes = function ( root_node ) {
	if ( root_node ) {
		for ( i = 0 ; i < root_node.childNodes.length ; i++ ) {
			var node = root_node.childNodes [i];
			
			if ( node.tagName == 'IMG' ) {
				node.__orig = new Object ();
				node.__orig.width  = node.style.width;
				node.__orig.height = node.style.height;
				node.style.width  = '';
				node.style.height = '';
			} else if ( typeof ( node.tagName ) == 'string' ) {
				trr_Common.unsetSizes ( node );
			}
		}
	}
}

trr_Common.restoreImageSizes = function ( root_node ) {
	if ( root_node ) {
		for ( i = 0 ; i < root_node.childNodes.length ; i++ ) {
			var node = root_node.childNodes [i];
			
			if ( node.tagName == 'IMG' && typeof ( node.__orig ) == 'object' ) {
				node.style.width  = node.__orig.width;
				node.style.height = node.__orig.height;
			} else if ( typeof ( node.tagName ) == 'string' ) {
				trr_Common.restoreSizes ( node );
			}
		}
	}
}

trr_Common.getElementOffsetXY = function ( elt, offset_point ) {
	if ( elt ) {
		offset_point [0] += elt.offsetLeft;
		offset_point [1] += elt.offsetTop;
		
		trr_Common.getElementOffsetXY ( elt.offsetParent, offset_point );
	}
}

trr_Common.sortNumberComparer = function ( a, b ) {
	return	a - b;
}

trr_Common.getPageSize = function () {
	var xScroll, yScroll;
	
	if ( window.innerHeight && window.scrollMaxY ) {	
		xScroll = window.innerWidth  + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if ( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {																// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if ( self.innerHeight ) {	// all except Explorer
		if ( document.documentElement.clientWidth )
			windowWidth = document.documentElement.clientWidth; 
		else
			windowWidth = self.innerWidth;
		
		windowHeight = self.innerHeight;
	} else if ( document.documentElement && document.documentElement.clientHeight ) { // Explorer 6 Strict Mode
		windowWidth  = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if ( document.body ) {													  // other Explorers
		windowWidth  = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	// for small pages with total height less then height of the viewport
	if ( yScroll < windowHeight )
		pageHeight = windowHeight;
	else
		pageHeight = yScroll;
	
	// for small pages with total width less then width of the viewport
	if ( xScroll < windowWidth )
		pageWidth = xScroll;
	else
		pageWidth = windowWidth;
	
	return [pageWidth,pageHeight];
}

trr_Common.getScrollOffsets = function () {
	return	[window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
			 window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop];
}

trr_Common.getViewportDimensions = function () {
	var width  = document.body.clientWidth  ? document.body.clientWidth  : ( self.innerWidth  ? self.innerWidth  : document.documentElement.clientWidth  );
	var height = document.body.clientHeight ? document.body.clientHeight : ( self.innerHeight ? self.innerHeight : document.documentElement.clientHeight );
	
	return	[width, height];
}
/*
 * } // end of class trr_Common
 */
}
if ( !trr_Included ( 'trr_url_utf8' ) ) {
	trr_RegisterInclusion ( 'trr_url_utf8' );
/*
 *  static class trr_UrlUtf8 {
 */
function trr_UrlUtf8 () {}

trr_UrlUtf8.UrlEncode = function ( string ) {
	var utftext = '';
	
	string = string.replace ( /\r\n/g, "\n" );
	
	for ( var n = 0 ; n < string.length ; n++ ) {
		var c = string.charCodeAt ( n );
		
		if ( c < 128 ) {
			utftext += String.fromCharCode ( c );
		} else if ( ( c > 127 ) && ( c < 2048 ) ) {
			utftext += String.fromCharCode ( ( c >> 6 ) | 192 );
			utftext += String.fromCharCode ( ( c & 63 ) | 128 );
		} else {
			utftext += String.fromCharCode ( (   c >> 12 ) | 224 );
			utftext += String.fromCharCode ( ( ( c >>  6 ) & 63  ) | 128 );
			utftext += String.fromCharCode ( (   c  & 63 ) | 128 );
		}
	}
	
	return	escape ( utftext );
}

trr_UrlUtf8.UrlDecode = function ( utftext ) {
	var string = '';
	var i = 0;
	var c = c1 = c2 = 0;
	
	utftext = unescape ( utftext );
	
	while ( i < utftext.length ) {
		c = utftext.charCodeAt ( i );
		
		if ( c < 128 ) {
			string += String.fromCharCode ( c );
			i++;
		} else if ( ( c > 191 ) && ( c < 224 ) ) {
			c2 = utftext.charCodeAt ( i + 1 );
			string += String.fromCharCode ( ( ( c & 31 ) << 6 ) | ( c2 & 63 ) );
			i += 2;
		} else {
			c2 = utftext.charCodeAt ( i + 1 );
			c3 = utftext.charCodeAt ( i + 2 );
			string += String.fromCharCode ( ( ( c & 15 ) << 12 ) | ( ( c2 & 63 ) << 6 ) | ( c3 & 63 ) );
			i += 3;
		}
	}
	
	return	string;
}
/*
 * } // end of class trr_UrlUtf8
 */
}
if ( !trr_Included ( 'trr_url' ) ) {
	trr_RegisterInclusion ( 'trr_url' );
/*
 *  static class trr_Url {
 */
function trr_Url () {}

/*const*/
trr_Url.TRR_ARGUMENT_PREFIX    = '_';
trr_Url.TRR_ARGUMENT_SEPARATOR = '&';

trr_Url.UrlEncode = trr_UrlUtf8.UrlEncode;
trr_Url.UrlDecode = trr_UrlUtf8.UrlDecode;

trr_Url.ParseUrl = function ( url ) {
	var res = url.match ( /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/ );
	
	var info = { 'scheme'    : res [2],
				 'authority' : res [4],
				 'path'      : res [5],
				 'query'     : res [7],
				 'fragment'  : res [9] };
	
	return	info;
}

trr_Url.BuildUrl = function ( scheme, authority, path, query, fragment ) {
	var url = '';
	
	if ( scheme    ) url += scheme + '://';
	if ( authority ) url += authority;
	if ( path      ) url += path;
	if ( query     ) url += '?' + query;
	if ( fragment  ) url += '#' + fragment;
	
	return	url;
}

trr_Url.HttpBuildQuery = function ( data, prefix, sep, key ) {
	prefix = prefix != null ? prefix : trr_Url.TRR_ARGUMENT_PREFIX;
	sep    = sep    != null ? sep    : trr_Url.TRR_ARGUMENT_SEPARATOR;
	key    = key    != null ? key    : null;
	
	var ret = new Array ();
	
	for ( var k in data ) {
		var v = data [k];
		var k_is_numeric = k == parseInt ( k );
		
		k = trr_Url.UrlEncode ( '' + k );
		
		if ( prefix != null && k_is_numeric )
			k = prefix + k;
		
		if ( key != null )
			k = key + '[' + k + ']';
		
		if ( typeof ( v ) == 'object' ) {
			var nested_url = trr_Url.HttpBuildQuery ( v, '', sep, k );
			
			if ( nested_url.length > 0 )
				ret.push ( trr_Url.HttpBuildQuery ( v, '', sep, k ) );
		} else {
			ret.push ( k + '=' + trr_Url.UrlEncode ( '' + v ) );
		}
	}
	
	return	ret.join ( sep );
}

trr_Url.HttpParseQuery = function ( query, sep ) {
	sep = sep != null ? sep : trr_Url.TRR_ARGUMENT_SEPARATOR;
	
	var res   = new Array ();
	var pairs = query.split ( sep );
	
	for ( var pair_key in pairs ) {
		var pair = pairs [pair_key];
		
		if ( pair.length == 0 )
			continue;
		
		var eq_pos, first_brace_pos;
		var arg, val;
		
		if ( -1 == ( eq_pos = pair.indexOf ( '=' ) ) ) {
			arg = pair;
			val = '';
		} else {
			arg = pair.substring ( 0, eq_pos );
			val = trr_Url.UrlDecode ( pair.substring ( eq_pos + 1 ) );
		}
		
		if ( ( -1 != ( first_brace_pos = arg.indexOf ( '[' ) ) ) &&
			 ( -1 != arg.indexOf ( ']' ) ) ) {
			var matches;
			
			if ( null != ( matches = arg.match ( /\[([^#\]]*)\]/gi ) ) ) {
				var path = '';
				var isset, len;
				
				arg = arg.substring ( 0, first_brace_pos );
				eval ( 'isset = res ["' + arg + '"]' + ' != undefined;' );
				
				if ( !isset )
					eval ( 'res ["' + arg + '"]' + ' = new Array ();' );
				
				for ( var key_key in matches ) {
					var key = matches [key_key];
					key = key.substring ( 1, key.length - 1 );
					
					if ( ( key.trim ().length ) == 0 ) {
						eval ( 'len = res ["' + arg + '"]' + path + '.length;' );
						path += '[' + len + ']';
					} else if ( parseInt ( key ) == key ) {
						path += '[' + key + ']';
					} else {
						path += '["' + key + '"]';
					}
					
					eval ( 'isset = res ["' + arg + '"]' + path + ' != undefined;' );
					
					if ( !isset )
						eval ( 'res ["' + arg + '"]' + path + ' = new Array ();' );
				}
				
				val = val.replace ( "'", "\\'" );
				eval ( 'res ["' + arg + '"]' + path + " = '" + val + "';" );
			}
		} else {
			res [arg] = val;
		}
	}
	
	return	res;
}
/*
 * } // end of class trr_Url
 */
}
if ( !trr_Included ( 'trr_ajax_client' ) ) {
	trr_RegisterInclusion ( 'trr_ajax_client' );
/*
 *  static class trr_AjaxClient {
 */
function trr_AjaxClient () {}

trr_AjaxClient.SendGetRequest = function ( uri, async, callback, async_data ) {
	if ( async )
		return	trr_AjaxClient._sendRequest ( uri, 'GET', null, async, callback, async_data );
	else
		return	trr_AjaxClient._sendRequest ( uri, 'GET', null, async, callback );
}

trr_AjaxClient.SendPostRequest = function ( uri, params, async, callback, async_data ) {
	if ( async )
		return	trr_AjaxClient._sendRequest ( uri, 'POST', params, async, callback, async_data );
	else
		return	trr_AjaxClient._sendRequest ( uri, 'POST', params, async, callback );
}

/*private*/
trr_AjaxClient._sendRequest = function ( uri, method, params, async, callback, async_data ) {
	var xmlHttp = trr_AjaxClient._getXmlHttp ();
	xmlHttp.open ( method, uri, async );
	
	if ( async ) {
		xmlHttp.onreadystatechange = function () {
			if ( xmlHttp.readyState == 4 )
				trr_AjaxClient._onLoadFile ( uri, async, callback, xmlHttp, async_data );
		}
	}
	
	if ( method == 'POST' ) {
		xmlHttp.setRequestHeader ( 'Content-Type', 'application/x-www-form-urlencoded' );
		
		if ( params != null )
			xmlHttp.setRequestHeader ( 'Content-Length', params.length.toString () );
	}
	
	xmlHttp.send ( params );
	
	if ( async )
		return	xmlHttp;
	else
		return	trr_AjaxClient._onLoadFile ( uri, async, callback, xmlHttp );
}

/*private*/
trr_AjaxClient._onLoadFile = function ( uri, async, callback, req, async_data ) {
	if ( callback != undefined )
		callback ( req.responseText, req.responseXML, async_data );
	if ( !async )
		return	req.responseXML;
}

/*private*/
trr_AjaxClient._getXmlHttp = function() {
	try {
		if ( window.XMLHttpRequest ) {
			var req = new XMLHttpRequest ();
			// some versions of Moz do not support the readyState property and the onreadystate event so we patch it!
			if ( req.readyState == null ) {
				req.readyState = 1;
				req.addEventListener ( 'load', 
									function () {
										req.readyState = 4;
										
										if ( typeof ( req.onreadystatechange ) == 'function' )
											req.onreadystatechange ();
									},
									false );
			}
			
			return	req;
		}
		
		if ( window.ActiveXObject )
			return	new ActiveXObject ( trr_AjaxClient._getXmlHttpProgID () );
	} catch ( ex ) {}
	
	throw new Error ( 'Your browser does not support XmlHttp objects' );
}

/*private*/
trr_AjaxClient._getXmlHttpProgID = function () {
	if ( trr_AjaxClient._getXmlHttpProgID.progid )
		return	trr_AjaxClient._getXmlHttpProgID.progid;
	
	var progids = ['Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
	var o;
	
	for ( var i = 0; i < progids.length; i++ ) {
		try {
			o = new ActiveXObject ( progids [i] );
			
			return	trr_AjaxClient._getXmlHttpProgID.progid = progids [i];
		} catch ( ex ) {};
	}
	
	throw new Error ( 'Could not find an installed XML parser' );
}
/*
 * } // end of class trr_AjaxClient
 */
}
if ( !trr_Included ( 'trr_ajax_async_request' ) ) {
	trr_RegisterInclusion ( 'trr_ajax_async_request' );
/*
 *  static class trr_AjaxAsyncRequest {
 */
function trr_AjaxAsyncRequest ( method, obj, callback ) {
	this.method   = method == 'POST' ? 'POST' : 'GET';
	this.obj      = obj;
	this.callback = callback;
	this.exec     = false;
	this.invoke_callback  = true;
	this.xml_http_request = null;
}

trr_AjaxAsyncRequest.prototype.Send = function ( uri, params, async_data ) {
	this.Abort ();
	
	var caller_info = { 'sender' : this, 'async_data' : async_data };
	
	if ( this.method == 'GET' )
		this.xml_http_request = trr_AjaxClient.SendGetRequest ( uri, true, trr_AjaxAsyncRequest._requestCallback, caller_info );
	else
		this.xml_http_request = trr_AjaxClient.SendPostRequest ( uri, params, true, trr_AjaxAsyncRequest._requestCallback, caller_info );
}

trr_AjaxAsyncRequest.prototype.EvalRemoteScript = function ( uri, params, invoke_callback, async_data ) {
	this.exec = true;
	this.invoke_callback = invoke_callback;
	
	this.Send ( uri, params, async_data );
}

/*private static*/
trr_AjaxAsyncRequest._requestCallback = function ( text, xml, caller_info ) {
	caller_info.sender.xml_http_request = null;
	
	if ( caller_info.sender.exec ) {
		var nd = xml.getElementsByTagName ( 'data' );
		
		if ( nd.length != 0 )
			eval ( nd [0].childNodes [0].nodeValue );
	}
	
	var sender = caller_info.sender;
	var cb     = sender.callback;
	
	if ( sender.obj [cb] && ( !sender.exec || ( sender.exec && sender.invoke_callback ) ) )
		sender.obj [cb] ( text, xml, caller_info.async_data );
}

trr_AjaxAsyncRequest.prototype.Abort = function () {
	if ( this.xml_http_request != null ) {
		this.xml_http_request.abort ();
		this.xml_http_request = null;
	}
}

trr_AjaxAsyncRequest.prototype.Sending = function () {
	return	this.xml_http_request != null;
}
/*
 * } // end of class trr_AjaxAsyncRequest
 */
}
if ( !trr_Included ( 'trr_image_preloader' ) ) {
	trr_RegisterInclusion ( 'trr_image_preloader' );
/*
 *  class trr_ImagePreLoader {
 */
function trr_ImagePreLoader ( obj_name, allImagesLoadedCallback ) {
	this.obj_name = obj_name;
	this.allImagesLoadedCallbacks = new Array ();
	this.AddAllImagesLoadedEventListener ( allImagesLoadedCallback );
	
	this.html                    = '';
	this.async_data              = null;
	this.pre_loaded_images_count = 0;
	this.images_to_pre_load      = 0;
	this.images                  = new Array ();
}

trr_ImagePreLoader.prototype.AddAllImagesLoadedEventListener = function ( callback ) {
	if ( callback )
		this.allImagesLoadedCallbacks.push ( callback );
}

trr_ImagePreLoader.prototype.RaiseAllImagesLoadedEvent = function () {
	for ( var key in this.allImagesLoadedCallbacks ) {
		eval ( this.allImagesLoadedCallbacks [key] + ' ( "' + this.html.replace ( /\"/g, '\\"' ).replace ( /[\r\n]/g, '' ) + '", "' + this.async_data.replace ( /\"/g, '\\"' ) + '" );' );
	}
}

trr_ImagePreLoader.prototype.ImagePreLoaded = function ( img ) {
	this.images.push ( img );
	this.pre_loaded_images_count++;
	
	if ( this.images_to_pre_load == this.pre_loaded_images_count )
		this.RaiseAllImagesLoadedEvent ();
}

trr_ImagePreLoader.prototype.PreLoadImages = function ( html, async_data ) {
	this.html                    = html;
	this.async_data			     = async_data;
	this.pre_loaded_images_count = 0;
	this.images.length           = 0;
	
	var ms1 = html.match ( /src=(["'])[a-z:%\/\-_0-9\.\?\s\=\&]+(\1)/gi );
	var ms2 = html.match ( /url\s*\(\s*(["']?)[a-z:%\/\-_0-9\.\?\s\=\&]+(\1)\s*\)/gi );
	
	var matches = ms1 && ms2 ? ms1.concat ( ms2 ) : ( ms1 ? ms1 : ( ms2 ? ms2 : null ) );
	
	if ( matches ) {
		this.images_to_pre_load = matches.length;
		var i;
		
		for ( i = 0 ; i < matches.length ; i++ )
			matches [i] = matches [i].replace ( /^(src=|url)/, '' ).replace ( /['"()]/g, '' ).trim ();
		
		var img_pre_loader;
		var this_ref = this;
		var img_refs = new Array ();
		
		for ( i = 0 ; i < matches.length ; i++ ) {
			var img = new Image ();
			
			img.onload = function () {
				this_ref.ImagePreLoaded ( this );
			}
			
			img.src = matches [i];
		}
	} else {
		this.RaiseAllImagesLoadedEvent ();
	}
}
/*
 * } // end of class trr_ImagePreLoader
 */
}
if ( !trr_Included ( 'trr_animation_keyframe' ) ) {
	trr_RegisterInclusion ( 'trr_animation_keyframe' );
/*
 *  class trr_KeyFrame {
 */
function trr_KeyFrame () {
	this.Init ();
}

/*const*/
trr_KeyFrame.INC_CONTINUOUS = 0;
trr_KeyFrame.INC_DISCRETE   = 1;

trr_KeyFrame.prototype.Init = function () {
	this.anim_props = new Array ();
}

trr_KeyFrame.prototype.SetProperty = function ( prop_name, prop_elt_path, prop_val, val_setter_code, inc_type ) {
	var prop = { 'prop_name'        : prop_name,
				 'prop_elt_path'    : prop_elt_path,
				 'prop_val'         : prop_val,
				 'val_setter_code'  : val_setter_code,
				 'inc_type'         : inc_type ? ( inc_type == trr_KeyFrame.INC_CONTINUOUS ? trr_KeyFrame.INC_CONTINUOUS : trr_KeyFrame.INC_DISCRETE ) : trr_KeyFrame.INC_CONTINUOUS
			   };
	
	this.anim_props [prop_name] = prop;
}

trr_KeyFrame.prototype.SetOpacity = function ( opacity ) {
	this.SetProperty ( 'opacity'   , 'style.opacity'        , opacity       );
	this.SetProperty ( 'opacity_ie', 'filters.alpha.opacity', opacity * 100 );	// for IE
}

trr_KeyFrame.prototype.SetPosition = function ( left, top ) {
	this.SetProperty ( 'left', 'style.left', left, "prop_val = '\"' + prop_val + 'px' + '\"';" );
	this.SetProperty ( 'top' , 'style.top' , top , "prop_val = '\"' + prop_val + 'px' + '\"';" );
}

trr_KeyFrame.prototype.SetSize = function ( width, height ) {
	this.SetProperty ( 'width' , 'style.width' , width , "prop_val = '\"' + prop_val + 'px' + '\"';" );
	this.SetProperty ( 'height', 'style.height', height, "prop_val = '\"' + prop_val + 'px' + '\"';" );
}

trr_KeyFrame.prototype.SetVisibility = function ( visible ) {
	this.SetProperty ( 'visibility' , 'style.visibility', visible ? 'visible' : 'hidden', null, trr_KeyFrame.INC_DISCRETE );
}
/*
 * } // end of class trr_KeyFrame
 */
}
if ( !trr_Included ( 'trr_animation' ) ) {
	trr_RegisterInclusion ( 'trr_animation' );
/*
 *  class trr_Animaton {
 */
function trr_Animaton ( obj_name, elt, stoppedCallback ) {
	this.obj_name = obj_name;
	this.Init ( elt, stoppedCallback );
}

trr_Animaton.prototype.Init = function ( elt, stoppedCallback ) {
	this.elt            = elt;
	this.keyframes      = new Array ();
	this.keyframes_map  = new Array ();
	this.keyframe_id    = -1;
	this.speed_mul      =  1;
	this.reverse        = false;
	this.intervalHandle = -1;
	this.keyFrameFrom   = null;
	this.keyFrameTo     = null;
	this.time_start     = -1;
	this.time_elapsed   = -1;
	
	this.stoppedCallbacks = new Array ();
	this.AddStoppedEventListener ( stoppedCallback );
}

trr_Animaton.prototype.AddKeyFrame = function ( keyframe, time ) {
	if ( keyframe )
		this.keyframes [time] = keyframe;
}

trr_Animaton.prototype.AddStoppedEventListener = function ( callback ) {
	if ( callback )
		this.stoppedCallbacks.push ( callback );
}

trr_Animaton.prototype.RaiseStoppedEventListener = function () {
	for ( var key in this.stoppedCallbacks )
		eval ( this.stoppedCallbacks [key] + ' ( ' + this.speed_mul + ', ' + this.reverse + ');' );
}

trr_Animaton.prototype.PathValid = function ( path ) {
	var path_nodes = path.split ( '.' );
	var path = 'this.elt';
	var valid = true;
	
	for ( var key in path_nodes ) {
		path += '.' + path_nodes [key];
		eval ( 'valid = ' + path + ' != null;' );
		
		if ( !valid )
			break;
	}
	
	return	valid;
}

trr_Animaton.prototype.TerminateElementProperties = function () {
	for ( var key in this.keyFrameTo.anim_props ) {
		var propTo = this.keyFrameTo.anim_props [key];
		
		if ( propTo.inc_type == trr_KeyFrame.INC_DISCRETE ) {
			var prop_val = propTo.prop_val;
			
			if ( propTo.val_setter_code )
				eval ( propTo.val_setter_code );
			
			if ( this.PathValid ( propTo.prop_elt_path ) )
				eval ( 'this.elt.' + propTo.prop_elt_path + ' = "' + prop_val + '";' );
		}
	}
}

trr_Animaton.prototype.UpdateElementProperties = function () {
	var propFrom, propTo, prop_val;
	
	for ( var key in this.keyFrameFrom.anim_props ) {
		propFrom = this.keyFrameFrom.anim_props [key];
		
		if ( propFrom.inc_type == trr_KeyFrame.INC_DISCRETE ) {
			prop_val = propFrom.prop_val;
			
			if ( propFrom.val_setter_code )
				eval ( propFrom.val_setter_code );
			
			if ( this.PathValid ( propFrom.prop_elt_path ) )
				eval ( 'this.elt.' + propFrom.prop_elt_path + ' = "' + prop_val + '";' );
		}
	}
	
	for ( var key in this.keyFrameTo.anim_props ) {
		propTo = this.keyFrameTo.anim_props [key];
		
		if ( !this.keyFrameFrom.anim_props [key] )
			continue;
		
		propFrom = this.keyFrameFrom.anim_props [key];
		
		if ( propTo.inc_type == trr_KeyFrame.INC_CONTINUOUS ) {
			/*FIXIT если один keyframe, будет деление на 0*/
			prop_val = ( propTo.prop_val - propFrom.prop_val ) * ( this.time_elapsed - this.keyFrameFromTime ) / ( this.keyFrameToTime - this.keyFrameFromTime ) + propFrom.prop_val;
			
			if ( propTo.val_setter_code )
				eval ( propTo.val_setter_code );
			
			if ( this.PathValid ( propTo.prop_elt_path ) )
				eval ( 'this.elt.' + propTo.prop_elt_path + ' = ' + prop_val + ';' );
		}
	}
}

/*static*/
trr_Animaton.prototype.frameCallback = function () {
	var curDate = new Date ();
	this.time_elapsed = ( curDate.getTime () - this.time_start ) * this.speed_mul;
	
	if ( this.time_elapsed > this.keyFrameToTime ) {
		this.time_elapsed = this.keyFrameToTime;
		this.UpdateElementProperties ();
		this.keyframe_id++;
		
		if ( this.keyframe_id >= this.keyframes_map.length ) {
			this.Stop ();
			this.TerminateElementProperties ();
			this.RaiseStoppedEventListener ();
			
			return;
		}
		
		this.keyFrameFrom     = this.keyFrameTo;
		this.keyFrameFromTime = this.keyFrameToTime;
		this.keyFrameTo     = this.keyframes [this.keyframes_map [this.keyframe_id]];
		this.keyFrameToTime = this.keyframes_map [this.keyframe_id];
	}
	
	this.UpdateElementProperties ();
}

trr_Animaton.prototype.Start = function ( speed_mul, reverse ) {
	this.speed_mul  = speed_mul ? speed_mul : 1;
	var old_reverse = this.reverse;
	this.reverse    = reverse   ? reverse   : false;
	this.Stop ();
	
	if ( this.keyframes.length > 0 ) {
		this.keyframe_id = 1;
		var i = 0;
		
		for ( var key in this.keyframes ) {
			this.keyframes_map [i] = key;
			i++;
		}
		
		this.keyframes_map.sort ( trr_Common.sortNumberComparer );
		
		for ( var key in this.keyframes_map )
			this.keyframes_map [key] = parseInt ( this.keyframes_map [key] );
		
		if ( this.reverse ^ old_reverse ) {
			var reversed_keyframes_map = new Array ();
			var reversed_keyframes     = new Array ();
			var max_time = this.keyframes_map [this.keyframes_map.length - 1];
			
			for ( i = this.keyframes_map.length - 1, j = 0 ; i > -1 ; i--, j++ ) {
				var old_time = this.keyframes_map [i];
				var new_time = max_time - old_time;
				reversed_keyframes_map [j]        = new_time;
				reversed_keyframes     [new_time] = this.keyframes [old_time];
			}
			
			this.keyframes_map = reversed_keyframes_map;
			this.keyframes     = reversed_keyframes;
			//alert ( get_object_dump ( reversed_keyframes_map ) );
			//alert ( get_object_dump ( reversed_keyframes ) );
		}
		
		this.keyFrameFrom     = this.keyframes [this.keyframes_map [0]];
		this.keyFrameFromTime = this.keyframes_map [0];
		
		var key_frame_to_id = this.keyframes.length > 1 ? 1 : 0;
		this.keyFrameTo     = this.keyframes [this.keyframes_map [key_frame_to_id]];
		this.keyFrameToTime = this.keyframes_map [key_frame_to_id];
		
		var curDate = new Date ();
		this.time_start   = curDate.getTime ();
		this.time_elapsed = 0;
		this.UpdateElementProperties ();
		this.intervalHandle = setInterval ( this.obj_name + '.frameCallback ();', 10 );
	}
}

trr_Animaton.prototype.Stop = function () {
	if ( this.keyframe_id != -1 ) {
		this.keyframe_id = -1;
		
		if ( this.intervalHandle != -1 ) {
			clearInterval ( this.intervalHandle );
			this.intervalHandle = -1;
		}
	}
}

trr_Animaton.prototype.Working = function () {
	return	this.keyframe_id != -1;
}
/*
 * } // end of class trr_Animaton
 */
}
if ( !trr_Included ( 'trr_animation_queue' ) ) {
	trr_RegisterInclusion ( 'trr_animation_queue' );
/*
 *  class trr_AnimatonQueue {
 */
function trr_AnimatonQueue ( obj_name, stoppedCallback ) {
	this.obj_name = obj_name;
	this.Init ( stoppedCallback );
}

trr_AnimatonQueue.prototype.Init = function ( stoppedCallback ) {
	this.animation_queue = new Array ();
	this.animation_id    = -1;
	this.speed_mul       =  1;
	this.reverse         = false;
	
	this.stoppedCallbacks = new Array ();
	this.AddStoppedEventListener ( stoppedCallback );
}

trr_AnimatonQueue.prototype.AddAnimation = function ( animation ) {
	if ( animation ) {
		this.animation_queue.push ( animation );
		animation.AddStoppedEventListener ( this.obj_name + '.animationStoppedCallback' );
	}
}

trr_AnimatonQueue.prototype.animationStoppedCallback = function ( speed_mul ) {
	if ( !this.Working () )
		return;
		
	if ( this.reverse )
		this.animation_id--;
	else
		this.animation_id++;
	
	if ( this.animation_id < this.animation_queue.length && this.animation_id > -1 ) {
		this.animation_queue [this.animation_id].Start ( this.speed_mul, this.reverse );
	} else {
		this.animation_id = -1;
	}
	
	if ( this.animation_id == -1 )
		this.RaiseStoppedEventListener ();
}

trr_AnimatonQueue.prototype.AddStoppedEventListener = function ( callback ) {
	if ( callback )
		this.stoppedCallbacks.push ( callback );
}

trr_AnimatonQueue.prototype.RaiseStoppedEventListener = function () {
	for ( var key in this.stoppedCallbacks )
		eval ( this.stoppedCallbacks [key] + ' ( ' + this.speed_mul + ', ' + this.reverse + ');' );
}

trr_AnimatonQueue.prototype.Start = function ( speed_mul, reverse ) {
	this.speed_mul = speed_mul ? speed_mul : 1;
	this.reverse   = reverse   ? reverse   : false;
	this.Stop ();
	
	if ( this.animation_queue.length > 0 ) {
		this.animation_id = this.reverse ? this.animation_queue.length - 1 : 0;
		this.animation_queue [this.animation_id].Start ( this.speed_mul, this.reverse );
	}
}

trr_AnimatonQueue.prototype.Stop = function () {
	if ( this.animation_id != -1 ) {
		this.animation_queue [this.animation_id].Stop ();
		this.animation_id = -1;
	}
}

trr_AnimatonQueue.prototype.Working = function () {
	return	this.animation_id != -1;
}
/*
 * } // end of class trr_AnimatonQueue
 */
}
if ( !trr_Included ( 'trr_image_preview' ) ) {
	trr_RegisterInclusion ( 'trr_image_preview' );
/*
 *  class trr_Hint {
 */
function trr_Hint ( obj_name, hint_id             , hint_css_class    , hint_content,
							  bg_fader_id         , bg_fader_class    ,
							  hint_prevbtn_id     , prevbtn_class     ,
							  hint_nextbtn_id     , nextbtn_class     ,
							  hint_closebtn_id    , closebtn_class    ,
							  hint_padding_id     , padding_class     ,
							  hint_caption_id     , caption_class     , caption,
							  hint_loading_id     , loading_class     ,
							  hint_item_loading_id, item_loading_class,
							  img_close           ,
							  img_prevbtn         , img_nextbtn       ,
							  img_prevbtn_hover   , img_nextbtn_hover ,
							  img_loading1        , img_loading2 ) {
	this.obj_name              = obj_name;
	this.hint_elt              = null;
	this.bg_fader_elt          = null;
	this.origin_elt            = null;
	this.origin_elt_id         = '';
	this.origin_elt_offset     = null;
	this.loadingTimeoutHandle  = -1;
	this.loadingTimeout        = 500;
	this.hint_items            = new Array ();
	this.image_pre_loader      = new trr_ImagePreLoader ( this.obj_name + '.image_pre_loader'     , this.obj_name + '._doShow'     );
	this.item_image_pre_loader = new trr_ImagePreLoader ( this.obj_name + '.item_image_pre_loader', this.obj_name + '._doShowItem' );
	this.Init ( hint_id             , hint_css_class    , hint_content,
				bg_fader_id         , bg_fader_class    ,
				hint_prevbtn_id     , prevbtn_class     ,
				hint_nextbtn_id     , nextbtn_class     ,
				hint_closebtn_id    , closebtn_class    ,
				hint_padding_id     , padding_class     ,
				hint_caption_id     , caption_class     , caption,
				hint_loading_id     , loading_class     ,
				hint_item_loading_id, item_loading_class,
				img_close           ,
				img_prevbtn         , img_nextbtn       ,
				img_prevbtn_hover   , img_nextbtn_hover ,
				img_loading1        , img_loading2 );
}

trr_Hint.prototype.Init = function ( hint_id             , hint_css_class    , hint_content,
									 bg_fader_id         , bg_fader_class    ,
									 hint_prevbtn_id     , prevbtn_class     ,
									 hint_nextbtn_id     , nextbtn_class     ,
									 hint_closebtn_id    , closebtn_class    ,
									 hint_padding_id     , padding_class     ,
									 hint_caption_id     , caption_class     , caption,
									 hint_loading_id     , loading_class     ,
									 hint_item_loading_id, item_loading_class,
									 img_close           ,
									 img_prevbtn         , img_nextbtn       ,
									 img_prevbtn_hover   , img_nextbtn_hover ,
									 img_loading1        , img_loading2 ) {
	if ( document.body ) {
		this.hint_elt = document.createElement ( 'DIV' );
		this.hint_elt.setAttribute ( 'id', hint_id );
		this.hint_elt.className = hint_css_class;
		this.hint_elt.innerHTML = hint_content;
		eval ( 'this.hint_elt.onclick = function () { ' + this.obj_name + '.Hide (); }' );
		eval ( 'this.hint_elt.onmouseover = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		eval ( 'this.hint_elt.onmousemove = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		this.hint_elt.style.visibility = 'hidden';
		this.hint_elt.style.position   = 'absolute';
		this.hint_elt.style.left       = '0px';
		this.hint_elt.style.top        = '0px';
		this.hint_elt.style.zIndex     = 999;
		document.body.appendChild ( this.hint_elt );
		this.hint_shown  = false;
		this.hint_hiding = false;
		
		this.hint_closebtn_elt = document.createElement ( 'DIV' );
		this.hint_closebtn_elt.setAttribute ( 'id', hint_closebtn_id );
		this.hint_closebtn_elt.className = closebtn_class;
		this.hint_closebtn_elt.innerHTML = '<b>Закрыть</b> <img class="trr_hint_close_img" src="' + img_close + '" />';
		eval ( 'this.hint_closebtn_elt.onmouseover = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		eval ( 'this.hint_closebtn_elt.onmousemove = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		this.hint_closebtn_elt.style.visibility = 'hidden';
		this.hint_closebtn_elt.style.position   = 'absolute';
		this.hint_closebtn_elt.style.left       = '0px';
		this.hint_closebtn_elt.style.top        = '0px';
		this.hint_closebtn_elt.style.zIndex     = 1000;
		document.body.appendChild ( this.hint_closebtn_elt );
		this.closebtn_shown = false;
		
		this.hint_prevbtn_elt = document.createElement ( 'DIV' );
		this.hint_prevbtn_elt.setAttribute ( 'id', hint_prevbtn_id );
		this.hint_prevbtn_elt.className = prevbtn_class;
		eval ( 'this.hint_prevbtn_elt.onclick = function () { ' + this.obj_name + '.ShowPrevItem (); }' );
		eval ( 'this.hint_prevbtn_elt.onmouseover = function () { ' + this.obj_name + '.MouseOverPrevBtnEventHandler (); }' );
		eval ( 'this.hint_prevbtn_elt.onmousemove = function () { ' + this.obj_name + '.MouseOverPrevBtnEventHandler (); }' );
		eval ( 'this.hint_prevbtn_elt.onmouseout  = function () { ' + this.obj_name + '.MouseOutPrevBtnEventHandler  (); }' );
		this.hint_prevbtn_elt.style.backgroundImage    = 'url(' + img_prevbtn + ')';
		this.hint_prevbtn_elt.style.backgroundRepeat   = 'no-repeat';
		this.hint_prevbtn_elt.style.backgroundPosition = 'left 35%';
		this.hint_prevbtn_elt.style.visibility = 'hidden';
		this.hint_prevbtn_elt.style.position   = 'absolute';
		this.hint_prevbtn_elt.style.left       = '0px';
		this.hint_prevbtn_elt.style.top        = '0px';
		this.hint_prevbtn_elt.style.zIndex     = 1000;
		document.body.appendChild ( this.hint_prevbtn_elt );
		this.img_prevbtn       = img_prevbtn;
		this.img_prevbtn_hover = img_prevbtn_hover;
		
		this.hint_nextbtn_elt = document.createElement ( 'DIV' );
		this.hint_nextbtn_elt.setAttribute ( 'id', hint_nextbtn_id );
		this.hint_nextbtn_elt.className = nextbtn_class;
		eval ( 'this.hint_nextbtn_elt.onclick = function () { ' + this.obj_name + '.ShowNextItem (); }' );
		eval ( 'this.hint_nextbtn_elt.onmouseover = function () { ' + this.obj_name + '.MouseOverNextBtnEventHandler (); }' );
		eval ( 'this.hint_nextbtn_elt.onmousemove = function () { ' + this.obj_name + '.MouseOverNextBtnEventHandler (); }' );
		eval ( 'this.hint_nextbtn_elt.onmouseout  = function () { ' + this.obj_name + '.MouseOutNextBtnEventHandler  (); }' );
		this.hint_nextbtn_elt.style.backgroundImage    = 'url(' + img_nextbtn + ')';
		this.hint_nextbtn_elt.style.backgroundRepeat   = 'no-repeat';
		this.hint_nextbtn_elt.style.backgroundPosition = 'right 35%';
		this.hint_nextbtn_elt.style.visibility = 'hidden';
		this.hint_nextbtn_elt.style.position   = 'absolute';
		this.hint_nextbtn_elt.style.left       = '0px';
		this.hint_nextbtn_elt.style.top        = '0px';
		this.hint_nextbtn_elt.style.zIndex     = 1000;
		document.body.appendChild ( this.hint_nextbtn_elt );
		this.img_nextbtn       = img_nextbtn;
		this.img_nextbtn_hover = img_nextbtn_hover;
		
		this.hint_loading_elt = document.createElement ( 'DIV' );
		this.hint_loading_elt.setAttribute ( 'id', hint_loading_id );
		this.hint_loading_elt.className = loading_class;
		//this.hint_loading_elt.innerHTML = '<table style="text-align : center; width : 100%; height : 100%;"><tr><td><img class="trr_hint_loading_img" src="' + img_loading1 + '" /></td></tr></table>';
		this.hint_loading_elt.style.backgroundImage    = 'url(' + img_loading1 + ')';
		this.hint_loading_elt.style.backgroundRepeat   = 'no-repeat';
		this.hint_loading_elt.style.backgroundPosition = 'center center';
		this.hint_loading_elt.style.visibility = 'hidden';
		this.hint_loading_elt.style.position   = 'absolute';
		this.hint_loading_elt.style.left       = '0px';
		this.hint_loading_elt.style.top        = '0px';
		this.hint_loading_elt.style.zIndex     = 996;
		document.body.appendChild ( this.hint_loading_elt );
		
		this.hint_item_loading_elt = document.createElement ( 'DIV' );
		this.hint_item_loading_elt.setAttribute ( 'id', hint_item_loading_id );
		this.hint_item_loading_elt.className = item_loading_class;
		this.hint_item_loading_elt.style.backgroundImage    = 'url(' + img_loading2 + ')';
		this.hint_item_loading_elt.style.backgroundRepeat   = 'no-repeat';
		this.hint_item_loading_elt.style.backgroundPosition = 'center center';
		this.hint_item_loading_elt.style.visibility = 'hidden';
		this.hint_item_loading_elt.style.position   = 'absolute';
		this.hint_item_loading_elt.style.left       = '0px';
		this.hint_item_loading_elt.style.top        = '0px';
		this.hint_item_loading_elt.style.zIndex     = 999;
		document.body.appendChild ( this.hint_item_loading_elt );
		
		this.hint_padding_elt = document.createElement ( 'DIV' );
		this.hint_padding_elt.setAttribute ( 'id', hint_padding_id );
		this.hint_padding_elt.className = padding_class;
		this.hint_padding_elt.innerHTML = '&nbsp;';
		eval ( 'this.hint_padding_elt.onmouseover = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		eval ( 'this.hint_padding_elt.onmousemove = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		this.hint_padding_elt.style.visibility = 'hidden';
		this.hint_padding_elt.style.position   = 'absolute';
		this.hint_padding_elt.style.left       = '0px';
		this.hint_padding_elt.style.top        = '0px';
		this.hint_padding_elt.style.zIndex     = 998;
		document.body.appendChild ( this.hint_padding_elt );
		this.padding_size = 10;
		
		this.hint_caption_elt = document.createElement ( 'DIV' );
		this.hint_caption_elt.setAttribute ( 'id', hint_caption_id );
		this.hint_caption_elt.className = caption_class;
		this.hint_caption_elt.innerHTML = caption;
		eval ( 'this.hint_caption_elt.onmouseover = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		eval ( 'this.hint_caption_elt.onmousemove = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		this.hint_caption_elt.style.visibility = 'hidden';
		this.hint_caption_elt.style.position   = 'absolute';
		this.hint_caption_elt.style.left       = '0px';
		this.hint_caption_elt.style.top        = '0px';
		this.hint_caption_elt.style.zIndex     = 999;
		document.body.appendChild ( this.hint_caption_elt );
		
		this.bg_fader_elt = document.createElement ( 'DIV' );
		this.bg_fader_elt.setAttribute ( 'id', bg_fader_id );
		this.bg_fader_elt.className = bg_fader_class;
		eval ( 'this.bg_fader_elt.onclick = function () { ' + this.obj_name + '.Hide (); }' );
		eval ( 'this.bg_fader_elt.onmouseover = function () { ' + this.obj_name + '.MouseOverBgEventHandler (); }' );
		eval ( 'this.bg_fader_elt.onmouseout = function () { ' + this.obj_name + '.MouseOverHintEventHandler (); }' );
		this.bg_fader_elt.style.visibility = 'hidden';
		this.bg_fader_elt.style.position   = 'absolute';
		this.bg_fader_elt.style.left       = '0px';
		this.bg_fader_elt.style.top        = '0px';
		this.bg_fader_elt.style.zIndex     = 997;
		document.body.appendChild ( this.bg_fader_elt );
		
		/* hint appearing/disappearing animations ( hint, bg_fader, padding, caption )*/
		this.anim_hint = new trr_Animaton ( this.obj_name + '.anim_hint', this.hint_elt );
		this.anim_hint_kf0 = new trr_KeyFrame ();
		this.anim_hint_kf0.SetVisibility ( false );
		this.anim_hint_kf1 = new trr_KeyFrame ();
		this.anim_hint_kf1.SetVisibility ( true );
		this.anim_hint_kf1.SetOpacity    ( 0 );
		this.anim_hint_kf2 = new trr_KeyFrame ();
		this.anim_hint_kf2.SetOpacity    ( 1 );
		this.anim_hint.AddKeyFrame ( this.anim_hint_kf0,   0 );
		this.anim_hint.AddKeyFrame ( this.anim_hint_kf1,   1 );
		this.anim_hint.AddKeyFrame ( this.anim_hint_kf2, 350 );
		
		this.anim_bg_fader = new trr_Animaton ( this.obj_name + '.anim_bg_fader', this.bg_fader_elt );
		this.anim_bg_fader_kf0 = new trr_KeyFrame ();
		this.anim_bg_fader_kf0.SetVisibility ( false );
		this.anim_bg_fader_kf1 = new trr_KeyFrame ();
		this.anim_bg_fader_kf1.SetVisibility ( true );
		this.anim_bg_fader_kf1.SetOpacity ( 0 );
		this.anim_bg_fader_kf2 = new trr_KeyFrame ();
		this.anim_bg_fader_kf2.SetOpacity ( 0.8 );
		this.anim_bg_fader.AddKeyFrame ( this.anim_bg_fader_kf0,   0 );
		this.anim_bg_fader.AddKeyFrame ( this.anim_bg_fader_kf1,   1 );
		this.anim_bg_fader.AddKeyFrame ( this.anim_bg_fader_kf2, 250 );
		
		this.anim_padding = new trr_Animaton ( this.obj_name + '.anim_padding', this.hint_padding_elt );
		this.anim_padding_kf0 = new trr_KeyFrame ();
		this.anim_padding_kf0.SetVisibility ( false );
		this.anim_padding_kf1 = new trr_KeyFrame ();
		this.anim_padding_kf1.SetVisibility    ( true );
		this.anim_padding_kf1.SetOpacity    ( 0 );
		this.anim_padding_kf2 = new trr_KeyFrame ();
		this.anim_padding_kf2.SetOpacity    ( 1 );
		this.anim_padding.AddKeyFrame ( this.anim_padding_kf0,   0 );
		this.anim_padding.AddKeyFrame ( this.anim_padding_kf1,   1 );
		this.anim_padding.AddKeyFrame ( this.anim_padding_kf2, 200 );
		
		this.anim_caption = new trr_Animaton ( this.obj_name + '.anim_caption', this.hint_caption_elt );
		this.anim_caption_kf0 = new trr_KeyFrame ();
		this.anim_caption_kf0.SetVisibility ( false );
		this.anim_caption_kf1 = new trr_KeyFrame ();
		this.anim_caption_kf1.SetVisibility ( true );
		this.anim_caption_kf1.SetOpacity ( 0 );
		this.anim_caption_kf2 = new trr_KeyFrame ();
		this.anim_caption_kf2.SetOpacity ( 1 );
		this.anim_caption.AddKeyFrame ( this.anim_caption_kf0,   0 );
		this.anim_caption.AddKeyFrame ( this.anim_caption_kf1,   1 );
		this.anim_caption.AddKeyFrame ( this.anim_caption_kf2, 250 );
		
		this.anim_queue = new trr_AnimatonQueue ( this.obj_name + '.anim_queue', this.obj_name + '.animationQueueStopped' );
		this.anim_queue.AddAnimation ( this.anim_hint     );
		this.anim_queue.AddAnimation ( this.anim_bg_fader );
		this.anim_queue.AddAnimation ( this.anim_padding  );
		this.anim_queue.AddAnimation ( this.anim_caption  );
		
		/* non-queued animations ( close, prev, next, loading ) */
		this.anim_closebtn = new trr_Animaton ( this.obj_name + '.anim_closebtn', this.hint_closebtn_elt );
		this.anim_closebtn_kf0 = new trr_KeyFrame ();
		this.anim_closebtn_kf0.SetVisibility ( false );
		this.anim_closebtn_kf1 = new trr_KeyFrame ();
		this.anim_closebtn_kf1.SetVisibility ( true );
		this.anim_closebtn_kf1.SetOpacity ( 0 );
		this.anim_closebtn_kf2 = new trr_KeyFrame ();
		this.anim_closebtn_kf2.SetOpacity ( 0 );
		this.anim_closebtn.AddKeyFrame ( this.anim_closebtn_kf0,   0 );
		this.anim_closebtn.AddKeyFrame ( this.anim_closebtn_kf1,   1 );
		this.anim_closebtn.AddKeyFrame ( this.anim_closebtn_kf2, 200 );
		
		this.anim_prevbtn = new trr_Animaton ( this.obj_name + '.anim_prevbtn', this.hint_prevbtn_elt );
		this.anim_prevbtn_kf0 = new trr_KeyFrame ();
		this.anim_prevbtn_kf0.SetVisibility ( false );
		this.anim_prevbtn_kf1 = new trr_KeyFrame ();
		this.anim_prevbtn_kf1.SetVisibility ( true );
		this.anim_prevbtn_kf1.SetOpacity ( 0 );
		this.anim_prevbtn_kf2 = new trr_KeyFrame ();
		this.anim_prevbtn_kf2.SetOpacity ( 1 );
		this.anim_prevbtn.AddKeyFrame ( this.anim_prevbtn_kf0,   0 );
		this.anim_prevbtn.AddKeyFrame ( this.anim_prevbtn_kf1,   1 );
		this.anim_prevbtn.AddKeyFrame ( this.anim_prevbtn_kf2, 200 );
		
		this.anim_nextbtn = new trr_Animaton ( this.obj_name + '.anim_nextbtn', this.hint_nextbtn_elt );
		this.anim_nextbtn_kf0 = new trr_KeyFrame ();
		this.anim_nextbtn_kf0.SetVisibility ( false );
		this.anim_nextbtn_kf1 = new trr_KeyFrame ();
		this.anim_nextbtn_kf1.SetVisibility ( true );
		this.anim_nextbtn_kf1.SetOpacity ( 0 );
		this.anim_nextbtn_kf2 = new trr_KeyFrame ();
		this.anim_nextbtn_kf2.SetOpacity ( 1 );
		this.anim_nextbtn.AddKeyFrame ( this.anim_nextbtn_kf0,   0 );
		this.anim_nextbtn.AddKeyFrame ( this.anim_nextbtn_kf1,   1 );
		this.anim_nextbtn.AddKeyFrame ( this.anim_nextbtn_kf2, 200 );
		
		this.anim_loading = new trr_Animaton ( this.obj_name + '.anim_loading', this.hint_loading_elt );
		this.anim_loading_kf0 = new trr_KeyFrame ();
		this.anim_loading_kf0.SetVisibility ( false );
		this.anim_loading_kf1 = new trr_KeyFrame ();
		this.anim_loading_kf1.SetVisibility ( true );
		this.anim_loading_kf1.SetOpacity ( 0 );
		this.anim_loading_kf2 = new trr_KeyFrame ();
		this.anim_loading_kf2.SetOpacity ( 1 );
		this.anim_loading.AddKeyFrame ( this.anim_loading_kf0,   0 );
		this.anim_loading.AddKeyFrame ( this.anim_loading_kf1,   1 );
		this.anim_loading.AddKeyFrame ( this.anim_loading_kf2, 250 );
		
		/* item-browsing animations ( hint_fading, caption, item_loading ) */
		this.hint_fading = new trr_Animaton ( this.obj_name + '.hint_fading', this.hint_elt );
		this.hint_fading_kf0 = new trr_KeyFrame ();
		this.hint_fading_kf0.SetOpacity    ( 1 );
		this.hint_fading_kf1 = new trr_KeyFrame ();
		this.hint_fading_kf1.SetVisibility ( true );
		this.hint_fading_kf1.SetOpacity    ( 0 );
		this.hint_fading_kf2 = new trr_KeyFrame ();
		this.hint_fading_kf2.SetVisibility ( false );
		this.hint_fading.AddKeyFrame ( this.hint_fading_kf0,   0 );
		this.hint_fading.AddKeyFrame ( this.hint_fading_kf1, 149 );
		this.hint_fading.AddKeyFrame ( this.hint_fading_kf2, 150 );
		
		this.caption_fading = new trr_Animaton ( this.obj_name + '.caption_fading', this.hint_caption_elt );
		this.caption_fading_kf0 = new trr_KeyFrame ();
		this.caption_fading_kf0.SetOpacity ( 1 );
		this.caption_fading_kf1 = new trr_KeyFrame ();
		this.caption_fading_kf1.SetVisibility ( true );
		this.caption_fading_kf1.SetOpacity ( 0 );
		this.caption_fading_kf2 = new trr_KeyFrame ();
		this.caption_fading_kf2.SetVisibility ( false );
		this.caption_fading.AddKeyFrame ( this.caption_fading_kf0,   0 );
		this.caption_fading.AddKeyFrame ( this.caption_fading_kf1, 149 );
		this.caption_fading.AddKeyFrame ( this.caption_fading_kf2, 150 );
		
		this.anim_item_loading = new trr_Animaton ( this.obj_name + '.anim_item_loading', this.hint_item_loading_elt );
		this.anim_item_loading_kf0 = new trr_KeyFrame ();
		this.anim_item_loading_kf0.SetVisibility ( false );
		this.anim_item_loading_kf1 = new trr_KeyFrame ();
		this.anim_item_loading_kf1.SetVisibility ( true );
		this.anim_item_loading_kf1.SetOpacity ( 0 );
		this.anim_item_loading_kf2 = new trr_KeyFrame ();
		this.anim_item_loading_kf2.SetOpacity ( 1 );
		this.anim_item_loading.AddKeyFrame ( this.anim_item_loading_kf0,   0 );
		this.anim_item_loading.AddKeyFrame ( this.anim_item_loading_kf1,   1 );
		this.anim_item_loading.AddKeyFrame ( this.anim_item_loading_kf2, 150 );
		
		this.anim_padding_resize = new trr_Animaton ( this.obj_name + '.anim_padding_resize', this.hint_padding_elt );
		this.anim_padding_resize_kf0 = new trr_KeyFrame ();
		this.anim_padding_resize_kf1 = new trr_KeyFrame ();
		this.anim_padding_resize.AddKeyFrame ( this.anim_padding_resize_kf0,   0 );
		this.anim_padding_resize.AddKeyFrame ( this.anim_padding_resize_kf1, 150 );
		
		this.anim_items_queue = new trr_AnimatonQueue ( this.obj_name + '.anim_items_queue', this.obj_name + '._animationItemsQueueStopped' );
		this.anim_items_queue.AddAnimation ( this.caption_fading      );
		this.anim_items_queue.AddAnimation ( this.hint_fading         );
		this.anim_items_queue.AddAnimation ( this.anim_padding_resize );
	}
	
	var this_ref = this;
	
	document.onkeydown = function ( e ) {
		var keycode = trr_Common.Browser.IE ? window.event.keyCode : e.which;
		
		if ( !this_ref.hint_hiding && this_ref.hint_shown ) {
			if ( keycode == 39 )
				this_ref.ShowNextItem ();
			else if ( keycode == 37 )
				this_ref.ShowPrevItem ();
			else if ( keycode == 27 )
				this_ref.Hide ();
		}
	};
}

trr_Hint.prototype.AddHintItem = function ( origin_elt_id, content, caption ) {
	var prev = this.hint_items.length > 0 ? this.hint_items [this.hint_items.length - 1] : null;
	
	var new_item = { 'origin_elt_id' : origin_elt_id,
					 'content'       : content      ,
					 'caption'       : caption      ,
					 'prev'          : prev         ,
					 'next'          : null };
	if ( prev )
		prev.next = new_item;
	
	this.hint_items [origin_elt_id]          = new_item;
	this.hint_items [this.hint_items.length] = new_item;
}

trr_Hint.prototype.SetPrevPageUserHandler = function ( obj, btnonshow_name, onclick_name, onhidden_name ) {
	this.prev_page_user_handler = { 'obj' : obj, 'btnonshow_name' : btnonshow_name, 'onclick_name' : onclick_name, 'onhidden_name' : onhidden_name };
}

trr_Hint.prototype.SetNextPageUserHandler = function ( obj, btnonshow_name, onclick_name, onhidden_name ) {
	this.next_page_user_handler = { 'obj' : obj, 'btnonshow_name' : btnonshow_name, 'onclick_name' : onclick_name, 'onhidden_name' : onhidden_name };
}

trr_Hint.prototype.SetCaption = function ( caption ) {
	this.hint_caption_elt.innerHTML = caption;
}

trr_Hint.prototype.SetContent = function ( content ) {
	this.hint_elt.innerHTML = content;
}

/*private*/
trr_Hint.prototype._setContentAndPreload = function ( content, async_data ) {
	if ( typeof content == 'string' ) {
		this.hint_elt.innerHTML = content;
		this.image_pre_loader.PreLoadImages ( content, async_data );
	} else if ( ( typeof content == 'object' ) && ( typeof content.func == 'function' ) ) {
		content.func ( this, '_setContentAndPreload', async_data, content.args );
	}
}

/*private*/
trr_Hint.prototype._doShow = function ( html, origin_elt_id ) {
	if ( this.loadingTimeoutHandle != -1 ) {
		this.anim_loading.Start ( 1, true );
		clearTimeout ( this.loadingTimeoutHandle );
		this.loadingTimeoutHandle = -1;
	}
	
	if ( this.origin_elt ) {
		trr_Common.unsetImageSizes ( this.hint_elt );
		
		var scrollOffsets      = trr_Common.getScrollOffsets      ();
		var viewportDimensions = trr_Common.getViewportDimensions ();
		
		this.end_height = Math.ceil ( viewportDimensions [1] * 0.8 );
		this.end_width  = Math.ceil ( this.hint_elt.clientWidth * this.end_height / this.hint_elt.clientHeight );
		this.end_left   = Math.ceil ( scrollOffsets [0] + ( viewportDimensions [0] - this.end_width  ) / 2 );
		this.end_top    = Math.ceil ( scrollOffsets [1] + ( viewportDimensions [1] - this.end_height ) / 2 - viewportDimensions [1] * 0.05 );
		
		trr_Common.restoreImageSizes ( this.hint_elt );
		
		this.anim_hint_kf1.SetPosition ( this.origin_elt_offset [0] , this.origin_elt_offset [1]   );
		this.anim_hint_kf2.SetPosition ( this.end_left              , this.end_top                 );
		this.anim_hint_kf1.SetSize     ( this.origin_elt.clientWidth, this.origin_elt.clientHeight );
		this.anim_hint_kf2.SetSize     ( this.end_width             , this.end_height              );
		
		/*this.hint_prevbtn_elt.style.left   =   this.end_left  + 'px';
		this.hint_prevbtn_elt.style.top    = ( this.end_top   + this.end_height * 0.3 ) + 'px';
		this.hint_nextbtn_elt.style.left   = ( this.end_left  + this.end_width - this.hint_nextbtn_elt.clientWidth ) + 'px';
		this.hint_nextbtn_elt.style.top    = ( this.end_top   + this.end_height * 0.3 ) + 'px';*/
		
		this.hint_prevbtn_elt.style.left   =   this.end_left + 'px';
		this.hint_prevbtn_elt.style.top    =   this.end_top  + 'px';
		this.hint_prevbtn_elt.style.width  = ( this.end_width * 0.33 ) + 'px';
		this.hint_prevbtn_elt.style.height =   this.end_height + 'px';
		
		this.hint_nextbtn_elt.style.left   = ( this.end_left + this.end_width * 0.67 + 1 ) + 'px';
		this.hint_nextbtn_elt.style.top    =   this.end_top  + 'px';
		this.hint_nextbtn_elt.style.width  = ( this.end_width * 0.33 ) + 'px';
		this.hint_nextbtn_elt.style.height =   this.end_height + 'px';
		
		this.hint_closebtn_elt.style.left  =   this.end_left  + 'px';
		this.hint_closebtn_elt.style.top   =   this.end_top   + 'px';
		this.hint_closebtn_elt.style.width =   this.end_width + 'px';
		
		this.anim_padding_kf1.SetPosition ( this.end_left , this.end_top    );
		this.anim_padding_kf1.SetSize     ( this.end_width, this.end_height );
		this.anim_padding_kf2.SetPosition ( this.end_left  - this.padding_size    , this.end_top    - this.padding_size     );
		this.anim_padding_kf2.SetSize     ( this.end_width + this.padding_size * 2, this.end_height + this.padding_size * 2 + this.hint_caption_elt.clientHeight );
		
		this.hint_caption_elt.style.left = this.end_left + 'px';
		this.hint_caption_elt.style.top  = this.end_top  + this.end_height + 'px';
		
		var pageSize = trr_Common.getPageSize ();
		this.bg_fader_elt.style.width  = pageSize [0];
		this.bg_fader_elt.style.height = pageSize [1];
	}
	
	this.anim_queue.Start ();
}

/*private*/
trr_Hint.prototype._loadingCallback = function () {
	this.hint_loading_elt.style.left   = this.origin_elt_offset [0]   + 'px';
	this.hint_loading_elt.style.top    = this.origin_elt_offset [1]   + 'px';
	this.hint_loading_elt.style.width  = this.origin_elt.clientWidth  + 'px';
	this.hint_loading_elt.style.height = this.origin_elt.clientHeight + 'px';
	this.anim_loading.Start ();
}

trr_Hint.prototype.Show = function ( origin_elt_id, content, caption ) {
	if ( origin_elt_id )
		this._setOriginElt ( origin_elt_id );
	
	this.loadingTimeoutHandle = setTimeout ( this.obj_name + '._loadingCallback ();', this.loadingTimeout );
	
	if ( caption )
		this.SetCaption ( caption );
	
	if ( content )
		this._setContentAndPreload ( content, origin_elt_id );
	else
		this._doShow ( '', origin_elt_id );
}

trr_Hint.prototype.Hide = function () {
	this.anim_hint_kf1.SetPosition ( this.origin_elt_offset [0] , this.origin_elt_offset [1]   );
	this.anim_hint_kf2.SetPosition ( this.end_left              , this.end_top                 );
	this.anim_hint_kf1.SetSize     ( this.origin_elt.clientWidth, this.origin_elt.clientHeight );
	this.anim_hint_kf2.SetSize     ( this.end_width             , this.end_height              );
	
	this.anim_padding_kf1.SetPosition ( this.end_left , this.end_top    );
	this.anim_padding_kf1.SetSize     ( this.end_width, this.end_height );
	this.anim_padding_kf2.SetPosition ( this.end_left  - this.padding_size    , this.end_top    - this.padding_size     );
	this.anim_padding_kf2.SetSize     ( this.end_width + this.padding_size * 2, this.end_height + this.padding_size * 2 + this.hint_caption_elt.clientHeight );
	
	this._hidePanels ();
	this.anim_queue.Start ( 2, true );
	this.hint_hiding = true;
}

/*private*/
trr_Hint.prototype._setOriginElt = function ( origin_elt_id ) {
	this.origin_elt_id = origin_elt_id;
	this.origin_elt    = document.getElementById ( origin_elt_id );
	
	if ( this.origin_elt ) {
		this.origin_elt_offset = [0, 0];
		trr_Common.getElementOffsetXY ( this.origin_elt, this.origin_elt_offset );
	}
}

/*private*/
trr_Hint.prototype._itemLoadingCallback = function () {
	this.hint_item_loading_elt.style.left   = this.end_left   + 'px';
	this.hint_item_loading_elt.style.top    = this.end_top    + 'px';
	this.hint_item_loading_elt.style.width  = this.end_width  + 'px';
	this.hint_item_loading_elt.style.height = this.end_height + 'px';
	this.anim_item_loading.Start ();
}

/*private*/
trr_Hint.prototype._setItemContentAndPreload = function ( content ) {
	if ( typeof content == 'string' ) {
		var item = this.hint_items [this.origin_elt_id];
		item.content = content;
		this.item_image_pre_loader.PreLoadImages ( content, '' );
	} else if ( ( typeof content == 'object' ) && ( typeof content.func == 'function' ) ) {
		content.func ( this, '_setItemContentAndPreload', null, content.args );
	}
}

/*private*/
trr_Hint.prototype._doShowItem = function ( html, async_data ) {
	if ( this.anim_items_queue.Working () && this.hint_hiding ) {
		this.item_content_preloaded = true;
		
		return;
	} else {
		this.item_content_preloaded = false;
	}
	
	var item = this.hint_items [this.origin_elt_id];
	
	if ( this.loadingTimeoutHandle != -1 ) {
		this.anim_item_loading.Start ( 1, true );
		clearTimeout ( this.loadingTimeoutHandle );
		this.loadingTimeoutHandle = -1;
	}
	
	if ( item.caption )
		this.SetCaption ( item.caption );
	
	if ( item.content )
		this.SetContent ( item.content );
	
	if ( this.origin_elt ) {
		trr_Common.unsetImageSizes ( this.hint_elt );
		
		var scrollOffsets      = trr_Common.getScrollOffsets      ();
		var viewportDimensions = trr_Common.getViewportDimensions ();
		
		this.end_height = Math.ceil ( viewportDimensions [1] * 0.8 );
		this.end_width  = Math.ceil ( this.hint_elt.clientWidth * this.end_height / this.hint_elt.clientHeight );
		this.end_left   = Math.ceil ( scrollOffsets [0] + ( viewportDimensions [0] - this.end_width  ) / 2 );
		this.end_top    = Math.ceil ( scrollOffsets [1] + ( viewportDimensions [1] - this.end_height ) / 2 - viewportDimensions [1] * 0.05 );
		
		trr_Common.restoreImageSizes ( this.hint_elt );
		
		this.hint_elt.style.left   = this.end_left   + 'px';
		this.hint_elt.style.top    = this.end_top    + 'px';
		this.hint_elt.style.width  = this.end_width  + 'px';
		this.hint_elt.style.height = this.end_height + 'px';
		
		/*this.hint_prevbtn_elt.style.left   =   this.end_left  + 'px';
		this.hint_prevbtn_elt.style.top    = ( this.end_top   + this.end_height * 0.3 ) + 'px';
		this.hint_nextbtn_elt.style.left   = ( this.end_left  + this.end_width - this.hint_nextbtn_elt.clientWidth ) + 'px';
		this.hint_nextbtn_elt.style.top    = ( this.end_top   + this.end_height * 0.3 ) + 'px';*/
		
		this.hint_prevbtn_elt.style.left   =   this.end_left + 'px';
		this.hint_prevbtn_elt.style.top    =   this.end_top  + 'px';
		this.hint_prevbtn_elt.style.width  = ( this.end_width * 0.33 ) + 'px';
		this.hint_prevbtn_elt.style.height =   this.end_height + 'px';
		
		this.hint_nextbtn_elt.style.left   = ( this.end_left + this.end_width * 0.67 + 1 ) + 'px';
		this.hint_nextbtn_elt.style.top    =   this.end_top  + 'px';
		this.hint_nextbtn_elt.style.width  = ( this.end_width * 0.33 ) + 'px';
		this.hint_nextbtn_elt.style.height =   this.end_height + 'px';
		
		this.hint_closebtn_elt.style.left  =   this.end_left  + 'px';
		this.hint_closebtn_elt.style.top   =   this.end_top   + 'px';
		this.hint_closebtn_elt.style.width =   this.end_width + 'px';
		
		this.anim_padding_resize_kf0.SetPosition ( this.end_left  - this.padding_size    , this.end_top    - this.padding_size     );
		this.anim_padding_resize_kf0.SetSize     ( this.end_width + this.padding_size * 2, this.end_height + this.padding_size * 2 + this.hint_caption_elt.clientHeight );
		this.anim_padding_resize_kf1.SetPosition ( this.hint_padding_elt.offsetLeft , this.hint_padding_elt.offsetTop    );
		this.anim_padding_resize_kf1.SetSize     ( this.hint_padding_elt.offsetWidth, this.hint_padding_elt.offsetHeight );
		
		this.hint_caption_elt.style.left = this.end_left + 'px';
		this.hint_caption_elt.style.top  = this.end_top  + this.end_height + 'px';
	}
		
	this.anim_items_queue.Start ( 1, true );
}

/*private*/
trr_Hint.prototype._animationItemsQueueStopped = function ( speed_mul, reverse ) {
	if ( reverse == false ) {
		this.hint_shown  = false;
		this.hint_hiding = false;
		this.hint_elt.style.width  = '';
		this.hint_elt.style.height = '';
		this.SetCaption ( '' );
		
		if ( this.item_content_preloaded )
			this._doShowItem ( '', '' );
	} else {
		this.hint_shown = true;
		this._showPanels ();
	}
}

/*private*/
trr_Hint.prototype._showItem = function ( item ) {
	this.hint_hiding = true;
	
	this.anim_padding_resize_kf0.SetPosition ( this.hint_padding_elt.offsetLeft , this.hint_padding_elt.offsetTop    );
	this.anim_padding_resize_kf0.SetSize     ( this.hint_padding_elt.offsetWidth, this.hint_padding_elt.offsetHeight );
	this.anim_padding_resize_kf1.SetPosition ( this.hint_padding_elt.offsetLeft , this.hint_padding_elt.offsetTop    );
	this.anim_padding_resize_kf1.SetSize     ( this.hint_padding_elt.offsetWidth, this.hint_padding_elt.offsetHeight );
	
	this.anim_items_queue.Start ( 2 );
	this._hidePanels ();
	
	if ( item.origin_elt_id )
		this._setOriginElt ( item.origin_elt_id );
	
	this.loadingTimeoutHandle = setTimeout ( this.obj_name + '._itemLoadingCallback ();', this.loadingTimeout );
	
	if ( item.content )
		this._setItemContentAndPreload ( item.content );
	else
		this._doShowItem ( '', '' );
}

trr_Hint.prototype.ShowPrevItem = function () {
	var cur_item = this.hint_items [this.origin_elt_id];
	
	if ( cur_item.prev ) {
		this._showItem ( cur_item.prev );
	} else {
		if ( this.prev_page_user_handler              &&
			 this.prev_page_user_handler.obj          &&
			 this.prev_page_user_handler.onclick_name &&
			 this.prev_page_user_handler.obj [this.prev_page_user_handler.onclick_name] )
		this.prev_page_clicked = true;
		this.prev_page_user_handler.obj [this.prev_page_user_handler.onclick_name] ();
	}
}

trr_Hint.prototype.ShowNextItem = function () {
	var cur_item = this.hint_items [this.origin_elt_id];
	
	if ( cur_item.next ) {
		this._showItem ( cur_item.next );
	} else {
		if ( this.next_page_user_handler              &&
			 this.next_page_user_handler.obj          &&
			 this.next_page_user_handler.onclick_name &&
			 this.next_page_user_handler.obj [this.next_page_user_handler.onclick_name] )
		this.next_page_clicked = true;
		this.next_page_user_handler.obj [this.next_page_user_handler.onclick_name] ();
	}
}

/*private*/
trr_Hint.prototype._showPanels = function () {
	if ( !this.closebtn_shown && this.hint_shown && !this.hint_hiding ) {
		this.anim_closebtn.Start ();
		
		var cur_item = this.hint_items [this.origin_elt_id];
		
		if ( cur_item.prev ) {
			this.anim_prevbtn.Start ();
		} else if ( this.prev_page_user_handler              &&
					this.prev_page_user_handler.obj          &&
					this.prev_page_user_handler.btnonshow_name &&
					this.prev_page_user_handler.obj [this.prev_page_user_handler.btnonshow_name] ) {
			if ( this.prev_page_user_handler.obj [this.prev_page_user_handler.btnonshow_name] () )
				this.anim_prevbtn.Start ();
		}
		
		if ( cur_item.next ) {
			this.anim_nextbtn.Start ();
		} else if ( this.next_page_user_handler              &&
					this.next_page_user_handler.obj          &&
					this.next_page_user_handler.btnonshow_name &&
					this.next_page_user_handler.obj [this.next_page_user_handler.btnonshow_name] ) {
			if ( this.next_page_user_handler.obj [this.next_page_user_handler.btnonshow_name] () )
				this.anim_nextbtn.Start ();
		}
		
		this.closebtn_shown = true;
	}
}

/*private*/
trr_Hint.prototype._hidePanels = function ( speed_mul ) {
	if ( this.closebtn_shown ) {
		this.anim_closebtn.Start ( speed_mul, true );
		
		var cur_item = this.hint_items [this.origin_elt_id];
		
		if ( cur_item.prev ||
			 ( this.prev_page_user_handler              &&
			   this.prev_page_user_handler.obj          &&
			   this.prev_page_user_handler.onclick_name &&
			   this.prev_page_user_handler.obj [this.prev_page_user_handler.onclick_name] ) ) {
			this.anim_prevbtn.Start ( speed_mul, true );
		}
		
		if ( cur_item.next ||
			 ( this.next_page_user_handler              &&
			   this.next_page_user_handler.obj          &&
			   this.next_page_user_handler.onclick_name &&
			   this.next_page_user_handler.obj [this.next_page_user_handler.onclick_name] ) ) {
			this.anim_nextbtn.Start ( speed_mul, true );
		}
		
		this.closebtn_shown = false;
	}
}

trr_Hint.prototype.MouseOverBgEventHandler = function () {
	this._hidePanels ();
}

trr_Hint.prototype.MouseOverHintEventHandler = function () {
	this._showPanels ();
}

trr_Hint.prototype.MouseOverPrevBtnEventHandler = function () {
	this.hint_prevbtn_elt.style.backgroundImage = 'url(' + this.img_prevbtn_hover + ')';
	this.MouseOverHintEventHandler ();
}

trr_Hint.prototype.MouseOutPrevBtnEventHandler = function () {
	this.hint_prevbtn_elt.style.backgroundImage = 'url(' + this.img_prevbtn + ')';
}

trr_Hint.prototype.MouseOverNextBtnEventHandler = function () {
	this.hint_nextbtn_elt.style.backgroundImage = 'url(' + this.img_nextbtn_hover + ')';
	this.MouseOverHintEventHandler ();
}

trr_Hint.prototype.MouseOutNextBtnEventHandler = function () {
	this.hint_nextbtn_elt.style.backgroundImage = 'url(' + this.img_nextbtn + ')';
}

trr_Hint.prototype.animationQueueStopped = function ( speed_mul, reverse ) {
	if ( reverse ) {
		this.hint_shown  = false;
		this.hint_hiding = false;
		this.hint_elt.style.width  = '';
		this.hint_elt.style.height = '';
		this.hint_elt.innerHTML    = '';
		this.bg_fader_elt.style.width  = '0px';
		this.bg_fader_elt.style.height = '0px';
		this.SetCaption ( '' );
		
		if ( this.prev_page_clicked &&
			 ( this.prev_page_user_handler              &&
			   this.prev_page_user_handler.obj          &&
			   this.prev_page_user_handler.onhidden_name &&
			   this.prev_page_user_handler.obj [this.prev_page_user_handler.onhidden_name] ) ) {
			this.prev_page_user_handler.obj [this.prev_page_user_handler.onhidden_name] ();
		} else
		if ( this.next_page_clicked &&
			 ( this.next_page_user_handler              &&
			   this.next_page_user_handler.obj          &&
			   this.next_page_user_handler.onhidden_name &&
			   this.next_page_user_handler.obj [this.next_page_user_handler.onhidden_name] ) ) {
			this.next_page_user_handler.obj [this.next_page_user_handler.onhidden_name] ();
		}
	} else {
		this.hint_shown  = true;
	}
}
/*
 * } // end of class trr_Hint
 */
}
if ( !trr_Included ( 'tour_search' ) ) {
	trr_RegisterInclusion ( 'tour_search' );
	
	var trr_tours      = new String ();
    var trr_ar_citydep = new Array  ();
    var trr_ar_accmd   = new Array  ();
    var trr_ar_city    = new Array  ();
    var trr_ar_subcity = new Array  ();
    var trr_ar_citys   = new Array  ();
    var trr_ar_citym   = new Array  ();
    var trr_ar_cityd   = new Array  ();
    var trr_ar_cityds  = new Array  ();
    var trr_ar_citydp  = new Array  ();
    var trr_ar_dep     = new Array  ();
    var trr_ar_days    = new Array  ();
    var trr_ar_meal    = new Array  ();
    var trr_ar_star    = new Array  ();
    var trr_ar_hotel   = new Array  ();
	
	var trr_ar_resp_s  = new Array  ();
	var trr_ar_resp_l  = new Array  ();
	var trr_ar_price_currency = null;
	
	var trr_country_info_menu_link         = null;
	var trr_country_hotels_menu_link       = null;
	var trr_country_excursions_menu_link   = null;
	var trr_country_visa_menu_link         = null;
	var trr_country_photogallery_menu_link = null;
	
	var countryDataElts =
		new Array ( "trr_city[]", "trr_star[]" , "trr_hotel[]", "trr_meal[]",
					"trr_accmd" , "trr_dep"    , "trr_plusmn" , "trr_days_f",
					"trr_days_t", "trr_price_f", "trr_price_t", "trr_price_currency" );
	var srchBlockElts = ( new Array ( 'trr_depcity', 'trr_country' ) ).concat ( countryDataElts );
	
	function trr_days_f_set_ls ( eltObj, elt ) {
		eltObj.val = elt.value;
		elt.disabled = true;
	}
	
	function trr_days_f_unset_ls ( eltObj, elt ) {
		elt.value = eltObj.val;
		elt.disabled = false;
	}
	
	function trr_days_t_set_ls ( eltObj, elt ) {
		eltObj.val = elt.value;
		elt.disabled = true;
	}
	
	function trr_days_t_unset_ls ( eltObj, elt ) {
		elt.value = eltObj.val;
		elt.disabled = false;
	}
	
	function trr_price_f_set_ls ( eltObj, elt ) {
		eltObj.val = elt.value;
		elt.disabled = true;
	}
	
	function trr_price_f_unset_ls ( eltObj, elt ) {
		elt.value = eltObj.val;
		elt.disabled = false;
	}
	
	function trr_price_t_set_ls ( eltObj, elt ) {
		eltObj.val = elt.value;
		elt.disabled = true;
	}
	
	function trr_price_t_unset_ls ( eltObj, elt ) {
		elt.value = eltObj.val;
		elt.disabled = false;
	}
	
	function trr_price_currency_set_ls ( eltObj, elt ) {
		eltObj.val = elt.value;
		elt.disabled = true;
	}
	
	function trr_price_currency_unset_ls ( eltObj, elt ) {
		elt.value = eltObj.val;
		elt.disabled = false;
	}
	
	var countryDataEltsAssoc = {
					"trr_city[]"  : null,
				    "trr_star[]"  : null,
					"trr_hotel[]" : null,
					"trr_meal[]"  : null,
					"trr_accmd"   : null,
					"trr_dep"     : null,
					"trr_plusmn"  : null,
					"trr_days_f"  : { 'set_handler' : trr_days_f_set_ls , 'unset_handler' : trr_days_f_unset_ls , val : '' },
					"trr_days_t"  : { 'set_handler' : trr_days_t_set_ls , 'unset_handler' : trr_days_t_unset_ls , val : '' },
					"trr_price_f" : { 'set_handler' : trr_price_f_set_ls, 'unset_handler' : trr_price_f_unset_ls, val : '' },
					"trr_price_t" : { 'set_handler' : trr_price_t_set_ls, 'unset_handler' : trr_price_t_unset_ls, val : '' },
					"trr_price_currency" : { 'set_handler' : trr_price_currency_set_ls, 'unset_handler' : trr_price_currency_unset_ls, val : '' } };
	var srchBlockEltsAssoc = Object.concat ( { 'trr_depcity' : null, 'trr_country' : null }, countryDataEltsAssoc );
	
	var req_loadCityDep         = null;
	var req_loadCountries       = null;
	var req_loadCountryData     = null;
	var req_submitSearchData    = null;
	var req_loadHotelInfo       = null;
	var req_advanceResponse     = null;
	var req_showMealDescription = null;
	var req_showRoomDescription = null;
	
	var trr_page = '';
	var trr_directLinkVals   = new Array ();
	var trr_directLinkActive = false;
	var trr_presetParams     = null;
	
	function trr_SetCurPage ( page, additional_args ) {
		if ( page == 'index' || page == 'main' )
			trr_page == '';
		else
			trr_page = page;
		
		trr_additional_args = additional_args;
	}
	
	function trr_GetCurPage () {
		return	trr_page;
	}
	
	function trr_ParseDirectLink () {
		loc = window.location.toString ();
		addr_parts = loc.split ( "#:tour_search" );
		
		if ( addr_parts.length > 1 ) {
			dl_args = ( addr_parts [1] ).split ( '/' );
			
			if ( dl_args.length > 1 ) {
				dl_args = dl_args [1].split ( '?' );
				var cur_page = dl_args [0];
				trr_SetCurPage ( cur_page );
				dl_args = '?' + dl_args [1];
			}
			
			dl_args = dl_args.toString ();
			
			if ( dl_args.substr ( 0, 1 ) == '?' ) {
				dl_args = dl_args.substr ( 1 ).split ( '&' );
				trr_directLinkActive = true;
			} else {
				return	false;
			}
		} else {
			return	false;
		}
		
		for ( i = 0 ; i < dl_args.length ; i++ ) {
			keyVal = dl_args [i].split ( '=' );
			
			if ( keyVal.length < 2 )
				continue;
			
			var key = keyVal.shift ();
			var val = keyVal.join ( '=' );
			
			if ( trr_directLinkVals [key] != null )
				trr_directLinkVals [key] = new Array ( trr_directLinkVals [key], trr_Url.UrlDecode ( val ) );
			else
				trr_directLinkVals [key] = trr_Url.UrlDecode ( val );
		}
		
		return	true;
	}
	
	function trr_LoadFromDirectLink ( eltIds ) {
		switch ( typeof ( eltIds ) ) {
		case 'string':
			processElt ( eltIds );
			break;
		case 'object':	// массив
			for ( var key in eltIds )
				processElt ( eltIds [key] );
			break;
		}
		
		function processElt ( eltId ) {
			if ( elt = document.getElementById ( eltId ) ) {
				var dlink_vals = null;
				
				if ( trr_directLinkVals [eltId] != null )
					dlink_vals = trr_directLinkVals [eltId];
				else if ( trr_presetParams != null && trr_presetParams [eltId] != null )
					dlink_vals = trr_presetParams [eltId];
				else
					return;
				
				switch ( elt.type ) {
				case 'select-multiple':
				case 'select-one':
					if ( dlink_vals != null ) {
						var val = dlink_vals;
						
						if ( typeof ( val ) == 'string' )
							val = new Array ( val );
						
						while ( val.length > 0 ) {
							var cur_val = val.shift ();
							
							for ( i = 0 ; i < elt.options.length ; i++ ) {
								if ( elt.options [i].value == cur_val ) {
									if ( elt.options.selectedIndex == 0 )
										elt.options.selectedIndex = i;
									else
										elt.options [i].selected = true;
								}
							}
						}
					}
					
					break;
				case 'text':
					if ( dlink_vals != null )
						elt.value = trr_directLinkVals [eltId];
					
					break;
				}
			}
		}
	}
	
	function trr_GenDirectLink ( eltIds, add_args ) {
		loc = window.location.toString ();
		addr_parts = loc.split ( "#:tour_search" );
		
		if ( addr_parts.length > 1 )
			orig_addr = addr_parts [0];
		else
			orig_addr = loc;
		
		var direct_addr = '';
		
		if ( '' != ( cur_page = trr_GetCurPage () ) )
			direct_addr += '/' + cur_page;
		
		switch ( typeof ( eltIds ) ) {
		case 'string':
			processElt ( eltIds, '?' );
			break;
		case 'object':	// массив
			firstElt = eltIds.shift ();
			processElt ( firstElt, '?', true );
			
			for ( var key in eltIds )
				processElt ( eltIds [key], '&', false );
			
			eltIds.unshift ( firstElt );
			break;
		}
		
		function processElt ( eltId, argPrefix, dont_check ) {
			if ( elt = document.getElementById ( eltId ) ) {
				switch ( elt.type ) {
				case 'select-multiple':
				case 'select-one':
					var dd_args = trr_MakeUrlArgFromDropDownVal ( eltId, eltId, '', true );
					
					if ( dd_args.length > 0 )
						direct_addr += argPrefix + dd_args;
					
					break;
				case 'text':
					if ( dont_check || ( elt.value.trim () ).length > 0 )
						direct_addr += argPrefix + eltId + '=' + trr_Url.UrlEncode ( elt.value );
					
					break;
				}
			}
		}
		
		if ( direct_addr.length > 0 && add_args && add_args.length > 0 )
			direct_addr += '&' + add_args;
		else if ( add_args && add_args.length > 0 )
			direct_addr  = '?' + add_args;
		
		window.location = orig_addr + "#:tour_search" + direct_addr;
	}
	
	function trr_RequestRemoteScript ( url, scriptLoadedCallback, async_data ) {
		return	trr_AjaxClient.SendGetRequest ( url, true, scriptLoadedCallback, async_data );
	}
	
	function trr_ExecScriptXml ( xml ) {
		var nd = xml.getElementsByTagName ( 'data' );
		
		if ( nd.length != 0 )
			eval ( nd [0].childNodes [0].nodeValue );
	}
	
	function trr_GetDropdownVal ( ddName, defaultVal ) {
		var dd = document.getElementById ( ddName );
		
		if ( dd && dd.length != 0 && dd.selectedIndex != -1 )
			return	dd.options [dd.selectedIndex].value;
		else
			return	defaultVal;
	}
	
	function trr_MakeUrlArgFromDropDownVal ( paramName, ddName, defaultVal, urlFullEncode ) {
		var dd = document.getElementById ( ddName );
		
		if ( !dd || dd.length == 0 || dd.selectedIndex == -1 )
			return	defaultVal;
		
        var str = new String ();
		cmb_opts = document.getElementById ( ddName ).options;
		
		var sep = '';
		
		urlFullEncode = urlFullEncode != null ? urlFullEncode : false;
		
		for ( i = 1 ; i < cmb_opts.length ; i++ )
			if ( cmb_opts [i].selected ) {
				str = str + sep + paramName + '=' + ( urlFullEncode ? trr_Url.UrlEncode ( cmb_opts [i].value ) : trr_UrlEncode ( cmb_opts [i].value ) );
				sep = '&';
			}
		
		return	str;
	}
	
	function trr_GetTextboxVal ( txtName, defaultVal ) {
		var txt = document.getElementById ( txtName );
		
		if ( txt )
			return	txt.value.trim ();
		else
			return	defaultVal;
	}
	
	function trr_GetCheckboxVal ( chkName, defaultVal ) {
		var chk = document.getElementById ( chkName );
		
		if ( chk )
			return	chk.checked ? 1 : 0;
		else
			return	defaultVal;
	}
	
	function trr_GoToResultsPageNo ( page, hotel_name ) {
		trr_SubmitSearchData ( null, page, hotel_name );
	}
	
	function trr_GoToHotelToursPageNo ( page, hotel_name ) {
		trr_GetHotelTours ( null, page, hotel_name );
	}
	
	function trr_GoToResultsPageNoByParams ( params, page ) {
		trr_SubmitSearchData ( params, page );
	}
	
	function trr_GoToHotelToursPageNoByParams ( params, page ) {
		trr_GetHotelTours ( params, page );
	}
	
	function trr_SubmitSearchDataNewWindow ( params, page, hotel_name ) {
		if ( params == null ) {
			var qChild = trr_GetAgeQueryPart ();
			
			var params =
				'trr_depcity='  + trr_DepCity        () +
				'&trr_country=' + trr_CountryIndex   ( null ) +
				
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_city[]' , 'trr_city[]' , '', true ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_star[]' , 'trr_star[]' , '', true ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_hotel[]', 'trr_hotel[]', '', true ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_meal[]' , 'trr_meal[]' , '', true ) +
				
				'&trr_dep='     + trr_GetDropdownVal ( 'trr_dep'    , '' ) +
				'&trr_plusmn='  + trr_GetTextboxVal  ( 'trr_plusmn' , '' ) +
				'&trr_days_f='  + trr_GetDropdownVal ( 'trr_days_f' , '' ) +
				'&trr_days_t='  + trr_GetDropdownVal ( 'trr_days_t' , '' ) +
				'&trr_accmd='   + trr_GetDropdownVal ( 'trr_accmd'  , '' ) +
				qChild +
				'&trr_price_f=' + trr_UrlEncode      ( trr_GetTextboxVal  ( 'trr_price_f', '' ) ) +
				'&trr_price_t=' + trr_UrlEncode      ( trr_GetTextboxVal  ( 'trr_price_t', '' ) ) +
				'&trr_price_currency=' + trr_GetDropdownVal ( 'trr_price_currency', ''  );/* +
				'&trr_full_search='    + trr_GetCheckboxVal ( 'trr_full_search'   , '0' );*/
		}
		
		if ( hotel_name != null ) {
			params = params.replace ( /trr_hotel\[\d*\]=[^&]*/gi, '' );
			params = params.replace ( /&{2,}/, '&' );
			params += '&trr_hotel[]=' + trr_UrlEncode ( hotel_name );
		}
		
		if ( page != null )
			params += '&page=' + page;
		
		params += '&querydate=' + Date ();	// делаем запрос уникальным, чтобы избежать кеширования
		url = "search_results.php#:tour_search/tours?" + params;		
		
		mealWnd = window.open ( url, 'TourSearch', '' );
		mealWnd.focus ();
	}
	
	function trr_SubmitSearchData ( params, page, hotel_name ) {
		if ( params == null ) {
			var qChild = trr_GetAgeQueryPart ();
			
			var params =
				'trr_depcity='  + trr_DepCity        () +
				'&trr_country=' + trr_CountryIndex   ( null ) +
				
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_city[]' , 'trr_city[]' , '' ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_star[]' , 'trr_star[]' , '' ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_hotel[]', 'trr_hotel[]', '' ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_meal[]' , 'trr_meal[]' , '' ) +
				
				'&trr_dep='     + trr_GetDropdownVal ( 'trr_dep'    , '' ) +
				'&trr_plusmn='  + trr_GetTextboxVal  ( 'trr_plusmn' , '' ) +
				'&trr_days_f='  + trr_GetDropdownVal ( 'trr_days_f' , '' ) +
				'&trr_days_t='  + trr_GetDropdownVal ( 'trr_days_t' , '' ) +
				'&trr_accmd='   + trr_GetDropdownVal ( 'trr_accmd'  , '' ) +
				qChild +
				'&trr_price_f=' + trr_UrlEncode      ( trr_GetTextboxVal  ( 'trr_price_f', '' ) ) +
				'&trr_price_t=' + trr_UrlEncode      ( trr_GetTextboxVal  ( 'trr_price_t', '' ) ) +
				'&trr_price_currency=' + trr_GetDropdownVal ( 'trr_price_currency', ''  );/* +
				'&trr_full_search='    + trr_GetCheckboxVal ( 'trr_full_search'   , '0' );*/
		}
		
		if ( hotel_name != null ) {
			params = params.replace ( /trr_hotel\[\d*\]=[^&]*/gi, '' );
			params = params.replace ( /&{2,}/, '&' );
			params += '&trr_hotel[]=' + trr_UrlEncode ( hotel_name );
		}
		
		if ( page != null )
			params += '&page=' + page;
		
		params += '&querydate=' + Date ();	// делаем запрос уникальным, чтобы избежать кеширования
		
		if ( targetContainer = document.getElementById ( 'tour_search_content' ) )
			targetContainer.innerHTML = '<div width="100%" align="center"><i>Загрузка...</i><br /><img src="http://www.sitravel.ru/modules/tury.ru/common/img/loading.gif"></div>';
		
		url = "http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/tours";
		
		if ( req_submitSearchData != null )
			req_submitSearchData.abort ();
		
		req_submitSearchData = trr_AjaxClient.SendPostRequest ( url, params, true, trr_SearchRequestCompleted );
	}
	
	function trr_GetHotelTours ( params, page, hotel_name ) {
		if ( ( trr_MakeUrlArgFromDropDownVal ( 'trr_hotel[]', 'trr_hotel[]', '' ) ).length == 0 ) {
			if ( targetContainer = document.getElementById ( 'hotel_tours_result' ) )
				targetContainer.innerHTML = 'По Вашему запросу туров не найдено.';
			
			return;
		}
		
		if ( params == null ) {
			var qChild = trr_GetAgeQueryPart ();
			
			var params =
				'trr_depcity='  + trr_DepCity        () +
				'&trr_country=' + trr_CountryIndex   ( null ) +
				
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_city[]' , 'trr_city[]' , '' ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_star[]' , 'trr_star[]' , '' ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_hotel[]', 'trr_hotel[]', '' ) +
				'&' + trr_MakeUrlArgFromDropDownVal ( 'trr_meal[]' , 'trr_meal[]' , '' ) +
				
				'&trr_dep='     + trr_GetDropdownVal ( 'trr_dep'    , '' ) +
				'&trr_plusmn='  + trr_GetTextboxVal  ( 'trr_plusmn' , '' ) +
				'&trr_days_f='  + trr_GetDropdownVal ( 'trr_days_f' , '' ) +
				'&trr_days_t='  + trr_GetDropdownVal ( 'trr_days_t' , '' ) +
				'&trr_accmd='   + trr_GetDropdownVal ( 'trr_accmd'  , '' ) +
				qChild +
				'&trr_price_f=' + trr_UrlEncode      ( trr_GetTextboxVal  ( 'trr_price_f', '' ) ) +
				'&trr_price_t=' + trr_UrlEncode      ( trr_GetTextboxVal  ( 'trr_price_t', '' ) ) +
				'&trr_price_currency=' + trr_GetDropdownVal ( 'trr_price_currency', ''  );/* +
				'&trr_full_search='    + trr_GetCheckboxVal ( 'trr_full_search'   , '0' );*/
		}
		
		if ( hotel_name != null ) {
			params = params.replace ( /trr_hotel\[\d*\]=[^&]*/gi, '' );
			params = params.replace ( /&{2,}/, '&' );
			params += '&trr_hotel[]=' + trr_UrlEncode ( hotel_name );
		}
		
		if ( page != null )
			params += '&page=' + page;
		
		params += '&result=hotel_tours';
		params += '&querydate=' + Date ();	// делаем запрос уникальным, чтобы избежать кеширования
		
		if ( targetContainer = document.getElementById ( 'hotel_tours_result' ) )
			targetContainer.innerHTML = '<div width="100%" align="center"><i>Загрузка...</i><br /><img src="http://www.sitravel.ru/modules/tury.ru/common/img/loading.gif"></div>';
		
		url = "http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/tours";
		
		if ( req_submitSearchData != null )
			req_submitSearchData.abort ();
		
		req_submitSearchData = trr_AjaxClient.SendPostRequest ( url, params, true, trr_GetHotelToursCompleted );
	}
	
	function trr_UrlEncode ( urlpart ) {
		return	urlpart.replace ( /&/g, '%26' );
	}
	
	function trr_GetAgeQueryPart () {
		var cmbQ;
		
		if ( cmbQ = document.getElementById ( "trr_accmd" ) ) {
			var sAccmd = cmbQ.options [cmbQ.selectedIndex].value;
			var aAccmd = sAccmd.split ( "+" );
			var iChilds = 0;
			var qChild = '';
			
			if ( aAccmd.length == 2 ) {
				var iMen    = aAccmd [0];
				var iChilds = aAccmd [1];
				var iCM = aAccmd [0] + '%2B' + aAccmd [1];
				
				for ( i = 0 ; i < iChilds ; i++ ) {
					qChild += '&age[' + sAccmd + '][]=' + trr_GetTextboxVal ( 'trr_age_' + i, '' );
				}
			}
			
			return	qChild;
		} else {
			return	'';
		}
	}
	
	function trr_GetHotelToursCompleted ( text, xml ) {
		trr_SetCurPage ( 'hotel_tours' );
		
		if ( trr_directLinkVals ['hotel_id'] )
			trr_GenDirectLink ( srchBlockElts, 'hotel_id=' + trr_directLinkVals ['hotel_id'] );
		else
			trr_GenDirectLink ( srchBlockElts );
		
		req_submitSearchData = null;
		var nd = xml.getElementsByTagName ( 'data' );
		
		if ( nd.length != 0 ) {
			var targetContainer = document.getElementById ( 'hotel_tours_result' );
			
			if ( targetContainer )
				targetContainer.innerHTML = nd [0].childNodes [0].nodeValue;
		}
	}
	
	function trr_SearchRequestCompleted ( text, xml ) {
		trr_SetCurPage ( 'tours' );
		trr_GenDirectLink ( srchBlockElts );
		req_submitSearchData = null;
		var nd = xml.getElementsByTagName ( 'data' );
		
		if ( nd.length != 0 ) {
			var targetContainer = document.getElementById ( 'tour_search_content' );
			
			if ( targetContainer )
				targetContainer.innerHTML = nd [0].childNodes [0].nodeValue;
		}
	}
	
	function trr_LoadHotelInfo ( hotel_id, next_func ) {
		trr_SetCurPage ( 'hotel' );
		trr_GenDirectLink ( srchBlockElts, 'hotel_id=' + hotel_id );
		
		if ( targetContainer = document.getElementById ( 'tour_search_content' ) ) {
			targetContainer.innerHTML = '<div width="100%" align="center"><i>Загрузка...</i><br /><img src="http://www.sitravel.ru/modules/tury.ru/common/img/loading.gif"></div>';
		}
		
		url = "http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/hotel?id=" + hotel_id + '&trr_depcity=' + trr_DepCity () + '&trr_country=' + trr_CountryIndex ( null ) + '&trr_dep=' + trr_GetDropdownVal ( 'trr_dep', '' ) + '&trr_accmd=' + trr_GetDropdownVal ( 'trr_accmd', '' ) + '&trr_price_currency=' + trr_GetDropdownVal ( 'trr_price_currency', '' ) + '&querydate=' + Date ();
		
		if ( req_loadHotelInfo != null )
			req_loadHotelInfo.abort ();
		
		req_loadHotelInfo = trr_AjaxClient.SendGetRequest ( url, true, trr_LoadHotelInfoCompleted, next_func );
	}
	
	function trr_LoadHotelInfoCompleted ( text, xml, next_func ) {
		req_loadHotelInfo = null;
		var nd = xml.getElementsByTagName ( 'data' );
		
		if ( nd.length != 0 ) {
			var targetContainer = document.getElementById ( 'tour_search_content' );
			
			if ( targetContainer )
				targetContainer.innerHTML = nd [0].childNodes [0].nodeValue;
		}
		
		if ( ( nd = xml.getElementsByTagName ( 'script' ) ).length != 0 )
			eval ( nd [0].childNodes [0].nodeValue );
		
		var hotel_tour_search_dest_elt   = document.getElementById ( 'hotel_tour_search_dest'   );
		var hotel_tour_search_loader_elt = document.getElementById ( 'hotel_tour_search_loader' );
		hotel_tour_search_loader_elt.style.display = 'block';
		hotel_tour_search_dest_elt.style.display   = 'block';
		hotel_tour_search_dest_elt.appendChild ( hotel_tour_search_loader_elt );
		
		if ( next_func )
			next_func ();
	}
	
	function trr_AdvanceResponse ( resp_c_id, resp_id ) {
		if ( targetContainer = document.getElementById ( resp_c_id ) ) {
			trr_ar_resp_s [resp_c_id] = targetContainer.innerHTML;
			
			if ( trr_ar_resp_l [resp_c_id] == null ) {
				targetContainer.innerHTML = '<div width="100%" align="center"><i>Загрузка...</i><br /><img src="http://www.sitravel.ru/modules/tury.ru/common/img/loading.gif"></div>';
				
				url = "http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/hotelresp?id=" + resp_id + '&querydate=' + Date ();
				
				if ( req_advanceResponse != null )
					req_advanceResponse.abort ();
				
				req_advanceResponse = trr_AjaxClient.SendGetRequest ( url, true, trr_AdvanceResponseCompleted, resp_c_id );
			} else {
				targetContainer.innerHTML = trr_ar_resp_l [resp_c_id];
			}
		}
	}
	
	function trr_AdvanceResponseCompleted ( text, xml, resp_c_id ) {
		req_advanceResponse = null;
		var nd = xml.getElementsByTagName ( 'data' );
		
		if ( nd.length != 0 ) {
			var targetContainer = document.getElementById ( resp_c_id );
			
			if ( targetContainer ) {
				var resp_html = nd [0].childNodes [0].nodeValue;
				trr_ar_resp_l [resp_c_id] = resp_html;
				targetContainer.innerHTML = resp_html;
			}
		}
	}
	
	function trr_HideResponse ( resp_c_id ) {
		if ( targetContainer = document.getElementById ( resp_c_id ) ) {
			if ( trr_ar_resp_s [resp_c_id] != null )
				targetContainer.innerHTML = trr_ar_resp_s [resp_c_id];
		}
	}
	
	function trr_ShowMealDescription ( mealId ) {
		var params =
			'id=' + mealId +
			'&querydate='  + Date ();	// делаем запрос уникальным, чтобы избежать кеширования
		
		mealWnd = window.open  ( '', 'MealInfo', 'directories=no,menubar=no,resizable=no,scrollbars=no,location=no,width=400,height=200' );
		mealWnd.document.write ( '<table style="width: 100%; height: 100%;"><tr><td id="content" align="center">' );
		mealWnd.document.write ( '</td></tr></table>' );
		mealWnd.focus ();
		
		url = "http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/meal";
		
		if ( req_showMealDescription != null )
			req_showMealDescription.abort ();
		
		req_showMealDescription = trr_AjaxClient.SendPostRequest ( url, params, true, trr_MealDescriptionObtained, mealWnd );
	}
	
	function trr_MealDescriptionObtained ( text, xml, mealWnd ) {
		req_showMealDescription = null;
		mealWnd.document.title = 'Питание';
		var nd = xml.getElementsByTagName ( 'data' );
		
		if ( nd.length != 0 ) {
			var targetContainer = mealWnd.document.getElementById ( 'content' );
			
			if ( targetContainer )
				targetContainer.innerHTML = nd [0].childNodes [0].nodeValue;
		}
	}
	
	function trr_ShowRoomDescription ( roomId ) {
		var params =
			'id=' + roomId +
			'&querydate='  + Date ();	// делаем запрос уникальным, чтобы избежать кеширования
		
		roomWnd = window.open  ( '', 'RTypeInfo', 'directories=no,menubar=no,resizable=no,scrollbars=no,location=no,width=400,height=200' );
		roomWnd.document.write ( '<table style="width: 100%; height: 100%;"><tr><td id="content" align="center">' );
		roomWnd.document.write ( '</td></tr></table>' );
		roomWnd.focus ();
		
		url = "http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/rtype";
		
		if ( req_showRoomDescription != null )
			req_showRoomDescription.abort ();
		
		req_showRoomDescription = trr_AjaxClient.SendPostRequest ( url, params, true, trr_RoomDescriptionObtained, roomWnd );
	}
	
	function trr_RoomDescriptionObtained ( text, xml, roomWnd ) {
		req_showRoomDescription = null;
		roomWnd.document.title = 'Номер';
		var nd = xml.getElementsByTagName ( 'data' );
		
		if ( nd.length != 0 ) {
			var targetContainer = roomWnd.document.getElementById ( 'content' );
			
			if ( targetContainer )
				targetContainer.innerHTML = nd [0].childNodes [0].nodeValue;
		}
	}
	
    function trr_DepCity () {
        if ( dc = document.getElementById ( "trr_depcity" ) )
			return	dc.options[dc.selectedIndex].value;
        else
            return	"";
    }
	
	function trr_SetElementsLoadingState ( eltIds, loadingString ) {
		if ( !loadingString )
			loadingString = 'загрузка...';
		
		switch ( typeof ( eltIds ) ) {
		case 'string':
			processElt ( eltIds );
			break;
		case 'object':	// массив
			for ( var key in eltIds )
				processElt ( eltIds [key] );
			
			break;
		}
		
		function processElt ( eltId ) {
			if ( elt = document.getElementById ( eltId ) ) {
				elt.disabled = true;
				
				switch ( elt.type ) {
				case 'select-one':
					while ( elt.options.length > 0 )
						elt.remove ( 0 );
					
					elt.options.add ( new Option ( loadingString, '' ) );
					break;
				case 'text':
					elt.value = loadingString;
					break;
				}
			}
		}
	}
	
	function trr_SetElementsLoadingStateAssoc ( elts, loadingString ) {
		if ( !loadingString )
			loadingString = 'загрузка...';
		
		switch ( typeof ( elts ) ) {
		case 'string':
			processElt ( elts );
			break;
		case 'object':	// массив
			for ( var key in elts )
				processElt ( key, elts [key] );
			
			break;
		}
		
		function processElt ( eltId, eltObj ) {
			if ( elt = document.getElementById ( eltId ) ) {
				if ( eltObj != null ) {
					eltObj.set_handler ( eltObj, elt );
				} else {
					elt.disabled = true;
					
					switch ( elt.type ) {
					case 'select-one':
						while ( elt.options.length > 0 )
							elt.remove ( 0 );
						
						elt.options.add ( new Option ( loadingString, '' ) );
						
						break;
					case 'text':
						elt.value = loadingString;
						break;
					}
				}
			}
		}
	}
	
	function trr_UnsetElementsLoadingState ( eltIds ) {
		switch ( typeof ( eltIds ) ) {
		case 'string':
			processElt ( eltIds );
			break;
		case 'object':	// массив
			for ( var key in eltIds )
				processElt ( eltIds [key] );
			
			break;
		}
		
		function processElt ( eltId ) {
			if ( elt = document.getElementById ( eltId ) ) {
				switch ( elt.type ) {
				case 'select-one':
					elt.options.length = 0;
					break;
				case 'text':
					elt.value = '';
					break;
				}
				
				elt.disabled = false;
			}
		}
	}
	
	function trr_UnsetElementsLoadingStateAssoc ( elts ) {
		switch ( typeof ( elts ) ) {
		case 'string':
			processElt ( elts );
			break;
		case 'object':	// массив
			for ( var key in elts )
				processElt ( key, elts [key] );
			
			break;
		}
		
		function processElt ( eltId, eltObj ) {
			if ( elt = document.getElementById ( eltId ) ) {
				if ( eltObj != null ) {
					eltObj.unset_handler ( eltObj, elt );
				} else {
					switch ( elt.type ) {
					case 'select-one':
						elt.options.length = 0;
						break;
					case 'text':
						elt.value = '';
						break;
					}
					
					elt.disabled = false;
				}
			}
		}
	}
	
	function trr_InitSearchBlock ( presetParams ) {
		if ( presetParams != null )
			trr_presetParams = presetParams;
		
		if ( trr_ParseDirectLink () || trr_presetParams != null ) {
			trr_LoadCityDep ( trr_DirectLinkCityDepLoaded );
		} else {
			trr_LoadCityDep ();
		}
	}
	
	function trr_DirectLinkCityDepLoaded () {
		trr_LoadFromDirectLink ( 'trr_depcity' );
		trr_LoadCountries ( trr_DirectLinkCountriesLoaded );
	}
	
	function trr_DirectLinkCountriesLoaded () {
		trr_LoadFromDirectLink ( 'trr_country' );
		trr_LoadCountryData ( trr_DirectLinkCountryDataLoaded );
	}
	
	function trr_DirectLinkCountryDataLoaded () {
		trr_LoadFromDirectLink ( countryDataElts );
		LoadQAge ();
		trr_LoadFromDirectLink ( srchBlockElts );
		trr_GenDirectLink ( srchBlockElts );
		
		var cur_page = trr_GetCurPage ();
		
		switch ( cur_page ) {
		case 'tours':
			trr_SubmitSearchData ();
			break;
		case 'hotel':
			if ( trr_directLinkVals ['hotel_id'] )
				trr_LoadHotelInfo ( trr_directLinkVals ['hotel_id'] );
			
			break;
		case 'hotel_tours':
			if ( trr_directLinkVals ['hotel_id'] )
				trr_LoadHotelInfo ( trr_directLinkVals ['hotel_id'], trr_GetHotelTours );
			
			break;
		case '':
		default:
			// do nothing
			break;
		}
	}
	
    function trr_LoadCityDep ( next_func ) {
		trr_SetElementsLoadingState ( 'trr_depcity' );
		trr_SetElementsLoadingState ( 'trr_country' );
		trr_SetElementsLoadingState ( countryDataElts, ' ' );
		
		if ( req_loadCityDep != null )
			req_loadCityDep.abort ();
		
		req_loadCityDep = trr_RequestRemoteScript ( "http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/citydeplist" + '?format=xml' + '&querydate=' + Date (), trr_LoadCityDepCompleted, next_func );
    }
	
	function trr_LoadCityDepCompleted ( text, xml, next_func ) {
		req_loadCityDep = null;
		trr_UnsetElementsLoadingState ( 'trr_depcity' );
		trr_ExecScriptXml ( xml );
		trr_GenDirectLink ( srchBlockElts );
		
		if ( next_func )
			next_func ();
		else
			trr_LoadCountries ();
	}
	
    function trr_LoadCountries ( next_func ) {
		var trr_country = document.getElementById ( 'trr_country' );
		
        if ( trr_country ) {
            if ( trr_country.options != null ) {
                var depCity = trr_DepCity ();
				trr_SetElementsLoadingState ( 'trr_country' );
				trr_SetElementsLoadingStateAssoc ( countryDataEltsAssoc, ' ' );
				
				if ( req_loadCountries != null )
					req_loadCountries.abort ();
				
				req_loadCountries = trr_RequestRemoteScript ( "http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/countrylist?citydep=" + depCity + '&format=xml' + '&querydate=' + Date (), trr_LoadCountriesCompleted, next_func );
            } else {
                trr_LoadCountryData ();
            }
        } else {
            trr_LoadCountryData ();
        }
    }
	
	function trr_LoadCountriesCompleted ( text, xml, next_func ) {
		req_loadCountries = null;
		trr_UnsetElementsLoadingState ( 'trr_country' );
		
		trr_ExecScriptXml ( xml );
		trr_GenDirectLink ( srchBlockElts );
		
		if ( next_func )
			next_func ();
	}
	
	function trr_CountryIndex ( selIdx ) {
		var trr_country = document.getElementById ( 'trr_country' );
		
		if ( trr_country && trr_country.options ) {
			if ( selIdx )
				selIdx.val = trr_country.selectedIndex;
			
			return	trr_country.options [trr_country.selectedIndex].value;
		}
	}
	
	function trr_CountryName ( selIdx ) {
		var trr_country = document.getElementById ( 'trr_country' );
		
		if ( trr_country && trr_country.options ) {
			if ( selIdx )
				selIdx.val = trr_country.selectedIndex;
			
			return	trr_country.options [trr_country.selectedIndex].text;
		}
	}
	
    function trr_LoadCountryData ( next_func ) {
		var selIdx = {val:0};
        var trr_country_index = trr_CountryIndex ( selIdx );
        var trr_country_name  = trr_CountryName  ();
		
        if ( trr_country_index != "" && selIdx.val != 0 ) {
			trr_SetElementsLoadingStateAssoc ( countryDataEltsAssoc );
			//trr_SetElementsLoadingState ( countryDataElts );
            var sCurCityDep = trr_DepCity ();
			var dvAge = document.getElementById ( "trr_age" );
			dvAge.style.display = "none";
			
			var main_caption_elt = document.getElementById ( 'main_caption' );
			
			if ( main_caption_elt ) {
				main_caption_elt.innerHTML = trr_country_name;
			}
			
			if ( req_loadCountryData != null )
				req_loadCountryData.abort ();
			
			req_loadCountryData = trr_RequestRemoteScript ( 'http://www.sitravel.ru/modules/tury.ru/tour_search/wsclient.php/qdata?citydep=' + sCurCityDep + '&iCountry=' + trr_country_index + '&format=xml' + '&querydate=' + Date (), trr_LoadCountryDataCompleted, next_func );
        }
    }
	
	function trr_LoadCountryDataCompleted ( text, xml, next_func ) {
		req_loadCountryData = null;
		trr_UnsetElementsLoadingStateAssoc ( countryDataEltsAssoc );
		trr_ExecScriptXml ( xml );
		trr_Filter ();
		trr_GenDirectLink ( srchBlockElts );
		
		if ( window.trr_Hotels )
			window.trr_Hotels.trr_InitHotelsBlock ();
		
		if ( window.trr_CountryInfo )
			window.trr_CountryInfo.trr_InitCountryInfoBlock ();
		
		if ( window.trr_PhotoGallery ) {
			trr_PhotoGallery.trr_photoGalleryParams ['page'] = 1;
			window.trr_PhotoGallery.trr_InitPhotoGalleryBlock ();
		}
		
		if ( window.trr_Excursions )
			window.trr_Excursions.trr_InitExcursionInfoBlock ();
		
		trr_InitCountryHorzMenuLinks ();
		
		if ( next_func )
			next_func ();
	}
	
	function trr_InitCountryHorzMenuLinks () {
		if ( !trr_country_info_menu_link )
			trr_country_info_menu_link = document.getElementById ( 'country_info_menu_link' );
		
		if ( !trr_country_hotels_menu_link )
			trr_country_hotels_menu_link = document.getElementById ( 'country_hotels_menu_link' );
		
		if ( !trr_country_excursions_menu_link )
			trr_country_excursions_menu_link = document.getElementById ( 'country_excursions_menu_link' );
		
		if ( !trr_country_visa_menu_link )
			trr_country_visa_menu_link = document.getElementById ( 'country_visa_menu_link' );
		
		if ( !trr_country_photogallery_menu_link )
			trr_country_photogallery_menu_link = document.getElementById ( 'country_photogallery_menu_link' );
		
		var sCurCityDep = trr_DepCity ();
		var selIdx = {val:0};
        var trr_country_index = trr_CountryIndex ( selIdx );
		
		if ( trr_country_info_menu_link )
			trr_country_info_menu_link.href = 'http://www.sitravel.ru/country_info.php#:tour_search?trr_depcity=' + sCurCityDep + '&trr_country=' + trr_country_index;
		
		if ( trr_country_hotels_menu_link )
			trr_country_hotels_menu_link.href = 'http://www.sitravel.ru/country_hotels.php#:tour_search?trr_depcity=' + sCurCityDep + '&trr_country=' + trr_country_index;
		
		if ( trr_country_excursions_menu_link )
			trr_country_excursions_menu_link.href = 'http://www.sitravel.ru/country_excursions.php#:tour_search?trr_depcity=' + sCurCityDep + '&trr_country=' + trr_country_index;
		
		if ( trr_country_visa_menu_link )
			trr_country_visa_menu_link.href = 'http://www.sitravel.ru/country_visa.php#:tour_search?trr_depcity=' + sCurCityDep + '&trr_country=' + trr_country_index;
		
		if ( trr_country_photogallery_menu_link )
			trr_country_photogallery_menu_link.href = 'http://www.sitravel.ru/country_photogallery.php#:tour_search?trr_depcity=' + sCurCityDep + '&trr_country=' + trr_country_index;
	}

    function trr_LoadArray ( ar, data ) {
        if ( ar == "accmd"   ) { trr_ar_accmd   = data.split( ',' ); }
        if ( ar == "city"    ) { trr_ar_city    = data.split( ',' ); }
        if ( ar == "subcity" ) { trr_ar_subcity = data.split( ',' ); }
        if ( ar == "citys"   ) { trr_ar_citys   = data.split( ',' ); }
        if ( ar == "citym"   ) { trr_ar_citym   = data.split( ',' ); }
        if ( ar == "cityd"   ) { trr_ar_cityd   = data.split( ',' ); }
        if ( ar == "cityds"  ) { trr_ar_cityds  = data.split( ',' ); }
        if ( ar == "dep"     ) { trr_ar_dep     = data.split( ',' ); }
        if ( ar == "days"    ) { trr_ar_days    = data.split( ',' ); }
        if ( ar == "meal"    ) { trr_ar_meal    = data.split( ',' ); }
        if ( ar == "star"    ) { trr_ar_star    = data.split( ',' ); }
        if ( ar == "hotel"   ) { trr_ar_hotel   = data.split( ',' ); }
        if ( ar == "tours"   ) { trr_tours      = data; }
    }
	
    function trr_Filter () {
        trr_FilterAccmd ();
        trr_FilterCity  ();
        trr_FilterStar  ();
        trr_FilterHotel ();
        trr_FilterMeal  ();
        trr_FilterDeps  ();
        trr_FilterDays  ();
		
        if ( tcnt = document.getElementById ( "trr_tcount" ) )
            tcnt.innerHTML = trr_tours;
		
        LoadFirstVals ();
		
        if ( cmbCurrency = document.getElementById ( "trr_price_currency" ) ) {
            cmbCurrency.options.length = 3;
            cmbCurrency.options[0].value = "USD";
            cmbCurrency.options[0].text = "$";
            cmbCurrency.options[1].value = "EUR";
            cmbCurrency.options[1].text = "Euro";
            cmbCurrency.options[2].value = "RUB";
            cmbCurrency.options[2].text = "Руб.";
			
			if ( trr_ar_price_currency ) {
				for ( var i = 0 ;  i < cmbCurrency.options.length ; i++ ) {
					if ( trr_ar_price_currency == cmbCurrency.options [i] )
						cmbCurrency.selectedIndex = i;
				}
			} else {
				cmbCurrency.selectedIndex = 2;
			}
        }
    }
	
    function LoadFirstVals () {
        var ar_one_line = new Array ( "trr_city[]", "trr_hotel[]", "trr_star[]", "trr_meal[]", "trr_days_f", "trr_days_t" );
		
        for ( i = 0 ; i < ar_one_line.length ; i++ ) {
			if ( cmb = document.getElementById ( ar_one_line [i] ) )
                if ( cmb.options.length == 2 )
                    cmb.options.selectedIndex = 1;
        }
		
        if ( cmb = document.getElementById ( "trr_dep" ) )
            cmb.options.selectedIndex = 1;
    }

    function trr_SelectedVals ( cmb_name ) {
        var str = new String ();
		
		cmb_opts = document.getElementById ( cmb_name ).options;
		
		for ( i = 1 ; i < cmb_opts.length ; i++ )
			if ( cmb_opts [i].selected )
				str = str + '(' + cmb_opts [i].value + ')';
		
		return	str;
    }

    function trr_FilterAccmd () {
        if ( cmbQ = document.getElementById ( "trr_accmd" ) ) {
            cmbQ.options.length = trr_ar_accmd.length + 1;
			
            for ( i = 0; i < trr_ar_accmd.length; i++ ) {
                ar = trr_ar_accmd [i].split ( ";" );
                var sAccmd = ar [0];
                var aAccmd = sAccmd.split ( "+" );
				
                if ( aAccmd.length == 2 ) {
                    sAccmd = aAccmd [0] + " взр.+" + aAccmd [1] + " реб.";
                    cmbQ.options [i + 1] = new Option ( sAccmd, ar[0] );
                } else {
                    cmbQ.options [i + 1] = new Option ( sAccmd + " взр.", ar [0] );
                }
				
                if ( ar [0] == "2" )
					cmbQ.selectedIndex = i + 1;
            }
			
            if ( cmbQ.options.length == 2 ) {
				cmbQ.selectedIndex = 1;
			}
        }
    }
	
    function LoadQAge () {
        var cmbQ  = document.getElementById ( "trr_accmd" );
        var dvAge = document.getElementById ( "trr_age"   );
        var sOut  = "";
        dvAge.innerHTML = "";
		
        if ( cmbQ.selectedIndex > 0 ) {
            var sAccmd = cmbQ.options [cmbQ.selectedIndex].value;
            var aAccmd = sAccmd.split ( "+" );
			
            if ( aAccmd.length == 1 ) {
                var iMans   = aAccmd [0];
                var iChilds = 0;
            } else {
                var iMans   = aAccmd [0];
                var iChilds = aAccmd [1];
            }
			
            if ( iChilds == 0 ) {
                cmbQ.style.width    = 150;
                dvAge.style.display = "none";
            } else {
                cmbQ.style.width = 150 - iChilds * 20 - 20;
				
                for ( i = 0 ; i < iChilds ; i++ ) {
					var accmdIdx = 'age[' + sAccmd + '][' + i + ']';
					
					if ( !srchBlockElts [accmdIdx] )
						srchBlockElts [accmdIdx] = accmdIdx;
					
					sOut = sOut + "<input type='text' id='" + accmdIdx + "' name='" + accmdIdx + "' style='font-size: 8pt; width: 20px' maxlength='2' onChange=\"javascript: trr_GenDirectLink ( srchBlockElts );\">";
				}
				
                dvAge.innerHTML     = sOut + "лет";
                dvAge.style.display = "block";
            }
        } else {
            cmbQ.style.width    = 150;
            dvAge.style.display = "none";
        }
    }
	
    function trr_FilterCity () {
        if ( cmb = document.getElementById ( "trr_city[]" ) ) {
            cmb.options.length = trr_ar_city.length + 1;
            cmb.options [0] = new Option ( "- Все курорты -", "" );
            cmb.selectedIndex = 0;
			
            for ( i = 0 ; i < trr_ar_city.length ; i++ )
                cmb.options [i + 1] = new Option ( trr_ar_city [i], trr_ar_city [i] );
        }
    }

    function trr_FilterSubCity () {
        if ( cmb = document.getElementById ( "trr_subcity" ) ) {
            var selCity = trr_SelectedVals ( "trr_city[]" );
            cmb.options.length = 1;
            cmb.options [0] = new Option ( "- Все районы -", "" );
            cmb.selectedIndex = 0;
			
            if ( selCity.length > 0 ) {
                for ( i = 0 ; i < trr_ar_subcity.length ; i++ ) {
                    ar = trr_ar_subcity [i].split ( ':' );
					
                    if ( selCity.indexOf ( "(" + ar [0] + ")" ) > -1 ) {
                        cmb.options.length++;
                        l = cmb.options.length - 1;
                        cmb.options [l] = new Option ( ar [1], ar[1] );
                    }
                }
            }
        }
    }

    function trr_FilterStar () {
        if ( cmb = document.getElementById ( "trr_star[]" ) ) {
            var ar_star = new Array ();
			
            if ( document.getElementById ( "trr_city[]" ).selectedIndex == 0 ) {
                /* all stars */
                ar_star = trr_ar_star;
            } else {
                /* by city */
                var sCity = trr_SelectedVals ( "trr_city[]" );
                var sStar = new String ( ";" );
				
                for ( i = 0 ; i < trr_ar_citys.length ; i++ ) {
                    ar = trr_ar_citys [i].split ( ":" );
					
                    if ( sCity.indexOf ( '(' + ar [0] + ')' ) > -1 && ar [0].length > 0 && sStar.indexOf ( ";" + ar [1] + ";" ) == -1 )
                        sStar = sStar + ar [1] + ";";
                }
				
                ar_star = sStar.split ( ';' );
            }
			
            ar_star.sort ();
            cmb.options.length = 1;
            cmb.options [0] = new Option ( "- Все категории -", "" );
            cmb.selectedIndex = 0;
			
            for ( i = 0 ; i < ar_star.length ; i++ ) {
                if ( ar_star [i].length > 0 ) {
                    cmb.options.length++;
                    l = cmb.options.length - 1;
                    cmb.options [l] = new Option ( ar_star [i], ar_star [i] );
                }
            }
        }
    }

    function trr_FilterHotel () {
        var ar_hotels = new Array ();
        var sHotels = new String ( ';' );
		
        if ( cmb = document.getElementById ( "trr_hotel[]" ) ) {
            if ( document.getElementById ( "trr_city[]" ).selectedIndex == 0 && document.getElementById ( "trr_star[]" ).selectedIndex == 0 ) {
                /* all hotels */
                for ( i = 0 ; i < trr_ar_hotel.length ; i++ ) {
                    var ar = trr_ar_hotel [i].split ( ":" );
					
                    if ( sHotels.indexOf ( ';' + ar [1] + ':' + ar [2] + ';' ) == -1)
                        sHotels = sHotels + ar [1] + ':' + ar [2] + ';';
                }
            } else {
                /* by city */
                var selCity = trr_SelectedVals ( "trr_city[]" );
                var selStar = trr_SelectedVals ( "trr_star[]" );
				
                for ( i = 0 ; i < trr_ar_hotel.length ; i++ ) {
                    var ar = trr_ar_hotel [i].split ( ':' );
					
                    if ( sHotels.indexOf ( ';' + ar [1] + ':' + ar [2] + ';' ) == -1 && ( selCity.indexOf ( '(' + ar [0] + ')' ) > -1 || selCity.length == 0 ) && ( selStar.indexOf ( '(' + ar [2] + ')' ) > -1 || selStar.length == 0 ) )
                        sHotels = sHotels + ar [1] + ':' + ar [2] + ';';
                }
            }
			
            /* loading list */
            ar_hotels = sHotels.split ( ';' );
            ar_hotels.sort ();
            cmb.options.length = 1;
            cmb.options [0] = new Option ( '- Все отели -', '' );
			
            for ( i = 2 ; i < ar_hotels.length ; i++ ) {
                var ar = ar_hotels[i].split ( ':' );
				
                if ( ar_hotels [i].length > 1 ) {
                    cmb.options.length++;
                    l = cmb.options.length - 1;
                    cmb.options [l] = new Option ( ar [0] + ' ' + ar [1] + '*', ar [0] );
                }
            }
			
            cmb.selectedIndex = 0;
        }
    }

    function trr_FilterMeal () {
        if ( cmb = document.getElementById ("trr_meal[]") ) {
            var ar_meal = new Array ();

            if ( document.getElementById ( "trr_city[]" ).selectedIndex == 0 && document.getElementById ( "trr_hotel[]" ).selectedIndex == 0 ) {
                /* all meals */
                ar_meal = trr_ar_meal;
            }
			
            if ( document.getElementById ( "trr_hotel[]" ).selectedIndex > 0 ) {
                /* by hotel */
                var selHotels = trr_SelectedVals ( "trr_hotel[]" );
                var sMeal = new String ( ';' );
				
                for ( i = 0 ; i < trr_ar_hotel.length; i++ ) {
                    ar = trr_ar_hotel [i].split ( ':' );
					
                    if ( selHotels.indexOf ( '(' + ar [1] + ')' ) > -1 ) {
                        ar2 = ar [3].split ( ';' );
						
                        for ( m = 0 ; m < ar2.length ; m++ ) {
                            if ( sMeal.indexOf ( ar2 [m] ) == -1 )
                                sMeal = sMeal + ar2 [m]+';';
                        }
                    }
                }
				
                ar_meal = sMeal.split ( ';' );
            }
			
            if ( document.getElementById ( "trr_city[]" ).selectedIndex > 0 && document.getElementById ( "trr_hotel[]" ).selectedIndex == 0 ) {
                /* by city */
                var sCity = trr_SelectedVals ( "trr_city[]" );
                var sMeal = new String ( ';' );

                for ( i = 0; i < trr_ar_citym.length ; i++ ) {
                    ar = trr_ar_citym [i].split ( ':' );
					
                    if ( sCity.indexOf ( '(' + ar [0] + ')' ) > -1 && ar [0].length > 0 && sMeal.indexOf ( ';' + ar [1] + ';' ) == -1 )
                        sMeal = sMeal+ar[1]+";";
                }
				
                ar_meal = sMeal.split ( ';' );
            }
			
            ar_meal.sort ();
            cmb.options.length = 1;
            cmb.options [0] = new Option ( '- Питание любое -', '' );
            cmb.selectedIndex = 0;
			
            for ( i = 0 ; i < ar_meal.length ; i++ ) {
                if ( ar_meal [i].length > 0 ) {
                    cmb.options.length++;
                    l = cmb.options.length - 1;
                    cmb.options [l] = new Option ( ar_meal [i], ar_meal [i] );
                }
            }
        }
    }

    function trr_FilterDeps () {
        var cmb = document.getElementById ( "trr_dep" );
		
        if ( !cmb ) {
            var cmb  = document.getElementById ( "trr_dep_f" );
            var cmb2 = document.getElementById ( "trr_dep_t" );
			
            if ( !cmb && !cmb2 )
                return;
        }
		
        if ( cmb ) {
            var ar_dep = new Array  ();
            var sDep   = new String ();

            if ( document.getElementById ( "trr_city[]" ).selectedIndex == 0 ) {
                /* all */
                ar_dep = trr_ar_dep;
            } else {
                /* by city */
                var selCity = trr_SelectedVals ( "trr_city[]" );

                for ( i = 0 ; i < trr_ar_cityd.length ; i++ ) {
                    ar = trr_ar_cityd [i].split ( ':' );
					
                    if ( selCity.indexOf ( '(' + ar [0] + ')' ) > -1 && sDep.indexOf ( ar [1] ) == -1 )
                        sDep = sDep + ar [1] + ';';
                }
				
                ar_dep = sDep.split ( ';' );
                ar_dep.sort ();
            }

            cmb.options.length = 1;
            cmb.options [0] = new Option ( "- Любая -", "" );
            cmb.selectedIndex = 0;
			
            if ( cmb2 ) {
                cmb2.options.length = 1;
                cmb2.options [0]    = new Option ( "- Любая -", "" );
                cmb2.selectedIndex  = 0;
            }
			
            for ( i = 0 ; i < ar_dep.length ; i++ ) {
                if ( ar_dep [i].length > 0 ) {
                    ar = ar_dep [i].split ( '^' );
                    cmb.options.length++;
                    l = cmb.options.length - 1;
                    cmb.options [l] = new Option ( ar [1], ar [0] );
					
                    if ( cmb2 ) {
                        cmb2.options.length++;
                        l = cmb2.options.length - 1;
                        cmb2.options [l] = new Option ( ar[1], ar[0] );
                    }
                }
            }
        }
		
        if ( cmb.options.length > 0 && cmb.options.selectedIndex == 0 )
			cmb.selectedIndex = 1;
		
        if ( cmb2 && cmb2.options.length > 0 && cmb2.options.selectedIndex == 0 )
			cmb2.selectedIndex = 1;
    }

    function trr_FilterDays () {
        var cmb  = document.getElementById ( "trr_days_f" );
        var cmb2 = document.getElementById ( "trr_days_t" );
		
        if ( !cmb || !cmb2 ) {
            return;
        } else {
            var ar_days = new Array  ();
            var sDays   = new String ();

            if ( document.getElementById ( "trr_city[]" ).selectedIndex == 0 ) {
                /* all */
                ar_days = trr_ar_days;
            } else {
                /* by city */
                var selCity = trr_SelectedVals ( "trr_city[]" );
				
                for ( i = 0; i < trr_ar_cityds.length; i++ ) {
                    ar = trr_ar_cityds [i].split ( ':' );
					
                    if ( selCity.indexOf ( '(' + ar [0] + ')' ) > -1 && sDays.indexOf ( ar [1] + ';' ) == -1 )
                        sDays = sDays+ar[1]+";";
                }
				
                ar_days = sDays.split ( ';' );
                ar_days.sort ();
            }

            cmb.options.length  = 1;
            cmb.options [0]     = new Option ( "- Все -", "" );
            cmb.selectedIndex   = 0;
            cmb2.options.length = 1;
            cmb2.options[0]     = new Option ( "- Все -", "" );
            cmb2.selectedIndex  = 0;
			
            for ( i = 0 ; i < ar_days.length ; i++ ) {
                if ( ar_days [i].length > 0 ) {
                    cmb.options.length++;
                    cmb2.options.length++;
                    l = cmb.options.length - 1;
                    cmb.options [l] = new Option ( ar_days [i], ar_days [i] );
                    cmb2.options[l] = new Option ( ar_days [i], ar_days [i] );
                }
            }
        }
    }

    function trr_Clear () {
        var cmbs = new Array ( "trr_city[]", "trr_star[]", "trr_hotel[]", "trr_meal[]", "trr_accmd", "trr_dep", "trr_days_f", "trr_days_t" );
		
        for ( i = 0; i < cmbs.length; i++ ) {
            if ( cmb = document.getElementById ( cmbs [i] ) )
                if ( cmb.options )
                    cmb.options.length = 0;
        }
    }
	
    function trr_SetDays () {
		var trr_days_f = document.getElementById ( "trr_days_f" );
		var trr_days_t = document.getElementById ( "trr_days_t" );
		
        if ( trr_days_f.selectedIndex > trr_days_t.selectedIndex )
            trr_days_t.selectedIndex = trr_days_f.selectedIndex;
    }
}

