var gargzdai_map = new google.maps.LatLng(59.69, 16.36);
var printit = new google.maps.LatLng(55.69768155401541, 21.365350484848022);

var marker;
var map;

var directionDisplay;
var directionsService = new google.maps.DirectionsService();
  
  

  function initialize() {
	if(document.getElementById("map_contacts_print-it")){
		
		//for contact page 
		
	  
		 var printitsigncontent = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h1 id="firstHeading" class="firstHeading"><img src="http://www.print-it.eu/logo/PRINT-IT-logo20.gif" /></h1>'+
    '<div id="bodyContent">'+
    'Gamyklos g. 27, Gargzdai,<br /> Lithuania'+    
    '</div>'+
    '</div>';
	
		var infowindow = new google.maps.InfoWindow({content: printitsigncontent});
	  
    	var myOptions = {
      		zoom: 4,
      		center: gargzdai_map,
	  		disableDefaultUI: true,
	  		panControl: false,
	  		zoomControl: false,
	  		zoomControlOptions: {
		  	style: google.maps.ZoomControlStyle.SMALL},
      		mapTypeId: google.maps.MapTypeId.ROADMAP
    	};
		
    	var map = new google.maps.Map(document.getElementById("map_contacts_print-it"), myOptions);
		
		var marker = new google.maps.Marker({
			map:map,
			draggable:true,
			animation: google.maps.Animation.DROP,
			position: printit,
			title: 'PRINT IT'
			});
		
		google.maps.event.addListener(marker, 'click', function() {
      		infowindow.open(map,marker);
    		});
		}
		else if (document.getElementById("map_logistics")){
			
			//for logistics
			
			

    		directionsDisplay = new google.maps.DirectionsRenderer();
    		var ee_map = new google.maps.LatLng(59.69, 16.36);
    		var myOptions = {
      			zoom:5,
      			mapTypeId: google.maps.MapTypeId.ROADMAP,
      			center: ee_map,
				disableDefaultUI: true,
	  			panControl: false,
	  			zoomControl: false
    		}
    		map = new google.maps.Map(document.getElementById("map_logistics"), myOptions);
    		directionsDisplay.setMap(map);			
		}
  }
  
  function calcRoute(rid) {
	if (rid == 1){
		var request = {
        origin:"gargzdai, lithuania", 
		destination: "Oslo, norway",
		waypoints: [
					{location:"Klaipeda , lithuania",stopover:false},
					{location:"Nynäshamn , sweden",stopover:true}
					],
		provideRouteAlternatives: true,
		travelMode: google.maps.DirectionsTravelMode.DRIVING,
		unitSystem: google.maps.DirectionsUnitSystem.METRIC 
    	};
	}
	
	else if (rid == 2){
		var request = {
        origin:"gargzdai, lithuania", 
		destination: "Stockholm, sweden",
		waypoints: [
					{location:"Klaipeda , lithuania",stopover:false},
					{location:"Nynäshamn , sweden",stopover:true}
					],
		provideRouteAlternatives: true,
		travelMode: google.maps.DirectionsTravelMode.DRIVING,
		unitSystem: google.maps.DirectionsUnitSystem.METRIC 
    	};
	}
	
	else if (rid == 3){
		var request = {
        origin:"gargzdai, lithuania", 
		destination: "Varnamo, sweden",
		waypoints: [
					{location:"Klaipeda , lithuania",stopover:false},
					{location:"karlshamn , sweden",stopover:true}
					],
		provideRouteAlternatives: true,
		travelMode: google.maps.DirectionsTravelMode.DRIVING,
		unitSystem: google.maps.DirectionsUnitSystem.METRIC 
    	};
	}
	
	else if (rid == 4){
		var request = {
        origin:"gargzdai, lithuania", 
		destination: "Copenhagen, denmark",
		waypoints: [
					{location:"Klaipeda , lithuania",stopover:false},
					{location:"karlshamn , sweden",stopover:true}
					],
		provideRouteAlternatives: true,
		travelMode: google.maps.DirectionsTravelMode.DRIVING,
		unitSystem: google.maps.DirectionsUnitSystem.METRIC 
    	};
	}
	
	else if (rid == 5){
		var request = {
        origin:"gargzdai, lithuania", 
		destination: "helsinki, norway",
		provideRouteAlternatives: false,
		travelMode: google.maps.DirectionsTravelMode.DRIVING,
		unitSystem: google.maps.DirectionsUnitSystem.METRIC 
    	};
	}
	
	else if (rid == 6){
		var request = {
        origin:"gargzdai, lithuania", 
		destination: "warsawa, poland",
		provideRouteAlternatives: false,
		travelMode: google.maps.DirectionsTravelMode.DRIVING,
		unitSystem: google.maps.DirectionsUnitSystem.METRIC 
    	};
	}
	
    directionsService.route(request, function(response, status) {
      if (status == google.maps.DirectionsStatus.OK) {
        directionsDisplay.setDirections(response);
      }
    });
  }
