var getInfo = function(){}

var preloader = new Image();
preloader.src = '/images/preloader.gif';

$( document ).ready( function() {

	var cities = null;
	var description = $( '#description' );

	function showDescription( id ) {
		description.html( cities.find( 'city[id=' + id + ']' ).text() );
	}

	getInfo = function( id ){
		if( cities !== null ) {
			showDescription( id );
			return;
		}

		$.ajax({
			url: '/files/Files/descriptions.xml?rand=' + Math.random(),
			type: 'get',
			dataType: 'xml',
			timeout: 60000,
			beforeSend: function( xhr ) {
				description.html( '<img src="/images/preloader.gif" alt="" />' );
			},
			success: function( data ) {
				cities = $( data );
				showDescription( id );
			},
			error: function( xhr ) {
				description.html( '' );
				alert( 'Error' );
			}
		});
	}
});

var config = {

	params: {
		menu: 'false',
		quality: 'high',
		wmode: 'transparent',
		allowscriptaccess: 'sameDomain'
	},

	flashvars: {
		xmlLink: '/files/Files/cities.xml?rand=' + Math.random(),
		functName: 'getInfo'
	},

	attributes: {
		'class': 'my_flash'
	}

};

swfobject.embedSWF( 
	'/images/map.swf',
	'main_flash',
	//'100%',
	//'400',
	'433',
	'250',
	'8.0.0',
	'',
	config.flashvars,
	config.params,
	config.attributes
);
