var height_ = jQuery.fn.height;
jQuery.fn.height = function() {
    if ( this[0] == window && jQuery.browser.opera && jQuery.browser.version >= 9.50)
        return window.innerHeight;
    else return height_.apply($(this[0]));
};

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

(function($) {

$.fn.dialog_hide = function(options)
{
	if($.browser.msie) {
		$('#floating_window').remove();
		$('#overlay').remove();
	} else {
		$('#floating_window').fadeOut('fast', function() {$(this).remove();});
		$('#overlay').fadeOut('fast', function() {$(this).remove();});
	}
}


$.fn.internal_label = function(text) {

	var bound_global_events = $.fn.internal_label.bound_global_events;

	if (bound_global_events == 0) {
		$(window).unload(function() {
			$('.internal_label').val('');
		});

//		$(this).parents('form:first').submit(function() {
//				alert('submit internal_label');
//			$('.internal_label').val('');
//		});

		bound_global_events = 1;
		$.fn.internal_label.bound_global_events = bound_global_events;
	}

	return this.each(function() {
		var $this = $(this);

		if ($this.val() == '') {
			$this.addClass('internal_label');
			$this.val(text);
		}

		$this.focus(function() {
			if ($(this).is('.internal_label')) {
				$(this).val('');
				$(this).removeClass('internal_label');
			}
		});

		$this.blur(function() {
			if (jQuery.trim($(this).val()) == '') {
				$(this).addClass('internal_label');
				$(this).val(text);
			}
		});
	});
};

$.fn.internal_label.bound_global_events = 0;

})(jQuery);

function simple_dialog(message)
{
	$('body').append('<div id="section_message"><p>' + message + '</p><button id="button_ok">OK</button></div>');
	if(message.length>20) {
		$('#section_message').width(300);
	}
	show_floating_message( null );
}

function autocompleteFormatItem(row,i,j)
{
  return '<strong>'+row[0]+'</strong>, <i>'+row[1]+'</i>';
}

function autocompleteSelected(li)
{
//  autocompleteFindValue(li);
//	$('#section_search #search_box').val('Szukaj...');
	window.location = li.extra[1];
}

$(document).ready(function() {
/*	$('#container_header h1').after( $('#container_header h1').clone() ).attr('id','header_title_shadow');*/

	$('a.map_point').mouseover(function()     { tooltipShow($(this).attr('id').substring(10)); });
	$('a.map_point').mouseout(function()      { tooltipHide($(this).attr('id').substring(10)); });
	$('a.sidebar_place').mouseover(function() { tooltipShow($(this).attr('id').substring(14)); });
	$('a.sidebar_place').mouseout(function()  { tooltipHide($(this).attr('id').substring(14)); });

	distribute_reviews();

	$("#box_review_request td").click(function() {
		load_floating_window( '/review_editor/'+$(this).attr('attr-mode')+'/'+$(this).attr('attr-object_id')+'/'+$(this).attr('attr-evaluation'), review_editor_initialization);
	});

	$("#box_landmarks span.one_landmark").click(function() {
		load_floating_window('/floating_landmark/'+$(this).attr('attr-landmark_id'), floating_landmark_initialization, true);
	});

	$("#section_footer #button_contact").click(function() {
		load_floating_window('/contact', contact_initialization, true);
	});

	$("#section_footer #button_review_all").click(function() {
		window.location = $(this).attr('attr-url');
	});

	$("#section_footer #button_add_note").click(function() {
		if($(this).attr('attr-place_id')) {
			load_floating_window('/note_editor/PLACE/'+$(this).attr('attr-place_id'), note_editor_initialization);
		} else if($(this).attr('attr-country_id')) {
			load_floating_window('/note_editor/COUNTRY/'+$(this).attr('attr-country_id'), note_editor_initialization);
		} else {
			load_floating_window('/note_editor/HOME', note_editor_initialization);
		}
	});

	$("#box_distances #button_add_distances").click(function() {
		load_floating_window('/distances_editor/'+$(this).attr('attr-place_id'), distances_editor_initialization);
	});

	$("#section_notes span.add_comment").click(function() {
		load_comment_editor( 'NOTE', $(this).parent().attr('id').substring(5) );
	});

	$("#section_notes div.one_comment span.comment_edit_button").click(function() {
		load_comment_editor( 'COMMENT', $(this).parent().parent().attr('id').substring(8) );
	});

	$(".one_review span.button_edit").click(function() {
		load_floating_window( '/review_editor/REVIEW/'+$(this).parent().parent().attr('attr-review_id'), review_editor_initialization);
	});

	$('#section_navigation #button_search').mouseover(function() {
		$('#section_search').slideDown('fast');
	});

	$('#section_search #search_box').autocomplete('/autocomplete', {mustMatch:0, autoFill:false, selectFirst:true, minChars:2, formatItem:autocompleteFormatItem, onItemSelect:autocompleteSelected, matchContains:1, cacheLength:10});	
  
/*
	$('#section_search #search_box').focus(function() {
		if($('#section_search #search_box').val()=='Szukaj...') $('#section_search #search_box').val('');
		return true;
	});

	$('#section_search #search_box').blur( function() { $('#section_search #search_box').val('Szukaj...'); } );
*/	
	if( $("#section_geomap").length ) {
		$('#section_geomap_list_of_places span.place, span.country').click(function() {
			$('#section_geomap_list_of_places span.selected').removeClass('selected');
			$('#section_geomap_landmarks div.selected').removeClass('selected');
			$(this).addClass('selected');
			geomap_center( 'ALL', $(this).attr('attr-latitude'), $(this).attr('attr-longitude'), $(this).attr('attr-zoom'), 'roads' );
		});

		$('#section_geomap_landmarks #button_add_landmark').click(function() {
			geomap_find_location( geomap_latitude, geomap_longitude );
			load_floating_window( '/landmark_editor/new/'+geomap_latitude+'/'+geomap_longitude+'/'+geomap_zoom, landmark_editor_initialization);
		});

		$('#section_geomap_landmarks .one_landmark').click(function(event) {
			if( $(event.target).hasClass('button_edit_landmark') ) {
				load_floating_window( '/landmark_editor/landmark/'+$(this).attr('attr-landmark_id') +'/'+geomap_latitude+'/'+geomap_longitude+'/'+geomap_zoom, landmark_editor_initialization);
			} else if( !$(event.target).is('a') ) {
				$('#section_geomap_landmarks div.selected').removeClass('selected');
				$('#section_geomap_list_of_places span.selected').removeClass('selected');
				$(this).addClass('selected');
				geomap_center( 'ALL', $(this).attr('attr-latitude'), $(this).attr('attr-longitude'), $(this).attr('attr-zoom'), 'satelite' );
			}
		});

		$('#section_geomap #geomap_layout_buttons #coordinates').dblclick(function(event) {
			$('#section_geomap #geomap_layout_buttons #coordinates').html(geomap_latitude+' '+geomap_longitude+' '+geomap_zoom);
		});

		geomap_initialize_maps();
		geomap_initialize_events();
	}

	if( $('#section_message').length ) {
		show_floating_message( more_reviews_request_initialization );
	}

	if( $('#section_review_all').length ) {
		$('#section_review_all #field_author').internal_label('Twoje imię / pseudonim');
		$('#section_review_all #field_email').internal_label('Email');

		$('#section_review_all .one_evaluation').click(function() {
			if($(this).hasClass('selected')) {
				$(this).removeClass('selected');
				$(this).parent().parent().find('input.field_evaluation').val('');
			} else {
				$(this).parent().find('span.one_evaluation').removeClass('selected');
				$(this).addClass('selected');
				$(this).parent().parent().find('input.field_evaluation').val($(this).attr('attr-evaluation'));
			}
		});
		$('#review_all_form').submit(function() {
			counter = 0;
			$('#review_all_form .one_place').each(function() {
				place_id = $(this).attr('attr-place_id');
				field_body = $(this).find('.field_body').val();
				field_evaluation = $(this).find('.field_evaluation').val();
				field_delete = $(this).find('.field_delete').val();

				if( (field_evaluation && !(field_body.length>15)) || (!field_evaluation && field_body.length>1) ) {
					counter++;
					$(this).addClass('incomplete');
				} else {
					$(this).removeClass('incomplete');
				};
			});
			if(counter>0) {
				simple_dialog('Niestety, nie wszystkie miejsca zostały ocenione w prawidłowy sposób. Żeby opinia była kompletna, należy wskazać ocenę oraz dopisać komentarz.<br /><br />Niewłaściwe pozycje zostały oznaczone kolorem czerwonym.');
				return false;
			} else if( $('#section_review_all #field_author').val().length==0 ) {
				simple_dialog('Proszę, podaj swoje imię lub pseudonim.');
				return false;
			} else {
				return true;
			}
		});
	}

	$('#section_map #scroll_up').click(function() {
		offset = $('#section_map #list_of_places #list').scrollTop() - $('#section_map #list_of_places #list').height() + 18;
		$('#section_map #list_of_places #list').animate({scrollTop: offset}, 500);
	});

	$('#section_map #scroll_down').click(function() {
//		$('#section_map #list_of_places').scrollTop($('#section_map #list_of_places').scrollTop()+$('#section_map #list_of_places').height()-13);
		offset = $('#section_map #list_of_places #list').scrollTop() + $('#section_map #list_of_places #list').height() - 18;
		$('#section_map #list_of_places #list').animate({scrollTop: offset}, 500);
	});

	if(admin_on_board) {
		$('#section_map #list_of_places #list img.star').click(function() {
			$('#section_map #label_position_editor').remove();
			p = $(this).parent().attr('attr-label_position');
			$(this).after('<div id="label_position_editor"><span'+(p=='N'?' class="selected"':'')+'>N</span> <span'+(p=='E'?' class="selected"':'')+'>E</span> <span'+(p=='S'?' class="selected"':'')+'>S</span> <span'+(p=='W'?' class="selected"':'')+'>W</span> <span'+(p=='X'?' class="selected"':'')+'>X</span> </div>');
			$('#section_map #label_position_editor span').click(function() {
				position = $(this).html();
				place_id = $(this).parent().parent().attr('attr-place_id');
				map_id   = $(this).parent().parent().parent().attr('attr-map_id');

				$(this).parent().parent().attr('attr-label_position',position);

				$(this).parent().remove();
				$.post( '/label_position/'+map_id+'/'+place_id+'/'+position, {}, function(data)
				{
					var s = $('#section_map #map').css('background-image');
					var i = s.indexOf('?');
					if(i<0) {
						i = s.indexOf(')');
					}
					var now = new Date();
					$('#section_map #map').css('background-image',s.substr(0,i)+'?'+now.getTime()+')');
				});
			});
		});

		$("#section_footer #button_add_picture").click(function() {
			load_picture_editor( 'PLACE', $(this).attr('attr-place_id') );
		});

		$("#section_footer #button_add_place").click(function() {
			load_floating_window('/place_editor/country/'+$(this).attr('attr-country_id'), place_editor_initialization);
		});

		$("#section_footer #button_edit_place").click(function() {
			load_floating_window('/place_editor/place/'+$(this).attr('attr-place_id'), place_editor_initialization);
		});

		$("div.one_review").dblclick(function() {
			load_floating_window( '/review_editor/REVIEW/'+$(this).attr('attr-review_id'), review_editor_initialization);
		});

		$("#section_notes div.one_note").dblclick(function() {
			load_floating_window('/note_editor/NOTE/'+$(this).attr('attr-note_id'), note_editor_initialization);
		});

		$("#section_notes div.one_comment").dblclick(function() {
			load_comment_editor( 'COMMENT', $(this).attr("id").substring(8) );
		});

		$("#section_pictures div.one_picture").dblclick(function() {
			load_picture_editor( 'PICTURE', $(this).attr("attr-picture_id") );
		});

		$('#section_calibrate #map').click(function(e) {
			var x = e.pageX - this.offsetLeft;
			var y = e.pageY - this.offsetTop;
			$('#section_calibrate #mouse_x').html(x);
			$('#section_calibrate #mouse_y').html(y);
		});

		$('#section_calibrate #list_of_places .one_place').click(function() {
			if( $(this).find('.place_x').val()!='' || $(this).find('.place_y').val()!='') {
				$(this).find('.place_x').val('');
				$(this).find('.place_y').val('');
			} else {
				$(this).find('.place_x').val($('#section_calibrate #mouse_x').html());
				$(this).find('.place_y').val($('#section_calibrate #mouse_y').html());
			}
			place_points_on_map('place');
		});

		$('#section_calibrate #map_latitude, #section_calibrate #map_longitude, #section_calibrate #map_gwidth, #section_calibrate #map_gheight').change(function() {
			place_points_on_map('map');
		});
	}

});

function place_points_on_map(mode)
{
	counter = 0;
	$('#section_calibrate #list_of_places .one_place').each(function() {
		if( $(this).find('.place_x').val()!='' || $(this).find('.place_y').val()!='' ) {
			counter++;
			if(counter==1) {
				x1 = $(this).find('.place_x').val();
				y1 = $(this).find('.place_y').val();
				lat1 = $(this).attr('attr-latitude');
				lng1 = $(this).attr('attr-longitude');
			} else if(counter==2) {
				x2 = $(this).find('.place_x').val();
				y2 = $(this).find('.place_y').val();
				lat2 = $(this).attr('attr-latitude');
				lng2 = $(this).attr('attr-longitude');
			}
		}
	});

	map_width     = parseInt($('#section_calibrate #map').width());
	map_height    = parseInt($('#section_calibrate #map').height());

	if(mode=='place' && counter==2) {
		map_gwidth    = Math.abs(lng1-lng2)/Math.abs(x1-x2)*map_width;
		map_gheight   = Math.abs(lat1-lat2)/Math.abs(y1-y2)*map_height;
		map_longitude = lng1 - map_gwidth*x1/map_width;
		map_latitude  =  lat1 - (map_gheight - map_gheight*y1/map_height);
//		alert(x1+'/'+y1+' '+x2+'/'+y2+' '+lng1+'/'+lat1+' '+lng2+'/'+lat2+' = '+map_gwidth+'/'+map_gheight+' '+map_longitude+'/'+map_latitude);	
		$('#section_calibrate #map_latitude').val(map_latitude);
		$('#section_calibrate #map_longitude').val(map_longitude);
		$('#section_calibrate #map_gwidth').val(map_gwidth);
		$('#section_calibrate #map_gheight').val(map_gheight);

	} else {
		map_latitude  = parseFloat($('#section_calibrate #map_latitude').val());
		map_longitude = parseFloat($('#section_calibrate #map_longitude').val());
		map_gwidth    = parseFloat($('#section_calibrate #map_gwidth').val());
		map_gheight   = parseFloat($('#section_calibrate #map_gheight').val());
	}

//	map_longitude = place_longitude1 - x1 / (map_width / map_gwidth)
//	map_gwidth = (map_width * (place_longitude2-map_longitude)) / x2

//	alert('poczatek '+map_latitude+' '+map_longitude+' '+map_gwidth+' '+map_gheight+' '+map_width+' '+map_height);
	c=0;
	$('#section_calibrate #map img').each(function() {
		c=c+1;
		place_latitude  = parseFloat($(this).attr('attr-latitude'));
		place_longitude = parseFloat($(this).attr('attr-longitude'));
		x = Math.round((place_longitude-map_longitude) * (map_width / map_gwidth)) -5;
		y = Math.round((map_gheight - place_latitude + map_latitude) * (map_height / map_gheight)) -5;
		$(this).css('left',x);
		$(this).css('top',y);
//		if(c<2) {
//			alert(place_latitude+' '+place_longitude+' '+x+' '+y)
//		}
	});
//	alert('koniec');
//	$place['x']     = round(($place['longitude']-$this->map['longitude']) * ($this->map['width'] /$this->map['gwidth'])) -5;
//	$place['y']     = round(($this->map['gheight'] - $place['latitude'] + $this->map['latitude']) * ($this->map['height']/$this->map['gheight'])) -5;
}

function geomap_find_location()
{
	dist = 1000000;
	place_name = '';
	place_id = null;
	
	$('#section_geomap_list_of_places span.place').each(function() {
		lat = $(this).attr('attr-latitude');
		lng = $(this).attr('attr-longitude');
		d = (lat-geomap_latitude)*(lat-geomap_latitude)+(lng-geomap_longitude)*(lng-geomap_longitude);
		if( d<dist ) {
			dist = d;
			place_id = $(this).attr('attr-place_id');
			place_name = $(this).html();
		}
	});
	$('#section_geomap #geomap_layout_buttons #coordinates').html(coordinates_to_string(geomap_latitude,'N','S')+' '+coordinates_to_string(geomap_longitude,'E','W'));

	$('#section_geomap #geomap_layout_buttons #localisation').html(place_name);	
	$('#section_geomap #geomap_layout_buttons #localisation').attr('attr-place_name',place_name);	
	$('#section_geomap #geomap_layout_buttons #localisation').attr('attr-place_id',place_id);	
}

function coordinates_to_string(g,x,y)
{
	return Math.floor(Math.abs(g))+'°'+Math.round((Math.abs(g)-Math.floor(Math.abs(g)))*60)+"'"+(g>0?x:y);
}

var geomap_google;
var geomap_yahoo;
var geomap_microsoft;
var geomap_show_google = true;
var geomap_show_yahoo = true;
var geomap_show_microsoft = true;
var geomap_synchronization = true;
var geomap_current = '';

function geomap_tolerance(x, a, b) {
//	debug('tolerance '+x+' '+a+' '+b+' '+(Math.abs(a - b) >= .0000001));
	return Math.abs(a - b) >= .0000001;
}

var geomap_event_time = 0;

function debug(text) {
	$('#debug').html(geomap_event_time+': ' + text + '<br />' + $('#debug').html());
}

function geomap_center( m, latitude, longitude, zoom, map_type )
{
	var now = new Date();
	geomap_event_time = now.getTime();
	
//geomap_google.setMapType(G_SATELLITE_MAP);
//debug('geomap_center: m='+m+', lat='+latitude+', long='+longitude+', zoom='+zoom+', map_type='+map_type);
	if(latitude) {
		geomap_latitude  = parseFloat(latitude);
		geomap_longitude = parseFloat(longitude);
		geomap_zoom      = parseInt(zoom);
	}

/*	if( m != 'GOOGLE'    && geomap_show_google     && ( m=='ALL' || geomap_tolerance('g', geomap_latitude, geomap_google.getCenter().lat())
																 || geomap_tolerance('g', geomap_longitude, geomap_google.getCenter().lng())      
																 || geomap_zoom != geomap_google.getZoom())) {
*/
	if( m != 'GOOGLE' && geomap_show_google ) {

		if(map_type) {
//debug('google map_type '+map_type+' zoom '+geomap_zoom);
//			geomap_google.setCenter( new GLatLng( geomap_latitude, geomap_longitude ), geomap_zoom);
			geomap_google.setCenter( new GLatLng( geomap_latitude, geomap_longitude ), geomap_zoom, map_type=='satelite'?G_SATELLITE_MAP:G_NORMAL_MAP);
//			geomap_google.setZoom(geomap_zoom);
//			if(geomap_zoom==17) { debug('extra zoom'); geomap_google.setZoom(17); }
//			debug('google zoom '+geomap_zoom+' '+geomap_google.getZoom());
		} else {
//debug('google bez map_type');
			geomap_google.setCenter( new GLatLng( geomap_latitude, geomap_longitude ), geomap_zoom);
		}
	}

/*	if( m != 'YAHOO'     && geomap_show_yahoo      && ( m=='ALL' || geomap_tolerance('y', geomap_latitude, geomap_yahoo.getCenterLatLon().Lat)
																 || geomap_tolerance('y', geomap_longitude, geomap_yahoo.getCenterLatLon().Lon)
																 || geomap_zoom != 18-geomap_yahoo.getZoomLevel())) {
*/
	if( m != 'YAHOO' && geomap_show_yahoo ) {
//debug('yahoo');
try {
		geomap_yahoo.drawZoomAndCenter( new YGeoPoint( geomap_latitude, geomap_longitude), 18-geomap_zoom);
		} catch(err) {};
//debug('po yahoo');
		if(map_type) {
//debug('yahoo map_type '+map_type+' '+(map_type=='satelite'?YAHOO_MAP_SAT:YAHOO_MAP_REG));
try {
			geomap_yahoo.setMapType(map_type=='satelite'?YAHOO_MAP_HYB:YAHOO_MAP_REG);  
		} catch(err) {};
//debug('po yahoo map_type');
		}
	}


/*	if( m != 'MICROSOFT' && geomap_show_microsoft  && ( m=='ALL' || geomap_tolerance('m', geomap_latitude, geomap_microsoft.GetCenter().Latitude)
																 || geomap_tolerance('m', geomap_longitude, geomap_microsoft.GetCenter().Longitude)
																 || geomap_zoom != geomap_microsoft.GetZoomLevel())) {
*/
	if( m != 'MICROSOFT' && geomap_show_microsoft ) {
		if(map_type) {
//debug('microsoft map_type '+map_type);
			geomap_microsoft.SetMapStyle(map_type=='satelite'?VEMapStyle.Aerial:VEMapStyle.Road);
		}
//debug('microsoft');
		geomap_microsoft.SetCenterAndZoom( new VELatLong( geomap_latitude, geomap_longitude ), geomap_zoom );
//debug('po microsoft');
	}

	
//	debug('find location');
	geomap_find_location();
}

function geomap_initialize_maps()
{
	if (GBrowserIsCompatible()) {
		geomap_google = new GMap2(document.getElementById('geomap_google')); 
		geomap_google.addControl(new GLargeMapControl()); 
		geomap_google.addControl(new GMapTypeControl()); 
	}

	geomap_yahoo = new YMap(document.getElementById("geomap_yahoo"));
	geomap_yahoo.addTypeControl();
	geomap_yahoo.addZoomLong();
	geomap_yahoo.setMapType(YAHOO_MAP_REG);
	geomap_yahoo.disableKeyControls();

/*
	YEvent.Capture(geomap_yahoo, EventsList.changeZoom, function() {
		if( geomap_synchronization ) {
			geomap_lat  = geomap_yahoo.getCenterLatLon().Lat;
			geomap_long = geomap_yahoo.getCenterLatLon().Lon;
			geomap_zoom = 18-geomap_yahoo.getZoomLevel();
			geomap_center('YAHOO');
		}
	});
*/
	geomap_microsoft = new VEMap('geomap_microsoft');
	geomap_microsoft.SetDashboardSize(VEDashboardSize.Small);
	geomap_microsoft.LoadMap();

	geomap_microsoft.AttachEvent("onmousewheel", function wheelCallback(e) { return true; });

	geomap_center( 'ALL', geomap_latitude, geomap_longitude, geomap_zoom, geomap_map_type );

	GEvent.addListener(geomap_google, "moveend", function() {
		var now = new Date();
		if(now.getTime() > geomap_event_time+2000) {
//			debug('google event');
			var center = geomap_google.getCenter();
			geomap_center( 'GOOGLE', center.lat(), center.lng(), geomap_google.getZoom() );
//		} else {
//			debug('google event skipped');
		}
	});
		
	YEvent.Capture(geomap_yahoo, EventsList.endPan, function() { 
		var now = new Date();
		if(now.getTime() > geomap_event_time+2000) {
//			debug('yahoo event endPan');
			geomap_center( 'YAHOO', geomap_yahoo.getCenterLatLon().Lat, geomap_yahoo.getCenterLatLon().Lon, 18-geomap_yahoo.getZoomLevel() );
//		} else {
//			debug('yahoo event endPan skipped');
		}
	});

	YEvent.Capture(geomap_yahoo, EventsList.changeZoom, function() {
		var now = new Date();
		if(now.getTime() > geomap_event_time+2000) {
//			debug('yahoo event changeZoom');
			geomap_center( 'YAHOO', geomap_yahoo.getCenterLatLon().Lat, geomap_yahoo.getCenterLatLon().Lon, 18-geomap_yahoo.getZoomLevel() );
//		} else {
//			debug('yahoo event changeZoom skipped');
		}
	});

	geomap_microsoft.AttachEvent("onchangeview", function() { 
		var now = new Date();
		if(now.getTime() > geomap_event_time+5000) {
//			debug('microsoft event');
			center = geomap_microsoft.GetCenter();
			geomap_center( 'MICROSOFT', center.Latitude, center.Longitude, geomap_microsoft.GetZoomLevel() );
//		} else {
//			debug('microsoft event skipped');
		}
	});
}

function geomap_initialize_events()
{
	$("#section_geomap #button_geomap_vertical").click(function() {
		$(this).addClass("selected");
		$("#section_geomap #button_geomap_horizontal").removeClass("selected");
		$("#section_geomap").addClass("section_geomap_vertical");
		$("#section_geomap").removeClass("section_geomap_horizontal");
//		geomap_google.checkResize();
//		geomap_yahoo.resizeTo(new YSize(920,$('#geomap_yahoo').height()));
//		alert($('#section_geomap').width()+' '+$('#geomap_yahoo').height());
//		geomap_initialization(); alert('v');
		geomap_initialize_maps();
	});

	$("#section_geomap #button_geomap_horizontal").click(function() {
		$(this).addClass("selected");
		$("#section_geomap #button_geomap_vertical").removeClass("selected");
		$("#section_geomap").addClass("section_geomap_horizontal");
		$("#section_geomap").removeClass("section_geomap_vertical");
//		geomap_google.checkResize();
//		geomap_yahoo.resizeTo(new YSize(300,$('#geomap_yahoo').height()));
//		alert($('#geomap_yahoo').width()+' '+$('#geomap_yahoo').height());
		geomap_initialize_maps();
	});

	$("#section_geomap #button_geomap_show_google").click(function() {
		if( geomap_show_google ) {
			geomap_show_google = false;
			$(this).removeClass("selected");
			$('#section_geomap_google').hide();
		} else {
			geomap_show_google = true;
			$(this).addClass("selected");
			$('#section_geomap_google').show();
		}
	});

	$("#section_geomap #button_geomap_show_yahoo").click(function() {
		if( geomap_show_yahoo ) {
			geomap_show_yahoo = false;
			$(this).removeClass("selected");
			$('#section_geomap_yahoo').hide();
		} else {
			geomap_show_yahoo = true;
			$(this).addClass("selected");
			$('#section_geomap_yahoo').show();
		}
	});

	$("#section_geomap #button_geomap_show_microsoft").click(function() {
		if( geomap_show_microsoft ) {
			geomap_show_microsoft = false;
			$(this).removeClass("selected");
			$('#section_geomap_microsoft').hide();
		} else {
			geomap_show_microsoft = true;
			$(this).addClass("selected");
			$('#section_geomap_microsoft').show();
		}
	});
/*
	$('#section_geomap #button_geomap_synchronization_yes').click(function() {
		geomap_synchronization = true;
		$(this).addClass("selected");
		$('#button_geomap_synchronization_no').removeClass("selected");
	});

	$('#section_geomap #button_geomap_synchronization_no').click(function() {
		geomap_synchronization = false;
		$(this).addClass("selected");
		$('#button_geomap_synchronization_yes').removeClass("selected");
	});
*/
}

function floating_landmark_initialization()
{
	$('#section_floating_landmark').click(function() {
		hide_floating_window();
		$('#floating_window').remove();
	});
}

function more_reviews_request_initialization()
{
	$('#section_review_more_request #button_agreed').click(function() {
		hide_floating_window();
		window.location = '/'+$(this).parent().parent().attr('attr-country_folder')+'/opiniuj';
//		$('#floating_window').remove();
//		load_floating_window('/review_all/'+$(this).parent().parent().attr('attr-country_id'), review_all_initialization);
	});
}

function review_editor_initialization()
{
	$("#review_editor div.one_evaluation[attr-evaluation='"+$("#review_editor #field_evaluation").attr("value")+"']").addClass("selected");

	$("#review_editor div.one_evaluation").click(function() {
		$("#review_editor #field_evaluation").val( $(this).attr("attr-evaluation") );
		$("#review_editor div.selected").removeClass("selected");
		$(this).addClass("selected");
	});

	$('#review_editor #field_body').internal_label('Zapraszam do komentowania.');
	$('#review_editor #field_author').internal_label('Twoje imię / pseudonim');
	$('#review_editor #field_email').internal_label('Email');

	$('#review_editor_form').submit(function() {
		empty_body      = $('#review_editor_form #field_body').hasClass('internal_label');
		empty_author    = $('#review_editor_form #field_author').hasClass('internal_label');
		empty_email     = $('#review_editor_form #field_email').hasClass('internal_label');
		empty_delete	= !($('#review_editor_form #field_delete').attr("checked")==true);

		if(empty_delete && (empty_body || empty_author)) {
			return false;
		} else {
			$('#review_editor_form .internal_label').val('');
			return true;
		}
	});
}

function map_is_loaded()
{ //alert(9);
//	if (GBrowserIsCompatible()) { 
		google_map = new GMap2(document.getElementById('google_map'));
		google_map.addControl(new GSmallMapControl());
		google_map.addControl(new GMapTypeControl());
		google_map.enableScrollWheelZoom();
		if( $('#place_editor #field_latitude').val()==0 && $('#place_editor #field_longitude').val()==0 ) {
			google_map.setCenter( new GLatLng( 27.1667, 78.0167 ), 3);
		} else {
			google_map.setCenter( new GLatLng( parseFloat($('#place_editor #field_latitude').val()), parseFloat($('#place_editor #field_longitude').val()) ), parseInt($('#place_editor #field_zoom').val()));
		}
//		alert(google_map.getSize());
//	}
}

function refresh_google_map_mini()
{
	z = parseInt($('#place_editor #field_zoom').val());
	if( z>0 && z<=18) {
		var now = new Date();
		s = 'http://maps.google.com/staticmap?center='+$('#place_editor #field_latitude').val()+','+$('#place_editor #field_longitude').val()+'&zoom='+$('#place_editor #field_zoom').val()+'&size=100x118&key='+google_map_key+'&mandalay='+now.getTime();
		$('#place_editor #google_map_mini').attr('src',s);
	}
}

function place_editor_initialization()
{
/*
	$("#review_editor div.one_evaluation[attr-evaluation='"+$("#review_editor #field_evaluation").attr("value")+"']").addClass("selected");

	$("#review_editor div.one_evaluation").click(function() {
		$("#review_editor #field_evaluation").val( $(this).attr("attr-evaluation") );
		$("#review_editor div.selected").removeClass("selected");
		$(this).addClass("selected");
	});
*/
	$('#place_editor #field_name').internal_label('Nazwa');
	$('#place_editor #field_dopelniacz').internal_label('Dopełniacz');
	$('#place_editor #field_miejscownik').internal_label('Miejscownik');
	$('#place_editor #field_folder').internal_label('Folder');
	$('#place_editor #field_description').internal_label('Opis');
	$('#place_editor #field_coordinates').internal_label('Współrzędne');

	$('#place_editor #field_zoom').keyup(function() {
		refresh_google_map_mini();
	});

	$("#place_editor #field_coordinates").change(function() {
		refresh_google_map_mini();
	});

	$('#place_editor #field_coordinates').keyup(function() {
//		alert('change '+$("#place_editor #field_coordinates").val());
		var re = new RegExp( '^([0-9]{1,3})[^0-9]([0-9]{1,3})([^0-9]([0-9]{1,3}))?[^0-9]?([NnSs])[^0-9]?([0-9]{1,3})[^0-9]([0-9]{1,3})([^0-9]([0-9]{1,3}))?[^0-9]?([WwEe])$' );
		var m = re.exec( $("#place_editor #field_coordinates").val() );
		if (m == null) {
//			alert("No match");
			$("#place_editor #field_coordinates").addClass('error');
		} else {
			var s = "Match at position " + m.index + ":\n";
			for (i = 0; i < m.length; i++) {
				s = s + i+ ' ' + m[i] + "\n";
			}
			$("#place_editor #field_coordinates").removeClass('error');
			
//			latitude = (parseInt(m[1])+parseFloat(m[2]/60))*(m[5]=='S' || m[5]=='s'?-1:1);
			latitude = (parseInt(m[1])+parseFloat(m[2]/60)+parseFloat(m[4]>0?m[4]/360:0))*(m[5]=='S' || m[5]=='s'?-1:1);
			longitude = (parseInt(m[6])+parseFloat(m[7]/60)+parseFloat(m[9]>0?m[9]/360:0))*(m[10]=='W' || m[10]=='w'?-1:1);

			$('#place_editor #field_latitude').val(latitude);
			$('#place_editor #field_longitude').val(longitude);
			
			google_map.setCenter( new GLatLng( latitude, longitude) );
//			alert(s);  //  1 2 4 5 6 7 9 10
		}

//		$("#place_editor #field_thumbnail_id").val( $(this).attr("attr-picture_id") );
//		$("#place_editor #section_thumbnails img.selected").removeClass("selected");
//		$(this).addClass("selected");
	});

	$("#place_editor #section_thumbnails img").click(function() {
		$("#place_editor #field_thumbnail_id").val( $(this).attr("attr-picture_id") );
		$("#place_editor #section_thumbnails img.selected").removeClass("selected");
		$(this).addClass("selected");
	});

	$("#place_editor #button_set_coordinates").click(function() {
		var center = google_map.getCenter();
		$('#place_editor #field_latitude').val(center.lat());
		$('#place_editor #field_longitude').val(center.lng());
		$('#place_editor #field_coordinates').val(coordinates_to_string(center.lat(),'N','S')+' '+coordinates_to_string(center.lng(),'E','W'));
		refresh_google_map_mini();
	});

	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAlD798re0kTZbjdflpeoVTxRGqqh-D6mRIPdDfLAY22rxga22FxS7L8HbY1ESlQCl60SV5tHE6te__A&async=2&callback=map_is_loaded";
	document.getElementsByTagName("head")[0].appendChild(script);

/*	if (GBrowserIsCompatible()) { alert(9);
		geomap_google = new GMap2(document.getElementById('google_map')); 
		geomap_google.addControl(new GLargeMapControl()); 
		geomap_google.addControl(new GMapTypeControl()); 
		geomap_google.setCenter( new GLatLng( 100, 100 ), 8);
	}
*/

/*
	$('#review_editor_form').submit(function() {
		empty_body      = $('#review_editor_form #field_body').hasClass('internal_label');
		empty_author    = $('#review_editor_form #field_author').hasClass('internal_label');
		empty_delete	= !($('#review_editor_form #field_delete').attr("checked")==true);

		if(empty_delete && (empty_body || empty_author)) {
			return false;
		} else {
			$('#review_editor_form .internal_label').val('');
			return true;
		}
	});
*/
}

function contact_initialization()
{
	$("#section_contact").click(function() {
		$.fn.dialog_hide();
	});
}

function picture_editor_initialization()
{
	$('#picture_editor #preview_picture img').upload({
		name: 'file',
		method: 'post',
		enctype: 'multipart/form-data',
		action: '/picture_upload/PICTURE',
		onSubmit: function() {
			$('#picture_editor #preview_picture .dimensions').text('Uploading...');
		},
		onComplete: function(data) {
			var now = new Date();
			$('#picture_editor #preview_picture img').attr('src','/thumbnail/temp/100?'+now.getTime());
			$('#picture_editor #preview_picture .dimensions').html(data);
			$('#picture_editor #field_picture_uploaded').val('Y');
		}
	});
	$('#picture_editor #preview_thumbnail img').upload({
		name: 'file',
		method: 'post',
		enctype: 'multipart/form-data',
		action: '/picture_upload/THUMBNAIL',
		onSubmit: function() {
			$('#picture_editor #preview_thumbnail .dimensions').text('Uploading...');
		},
		onComplete: function(data) {
			var now = new Date();
			$('#picture_editor #preview_thumbnail img').attr('src','/thumbnails/temp.jpg?'+now.getTime());
			$('#picture_editor #preview_thumbnail .dimensions').html(data);
			$('#picture_editor #field_thumbnail_uploaded').val('Y');
		}
	});
}

function note_editor_initialization()
{
}

function distances_editor_initialization()
{
	$('#distances_editor #field_author').internal_label('Twoje imię / pseudonim');
	$('#distances_editor #field_email').internal_label('Email');

	$('#distances_editor_form select').change(function() {
		if( $(this).val()=='0' ) {
			$(this).removeClass('modified');
		} else {
			$(this).addClass('modified');
		};
	});

	$('#distances_editor_form').submit(function() {
		empty_author    = $('#distances_editor_form #field_author').hasClass('internal_label');
		empty_email     = $('#distances_editor_form #field_email').hasClass('internal_label');
		empty_delete	= !($('#distances_editor_form #field_delete').attr("checked")==true);

		if(empty_delete && (empty_body || empty_author)) {
			return false;
		} else {
			$('#distances_editor_form .internal_label').val('');
			return true;
		}
	});
}

function comment_editor_initialization()
{
	$('#comment_form_body').internal_label('Zapraszam do komentowania');
	$('#comment_form_author').internal_label('Twoje imię / pseudonim');

	$("#comment_editor_form").submit(function() {
		body_empty       = $('#comment_form_body').is('.internal_label');
		author_empty     = $('#comment_form_author').is('.internal_label');
		comment_id_empty = ($('#comment_form_comment_id').val() == '');
		
//		alert(body_empty + '/' + author_empty + '/' + review_id_empty);
		
		if(comment_id_empty && (body_empty || author_empty)) {
			return false;
		} else if ((body_empty && !author_empty) || (!body_empty && author_empty)) {
			return false;
		}
		if(body_empty) {
			$('#comment_form_body').val('');
		}
		if(author_empty) {
			$('#comment_form_author').val('');
		}
		return true;
	});
}

function landmark_editor_initialization()
{
	$('#landmark_editor #field_description').internal_label('Opis miejsca');
	$('#landmark_editor #field_author').internal_label('Twoje imię / pseudonim');
	if($('#section_geomap #geomap_layout_buttons #localisation').attr('attr-place_id')) {
		$('#landmark_editor #field_place_id').val($('#section_geomap #geomap_layout_buttons #localisation').attr('attr-place_id'));
	}

	$("#landmark_editor_form").submit(function() {
		description_empty = $('#field_description').is('.internal_label');
		author_empty      = $('#field_author').is('.internal_label');
		landmark_id_empty = ($('#landmark_form_landmark_id').val() == '');

		if(landmark_id_empty && (description_empty || author_empty)) {
			return false;
		} else if ((description_empty && !author_empty) || (!description_empty && author_empty)) {
			return false;
		}
		if(description_empty) {
			$('#field_description').val('');
		}
		if(author_empty) {
			$('#field_author').val('');
		}
		return true;
	});
}

function load_floating_window(url, initialize, transparent)
{
	if(transparent) {
		$('body').append('<div id="overlay"></div><div id="floating_window"><div id="container"></div></div><img id="loading_indicator" src="/pic/ajax-loader.gif" />');
	} else {
		$('body').append('<div id="overlay"></div><table id="floating_window"><tbody><tr><td id="top_left"></td><td id="top_middle"></td><td id="top_right"></td></tr><tr><td id="middle_left"></td><td id="middle_middle"><div id="container"></div></td><td id="middle_right"></td></tr><tr><td id="bottom_left"></td><td id="bottom_middle"></td><td id="bottom_right"></td></tr></tbody></table><img id="loading_indicator" src="/pic/ajax-loader.gif" />');
	}

	if($.browser.msie) {
		$('#overlay').show();
		$('#loading_indicator').show();
	} else {
		$('#overlay').fadeIn('slow');
		$('#loading_indicator').fadeIn('slow');
	}

	$('#loading_indicator').css('left',($(window).width()-$('#loading_indicator').width())/2);
	$('#loading_indicator').css('top',($(window).height()-$('#loading_indicator').height())/2);

//	$('#floating_window').css('left',($(window).width()-$('#floating_window').width())/2);
//	$('#floating_window').css('top',($(window).height()-$('#floating_window').height())/2);

	$.post( url, {}, function(data)
		{
			$('#loading_indicator').fadeOut('fast');
			$('#floating_window #container').html( data );
			if($.browser.msie) {
				$('#floating_window').show();
			} else {
				$('#floating_window').fadeIn('slow');
			}
			$('#floating_window').css('left',($(window).width()-$('#floating_window').width())/2);
			$('#floating_window').css('top',($(window).height()-$('#floating_window').height())/2);
			$("#floating_window #button_cancel").click(function() { $.fn.dialog_hide(); });
			initialize();
		}
	);
}

function show_floating_message( initialize )
{
	$('body').append('<div id="overlay"></div><table id="floating_window"><tbody><tr><td id="top_left"></td><td id="top_middle"></td><td id="top_right"></td></tr><tr><td id="middle_left"></td><td id="middle_middle"><div id="container"></div></td><td id="middle_right"></td></tr><tr><td id="bottom_left"></td><td id="bottom_middle"></td><td id="bottom_right"></td></tr></tbody></table><img id="loading_indicator" src="/pic/ajax-loader.gif" />');

	if($.browser.msie) {
		$('#overlay').show();
	} else {
		$('#overlay').fadeIn('slow');
	}

	$('#section_message').appendTo('#floating_window #container');

	if($.browser.msie) {
		$('#floating_window').show();
	} else {
		$('#floating_window').fadeIn('slow');
	}
//alert($(window).height()+' '+$(window).innerHeight( ));
	$('#floating_window').css('left',($(window).width()-$('#floating_window').width())/2);
	$('#floating_window').css('top',($(window).height()-$('#floating_window').height())/2);
	$("#floating_window #button_cancel").click(function() { $.fn.dialog_hide(); });
	$("#floating_window #button_ok").click(function() { $.fn.dialog_hide(); });
	
	if(initialize) {
		initialize();
	}
}

function hide_floating_window()
{
	if($.browser.msie) {
		$('#overlay').show();
	} else {
		$('#overlay').fadeOut('slow');
	}
}

function load_picture_editor( mode, id )
{
	var url = '/picture_editor/'+mode+'/'+id;
	load_floating_window(url, picture_editor_initialization);
}

function load_comment_editor( mode, id )
{
	var url = '/comment_editor/'+mode+'/'+id;
	load_floating_window(url, comment_editor_initialization);
}

function load_review_editor( mode, object_id, evaluation_id)
{
	var url = '/review_editor/'+mode+'/'+object_id+'/'+evaluation_id;
	load_floating_window(url, review_editor_initialization);
}


/*
var buf;

function load_review_editor( container, mode, object_id, evaluation_id)
{
	var url = '/review_editor/'+mode+'/'+object_id+'/'+evaluation_id;
	load_floating_window(container, url, review_editor_initialization);
}
*/

function distribute_reviews()
{
	return;
/*	if($('#section_notes').length && $('#section_notes').height()>0) {
		notes = $('#section_notes').height();
	} else {
		notes = 0;
	}

	if($('#section_country_gallery').length && $('#section_country_gallery').height()>0) {
		country_gallery = 200;
	} else {
		country_gallery = 0;
	}

	if($('#section_place_on_map').length && $('#section_place_on_map').height()>0) {
		place_on_map = 164;
	} else {
		place_on_map = 0;
	}

	if($('#section_review_request').length && $('#section_review_request').height()>0) {
		review_request = 178;
	} else {
		review_request = 0;
	}
	
	if($('#section_landmarks').length && $('#section_landmarks').height()>0) {
		review_landmarks = $('#section_landmarks').height();
	} else {
		review_landmarks = 0;
	}
	
	max_height = notes - country_gallery - place_on_map - review_request - review_landmarks;

//	alert(max_height + '=' + notes +'-'+ country_gallery +'-'+ place_on_map +'-'+ review_request);
	
	if(max_height < 250) {
		max_height = 0;
	}
	
	latest_height = $('#section_latest_reviews').height();
*/
	one_height    = 0;
	two_height    = 0;
	three_height  = 0;

	one_two_three_counter = 0;

	$('div.one_review').each(function (i) {
		if(one_height <= two_height && one_height <= three_height) {
			$(this).appendTo('#reviews_column_one');
			one_height = $('#reviews_column_one').height();
			one_two_three_counter++;
		}  else if(two_height <= three_height) {
			$(this).appendTo('#reviews_column_two');
			two_height = $('#reviews_column_two').height();
			one_two_three_counter++;
		} else {
			$(this).appendTo('#reviews_column_three');
			three_height = $('#reviews_column_three').height();
			one_two_three_counter++;
		}
	})

	if(one_two_three_counter == 0) {
		$('#section_reviews').remove();
	}
	
//	$('#reviews_list').remove();
}

function min(a,b) {
	if(a<b) return a;
	else return b;
}

function tooltipShow(placeID)
{
	$("#map_tooltip_"+placeID).hide();

	$("#map_point_"+placeID).css('z-index',20);
	var mapWidth = $("#map").width();
	var mapHeight = $("#map").height();
	var tooltipWidth = $("#map_tooltip_"+placeID).width();
	var tooltipHeight = $("#map_tooltip_"+placeID).height();
	var pointX = parseInt($("#map_point_"+placeID).css('left'));
	var newX;
	var newY;

	newY = parseInt($("#map_point_"+placeID).css('top')) - tooltipHeight - 9;

	if(pointX > (tooltipWidth)) {
		newX = pointX - (tooltipWidth) - 6;
		arrow = "#map_tooltip_arrow_se";
		arrowX = newX+1;
		arrowY = newY+tooltipHeight-7;
	} else {
		newX = pointX+17;
		arrow = "#map_tooltip_arrow_sw";
		arrowX = newX-10;
		arrowY = newY+tooltipHeight-7;
	}

	$("#map_tooltip_"+placeID).css('left',newX);
	$("#map_tooltip_"+placeID).css('top',newY);

	$(arrow).css('left',arrowX);
	$(arrow).css('top',arrowY);

	if($.browser.msie) {
		$("#map_tooltip_"+placeID).show();
		$("#map_tooltip_arrow_sw").show();
		$("#map_tooltip_arrow_se").show();
	} else {
		$("#map_tooltip_"+placeID).fadeIn('fast');
		$("#map_tooltip_arrow_sw").fadeIn('fast');
		$("#map_tooltip_arrow_se").fadeIn('fast');
	}
} 

function tooltipHide(placeID)
{
	$("#map_tooltip_"+placeID).hide();
	$("#map_tooltip_arrow_sw").hide();
	$("#map_tooltip_arrow_se").hide();

	$("#map_point_"+placeID).css('z-index',0);
	$("#map_tooltip_"+placeID).css('left',-99999);
	$("#map_tooltip_arrow_sw").css('left',-99999);
	$("#map_tooltip_arrow_se").css('left',-99999);	
}
