$(document).ready(function() {
	$("a#single_1").fancybox({
		'titleShow'     : true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
	});
	$("a.group").fancybox({});
	$("#mapka").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titleShow'     	: false,
		'type'				: 'iframe',
		'width'				: 860,
		'height'			: 480,
		'autoDimensions'	: true
	});
	$("a.eo").fancybox({
		'type'				: 'iframe',
		'width'				: 570,
		'height'			: 570,
		'titleShow'     	: false,
		'scrolling'   		: 'no',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
	});
	$('span').cluetip({closeText: '<img src="images/close.png" alt="Zamknij" />'});
	$('#txt').cluetip({
		splitTitle: '|',
		cluetipClass: 'jtip',
		width: '200px',
		dropShadow: false,
		arrows: false,
		sticky: false,
		tracking: true,
		positionBy: 'mouse',
		clickThrough: true,
		topOffset: 25
	});
	$('.txt').cluetip({
		splitTitle: '|',
		cluetipClass: 'jtip',
		width: '200px',
		dropShadow: false,
		arrows: false,
		sticky: false,
		tracking: true,
		positionBy: 'mouse',
		clickThrough: true,
	});
	$('.mimg').cluetip({
		cluetipClass: 'jtip',
		width: '150px',
		dropShadow: false,
		arrows: false,
		sticky: false,
		tracking: true,
		positionBy: 'mouse',
		clickThrough: true,
		showTitle: false,
  });

});

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById('map'));
        map.setCenter(new GLatLng(52.539991,19.7345475), 14);
        map.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT));
        map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT));
        map.setMapType(G_NORMAL_MAP);
        map.enableDoubleClickZoom();
        keyboardhandler = new GKeyboardHandler(map);
        toPoint = map.getCenter();
        gdir=new GDirections(map, document.getElementById('directions'));
        var point = new GLatLng(52.539991, 19.7345475);
        var marker = createMarker(point,'<b>Firma \"STANPOL\" Export-Import</b><hr>ul. Graniczna 53<BR>09-407 P&#322;ock');
        map.addOverlay(marker);
        GEvent.trigger(marker, 'click');
      }
    }
    function createMarker(point, label) {
      var marker = new GMarker(point);
      GEvent.addListener(marker,"click",function() { marker.openInfoWindowHtml(label);});
      return marker;
    }
    function showDirections() {
      var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";
      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Nieznany adres: Nie mo¿na odnale¼æ podanej lokalizacji.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";
      reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";
      reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";
      GEvent.addListener(gdir, "error", function() {
          var code = gdir.getStatus().code;
          var reason="Code "+code;
          if (reasons[code]) {
          	reason = reasons[code];
          }
          alert(reason);
      });
     var toAddr = "Firma STANPOL"+"@"+toPoint.lat() + "," + toPoint.lng();
     // selectcoordinate=177
     var opts = {};
		if (document.getElementById("walk").checked) {
           opts.travelMode = G_TRAVEL_MODE_WALKING;
        }
        if (document.getElementById("highways").checked) {
           opts.avoidHighways = true;
        }
     opts.locale = "pl_PL";
     var fromAddr = document.inputFormDirection.fromAddr.value;
     gdir.load("from: "+fromAddr+" to: "+toAddr, opts);
   }

$(function() {
	$("div.tabs").tabs(".images > div", {
		effect: 'fade',
		fadeOutSpeed: "slow",
		rotate: true
	}).slideshow();
});
