	var ver4, target;
	ver4 = (parseInt(navigator.appVersion) >= 4 );
	
	function toggle_state(targetId,_view){
		if ( ver4 ){
			if( target = document.getElementById(targetId) ) {
				if ( _view ) {
					target.style.display = "";
				} else {
					target.style.display = "none";
				}
			}// else alert( 'no id with value "'+targetId+'"');
		}
	}
	function toggle(targetId){
		if ( ver4 ){
			if( target = document.getElementById(targetId) ) {
				if ( target.style.display != "block" ) {
					if ( document.all ){
							target.style.display = "block";
						} else {
							target.style.display = "table-row";
						}
				} else {
					target.style.display = "none";
				}
			} else alert( 'no id with value "'+targetId+'"');
		}
	}
	function popup_site(url) {
		window.open(url,'info','width=750,height=650,scrollbars=yes,resizable=yes');
	}
	function check_boxes( hotel_id ) {
		var valid = false;
		if( hotels[hotel_id] ) {
			var hotel = hotels[hotel_id];
			for( i in hotel.roomtypes ) {
				if( document.getElementById( hotel.roomtypes[i] ).checked ) valid = true;
			}
			for( i in hotel.packages ) {
				if( document.getElementById( hotel.packages[i] ).checked ) valid = true;
			}
			if (valid == false) {
				for( i in hotel.programs ) {
					var tmp = hotel.programs[i].split('|');
					if( document.getElementById( tmp[0] ).checked ) {
							if (tmp[1] == 1) {
								valid = true;
							} else {
								valid = false;
								break;	
							}
					}
				}			
			}
		}
		if( !valid ) {
			var i18n = new cst_i18n;
			alert( i18n.i18n_string_entities_decode( lng_str['book.error.room.choose'] ) );
		}
		return valid;
	}
	function view_rows( rows ) {
		for( row in rows ) {
			toggle_state( rows[row], true );
		}
	}
	
	function toggle_rows( rows ) {
		for( row in rows ) {
			toggle( rows[row] );
		}
	}
	
	var calendar_offset_x = 25;
	var calendar_offset_y = 0;
	
	//gehoert zur request.xsl feldabfrage
	
	var fields = new Array(
		"request_user_firstname",
		"request_user_lastname",
		"request_user_street",
		"request_user_zip",
		"request_user_city",
		"request_user_country",
		"request_user_email",
		"rd_from1",
		"rd_to1"
	);
	var flength = fields.length;
	function request_check_form() {
		var tmpary = new Array();
		for (var i = 0; i < flength; i++) {
			var tmp = 'form[' + fields[i] + ']';
			if (document.form[tmp].value == "") {
				document.form[tmp].style.backgroundColor = "#FFFF70";
				tmpary.push(tmp);
			}
			else {
				document.form[tmp].style.backgroundColor = "#FFFFFF";
			} 
		}
		if (tmpary.length !=0) {
			alert('Bitte fuellen Sie alle farbig hinterlegten Felder aus');
			document.form[tmpary[0]].focus();
			return false;
		}
		return true;
	}
	
	var cst_image_zoom_win = false;
	function cst_image_zoom( url ) {
		cst_image_zoom_win = window.open( url+'/600xq', 'cstimage', 'width=620,height=550,location=no,toolbar=no' );
		cst_image_zoom_win.focus( );
		return false;
	}
	
	function cst_ssl_host( ssl_host ) {
		if( location.protocol != 'https:' ) {
			var target = 'https://'
			target += ssl_host;
			target += location.pathname;
			target += location.search;
			target += location.hash;
			location.href = target;
		}
	}
	
	function cst_hotel_stars_string( stars_num ) {
		var stars = [];
		for( var s = 0; s < Math.floor( stars_num / 10 ); s++ )  {
			stars.push( '*' )
		}
		if( stars_num == 45 || stars_num == 35 ) {
			stars.push( 's' )
		}
		return stars.join( '' );
	}
	
	function cst_datepicker_custom_range( input, obj_id, obj_range_start, obj_range_end ) {
		if( obj_range_start != '' ) {
			return {
				minDate: ( input.id == obj_id ? jQuery('#'+obj_range_start).datepicker( 'getDate' ) : null), 
				maxDate: ( input.id == obj_range_start ? jQuery('#'+obj_id).datepicker( 'getDate' ) : null)
			}; 
		} else if( obj_range_end != '' ) {
			return {
				minDate: (input.id == obj_id ? ( jQuery('#'+obj_id).datepicker( 'getDate' ) > jQuery('#'+obj_range_end).datepicker( 'getDate' ) ? jQuery('#'+obj_range_end).datepicker( 'setDate', jQuery('#'+obj_id).datepicker( 'getDate' ) ) : null ) : null)
			};
		} else {
			return true;
		}
	}
	
	var cst_xd_url;
	
	function cst_xd_url_set( url ) {
		cst_xd_url = url;
	}
	
	function cst_xd_iframe_create( call, params ) {
		/*
		 * iframe nur erstellen, wenn die cst in einem iframe liegt
		 * */
		try {
			if ( document.all ) {
				top.location.href;
			}
			else if ( typeof top.location.href == 'undefined' ) {
				throw (new Error());
			}
		} 
		catch (e) {
			var url = cst_xd_url + '?call=' + call + '&params=' + params;
			
			jQuery('body').append('<iframe src="' + url + '" height="0" width="0" frameborder="0"></iframe>');
		}
	}
	
	function cst_xd_iframe_resize( height ) {
		if ( !cst_xd_url ) return;

		if ( height ) {
			jQuery('body').height( height )
		}
		
		cst_xd_iframe_create( 'embed_iframe_resize', encodeURI( '{"height":' + ( ( height || jQuery('body').height() ) + 20 ) + '}' ) );
	}
	
	function cst_xd_scroll_top() {
		cst_xd_iframe_create( 'embed_scroll_top' );
	}
	
	if( typeof _lib_load_libs == 'undefined' && typeof window._loader == 'undefined' ) {
		var _lib_load_loaded = false;
		var _lib_load_libs = {};
		if( typeof _lib_load_libs_loaded == 'undefined' ) {
			var _lib_load_libs_loaded = {};
		}

		var onload_old = window.onload;
		window.onload = function(){
			window._lib_load_loaded = true;
			if( typeof( onload_old ) == 'function' ) {
				onload_old();
			}
		};
		
		var _file_load = function( file ) {
			if( typeof file == 'undefined' ) { return; }
			var tag = false, file_ext = file.split( '?' )[0].substring( file.lastIndexOf( '.' ) + 1 );

			var head = document.getElementsByTagName( "head" )[0];
			if( file_ext == 'js' ) {
				if ( window._lib_load_loaded ) {
					tag = document.createElement( 'script' );
					tag.type = 'text/javascript';
					tag.src = file;
					tag.charset = 'UTF-8';
				}
				else {
					window.document.write( '<scr'+'ipt type="text/javascript" src="'+file+'" charset="UTF-8"></scr'+'ipt>' );
				}
			} else if ( file_ext == 'css' ) {
				if ( window._lib_load_loaded ) {
					tag = document.createElement( 'link' );
					tag.rel = 'stylesheet';
					tag.href = file;
				}
				else {
					window.document.write( '<link rel="stylesheet" href="'+file+'" type="text/css" />' );
				}
			}
			
			if ( window._lib_load_loaded && tag !== false ) {
				head.appendChild( tag );
			}
		}
		
		var _lib_load = function ( ) {
			for( var i = 0; i < arguments.length; i++ ) {
				var lib_name = arguments[i];
				if( typeof _lib_load_libs_loaded[lib_name] == 'undefined' ) {
					for( file_idx in _lib_load_libs[lib_name] ) {
						var file = _lib_load_libs[lib_name][file_idx];
						if ( typeof file == 'function' ) { continue; }
						if( typeof file == 'string' ) {
							_file_load( file );
						} else {
							if( typeof file.check == 'function' && file.check() ) {
								_file_load( file.path );
							} else if ( typeof file.check == 'undefined' ) {
								_file_load( file.path );
							}
						}
					}
					_lib_load_libs_loaded[lib_name] = true;
				}
			}
		};
		
		var _lib_repository_add = function ( name, files ) {
			if( typeof _lib_load_libs[name] == 'undefined' ) {
				_lib_load_libs[name] = files;
			}
		}
		
	}

	if( typeof window._loader != 'undefined' ) {
		var _lib_repository_add = window._loader.lib_add;
		var _lib_load = window._loader.lib_load;
	}		
	
	_lib_repository_add(
		'jQuery',
		[
			{ path: _base_res+'js/jquery-1.3.2/jquery-1.3.2.min.js', check: function() {
				if( typeof window.jQuery == 'undefined' ) { return true; }
				if( version_compare( "1.3.2", jQuery.fn.jquery ) ) {
					return true;
				}
				return false;
			} },
			_base_res+'js/jquery-1.1.3.1/jquery-history.js',
			_base_res+'js/jquery-1.1.3.1/jquery-custom.js'
		]
	);
	_lib_repository_add(
		'jQuery-UI',
		[
			_base_res+'js/ui-1.7.2/js/jquery-ui-1.7.2.custom.min.js',
			_base_res+'js/ui-1.7.2/css/smoothness/jquery-ui-1.7.2.custom.css'
		]
	);
	_lib_repository_add(
		'Datepicker',
		[
			_base_res+'js/datepicker-3.3/ui.datepicker.js',
			_base_res+'js/datepicker-3.3/ui.datepicker.css'
		]
	);
	_lib_repository_add(
		'Lytebox',
		[
			_base_res+'js/lytebox-3.22/lytebox.js',
			_base_res+'js/lytebox-3.22/lytebox.css'
		]
	);
	
	_lib_repository_add(
		'Highslide',
		[
			_base_res+'/js/highslide-4.1.5/highslide.min.js?version='+_version_cache,
			_base_res+'/js/highslide-4.1.5/settings.js?version='+_version_cache,
			_base_res+'/js/highslide-4.1.5/highslide.css?version='+_version_cache
		]
	);

	_lib_repository_add(
		'cst_general',
		[
			_base_res+'js/cst_i18n.js'
		]
	);
	_lib_repository_add(
		'cst_book',
		[
			_base_res+'js/cst_book.js?version='+_version_cache,
			_base_res+'js/cst_calendar.js?version='+_version_cache
		]
	);
	_lib_repository_add(
		'cst_scroller',
		[
			_base_res+'js/cst_scroller.js'
		]
	);
	_lib_repository_add(
		'calendar_old',
		[
			_base_res+'js/calendar.js'
		]
	);
	_lib_repository_add(
		'Mediaplayer',
		[
			_base_res+'js/mediaplayer-4.1/swfobject.js'
		]
	);
	_lib_repository_add(
		'swfobject',
		[
			_base_res+'js/swfobject-2.2/swfobject.js'
		]
	);
	_lib_repository_add(
		'bgiframe',
		[
			_base_res+'js/jquery.bgiframe-2.1.1/jquery.bgiframe.min.js'
		]
	);
	_lib_repository_add(
		'vjg',
		[
			_base_res+'js/vjg/vjg.js',
			_base_res+'js/vjg/vjg.css'
		]
	);
	_lib_repository_add(
		'vil',
		[
			_base_res+'js/vil/vil.js',
			_base_res+'js/vil/vil.css'
		]
	);
	_lib_repository_add(
		'vct',
		[
			_base_res+'js/vct/vct.js'
		]
	);
	_lib_repository_add(
		'vnh',
		[
			_base_res+'js/vnh/vnh.js'
		]
	);
	_lib_repository_add(
		'Cookies',
		[
			_base_res+'js/jquery.cookie-1.0/jquery.cookie.js'
		]
	);
	_lib_repository_add(
		'jquery.json',
		[
			_base_res+'js/jquery.labs_json-1.0/labs_json.js'
		]
	);
	_lib_repository_add(
		'ui',
		[
			_base_res+'js/ui-1.0.6/ui.core.js',
			_base_res+'js/ui-1.0.6/css/base/ui.all.css'
		]
	);
	_lib_repository_add(
		'ui-tabs',
		[
			_base_res+'js/ui-1.0.6/ui.tabs.js',
			_base_res+'js/ui-1.0.6/css/cst-tabs.css'
		]
	);
	_lib_repository_add(
		'ui-autocomplete',
		[
			_base_res+'js/jquery.autocomplete-1.2.6/jquery.autocomplete.js',
			_base_res+'js/jquery.autocomplete-1.2.6/jquery.autocomplete.css'
		]
	);
	_lib_repository_add(
		'ui-accordion',
		[
			_base_res+'js/ui-1.0.6/ui.accordion.js'
		]
	);
	_lib_repository_add(
		'corner',
		[
			_base_res+'js/curvycorners-2.0.3/curvycorners.js'
		]
	);
	
	_lib_repository_add(
		'roundies',
		[
			'/js/dd_roundies-0.0.2a/DD_roundies_0.0.2a-min.js'
		]
	);
	
	_lib_repository_add(
		'reflection',
		[
			_base_res+'js/reflection-2.0/reflection.js'
		]
	);

	_lib_repository_add(
		'jsoncookie',
		[
			_base_res+'js/jsoncookie-0.9/json2-min.js',
			_base_res+'js/jsoncookie-0.9/jquery.cookie.js',
			_base_res+'js/jsoncookie-0.9/jquery.jsoncookie.js'
		]
	);	

	_lib_repository_add(
		'voucher_calculate',
		[
			_base_res+'js/cst_voucher_calculate.js?version='+_version_cache
		]
	);	

	_lib_repository_add(
		'qtip',
		[
			_base_res+'js/qtip-1.0.0/jquery.qtip-1.0.min.js'
		]
	);		

	_lib_repository_add(
		'cst_helper',
		[
			_base_res+'js/cst_helper.js?version='+_version_cache
		]
	);			

	_lib_repository_add(
		'cst_textbox_limited',
		[
			_base_res+'js/cst_textbox_limited.js?version='+_version_cache
		]
	);			

	_lib_repository_add(
		'cst_tab_switcher',
		[
			_base_res+'js/cst_tab_switcher-0.1/cst_tab_switcher.js?version='+_version_cache
		]
	);			
	

	//version_compare("1.2.3","1.0") returned true
	function version_compare( a, b ) {
		var a_versions = a.split(".");
		var b_versions = b.split(".");
		var max_parts = Math.max(a_versions.length,b_versions.length);
		for( var i = 0;i<max_parts;i++ ) {
		 var a_part = a_versions[i]*1;
		 var b_part = b_versions[i]*1;
		 if( a_part == b_part ) {continue}
		 if( a_part > b_part ) return true;
		    return false;   
		}
	}	
	
	if( typeof Function.prototype.bind != 'function' ) {
		Function.prototype.bind = function() {
			var __method = this, args = Array.prototype.slice.call(arguments,0), object = args.shift();
			return function() {
				return __method.apply(object, args.concat(Array.prototype.slice.call(arguments,0)));
			}
		}
	}
	
	/* IE Bildflackern bei hover vermeiden */
	try {
	 document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}	

	/* console für ie emulieren falls jmd eins vergisst */
	if(typeof console == 'undefined') {
		console = { log: function() {}, dir: function() {} };
	}
    
	if( typeof jQuery == 'function' ) {
		_$ = jQuery;
	}
	