jQuery(document).ready(function() {
	jQuery('.flashMap .specialcontainer').hover(function() {
		jQuery(this).find('.specialcontent').slideDown(500);
	}, function() {
		jQuery(this).find('.specialcontent').slideUp(500);
	})

	jQuery('.flashMap .infoicon, .flashMap .infoclose').click(function() {
		if(jQuery(this).parents('.flashMap').find('.infocontent:hidden').length) {
			jQuery(this).parents('.flashMap').find('.infocontent').css({left:-5000, display:'block'});
			var infoLeft = (jQuery(this).nextAll(jQuery.browser.msie ? 'object' : 'embed').width()-jQuery(this).parents('.flashMap').find('.infocontent').outerWidth())/2;
			var infoTop = (jQuery(this).nextAll(jQuery.browser.msie ? 'object' : 'embed').height()-jQuery(this).parents('.flashMap').find('.infocontent').outerHeight())/2;
			jQuery(this).parents('.flashMap').find('.infocontent').css({left:infoLeft, top:infoTop, display:'none'});			
			jQuery(this).parents('.flashMap').find('.infocontent').show(500);
		} else {
			jQuery(this).parents('.flashMap').find('.infocontent').hide(500); 
		}
	})
})

function mapAction(action) {
	var params = arguments[1];
	params.action = action;
	params.eID = 'tx_tuiflashmap_ajax';
	params.cid = jQuery(jQuery('.fammap').length ? '.fammap' : '.flashMap').prevAll('a:first').attr('id').split('c')[1];		
	switch(action){
		case 'openpopup':
			if(!window.open(arguments[1])){
				window.location.href = arguments[1];
			}
			break;
		case 'concation':
			jQuery('.fammap .flashMap .notification').remove();
			if(!params['from'] && !params['to']) {
				!params['from'] ? jQuery('.famap select:first').find('option:first').attr('selected', 'selected') : '';
				!params['to'] ? jQuery('.famap select:last').find('option:first').attr('selected', 'selected') : '';
			} else {
				if(params['from'] && params['to']) {
					jQuery('.fammap .flashMap').prepend('<div class="notification"><img src="fileadmin/tui/pics/img/flugdatum.jpg" /></div>')
					jQuery('.fammap .flashMap .notification').fadeIn(3000)
					setTimeout(function() {
						jQuery('.fammap .flashMap .notification').fadeOut(3000, function() {jQuery('.fammap .flashMap .notification').remove()});
					}, 15000);
				}
				jQuery.get('index.php', {eID:'tx_tuiflightlist_ajax', method:'option', sec:0}, function(data) {
					jQuery('.famap select:first').html(data);
					jQuery('.famap select:first').find('option[value=' + params['from'] + ']').attr('selected', 'selected');
					jQuery('.famap select:first').change();
					setTimeout(function() {jQuery('.famap select:last').find('option[value=' + params['to'] + ']').attr('selected', 'selected');}, 1000);
				});
			}
			break;
		case 'session':
			$.get('index.php', params);
			break;
	}
}