$(function() {
	// Contacts
	var err = $("#error").text();
	if (err != '') { $("#error").hide().addClass("msg").fadeIn(1000); }
	else { $("#error").hide().text("").removeClass("msg"); }

	var err = $("#success").text();
	if (err != '') { $("#success").hide().addClass("msg").fadeIn(1000, function() { $(this).fadeOut(15000); }); }
	else { $("#success").hide().text("").removeClass("msg"); }

	$("#userpost").bind("focus blur", function() {
		if ( $(this).val() == "Моля, пишете на кирилица!" ) { $(this).val(""); }
	});	

	$("#about").hide();
	$("a#showAbout").click(function(){
		$("#about").slideDown("slow");
		$("a#showAbout").hide();
		$('html, body').animate({
			scrollTop: $("#about").offset().top
		}, 500);
		return false;
	});
	$("a#hideAbout").click(function(){
		$("#about").slideUp("slow");
		$("a#showAbout").show();
		return false;
	});

	// Captcha
	var randomNumber = 1000000;
	randomNumber = Math.floor(Math.random() * 1000000);
	
	$("#photos").load(root + "ajax/get-contacts-photos.php", '', function() {
		$(".fancyZoom").fancyZoom({closeOnClick: true});
	});

	// Google Maps
	function initialize() {
	//<![CDATA[
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(42.69402068516969, 23.321518520736694), 17);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());

		// Create our "tiny" marker icon
		var customIcon = new GIcon(G_DEFAULT_ICON);
		customIcon.image = root + "images/icons/i-google-maps-contacts.png";
		customIcon.iconSize = new GSize(210, 70);
		customIcon.shadow = false;
		// Set up our GMarkerOptions object
		markerOptions = { icon: customIcon };
		// Add marker to the map
		var latlng = new GLatLng(42.69402068516969, 23.321518520736694);
		map.addOverlay(new GMarker(latlng, markerOptions));
      }
    }
	//]]>

	if (!strstr(root, 'localhost')) {
		initialize();
		$(window).bind("unload", function() { GUnload(); });
	}
});