//Google Maps code - display selected jobs on the map
window.addEventListener?window.addEventListener("load",initialize,false):window.attachEvent("onload",initialize);


var map;
var geocoder;

function initialize() {
geocoder = new google.maps.Geocoder();
var myLatlng = new google.maps.LatLng(53.770255, -2.476206);//centre map on head office or use 54.792906, -4.321192 - acutal map centre
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.SATELLITE,
navigationControl: true,
scaleControl: false,
mapTypeControl:false
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);

setMarkers(map);

}//end function


/*var infowindow = new google.maps.InfoWindow(
{ content: '<h1 style="margin:1px 0px 0px 0px;font-family:arial,helvetica,sans-serif;color:#cc0000">Cronshaw Head Office</h1>'+
	   '<img src="images/thumbs/ho.png" style="float:left;width:75px;height:75px;border: solid 1px #cc0000;font-size:0.7em;margin:0px 3px 20px 0px;display:block;" alt="Our Head Office"/>'+
	   '<p style="font-size:0.7em;color:#000000;margin:0px 0px 5px 0px">Vale Mill<br />Emerald Street<br />Blackburn<br />Lancashire<br />BB1 9QJ<br />Tel: 0845 250 0780</p>',
size: new google.maps.Size(200,100),
});
*/

//long lat arrays featuring titles and descriptions
//format - title, lat, long, image, description, flag, shadow





function setMarkers(map) {
// Add markers to the map
attachHeadOffice(map,jobs[0]);
for (var i = 1; i < jobs.length; i++) {
		    attachInfo(map, jobs[i]);
		    }
		    };
		    
 function attachHeadOffice(map, job) {
		    
 		    var myLatLng = new google.maps.LatLng(job[1], job[2]);
		    var image = new google.maps.MarkerImage(job[5],
		    new google.maps.Size(20, 24),
		    new google.maps.Point(0,0),
		    new google.maps.Point(10, 24));
		    //do shadow
		    var shadow = new google.maps.MarkerImage('images/maps/shadow.png',
		    // The shadow image is larger in the horizontal dimension
		    // while the position and offset are the same as for the main image.
		    new google.maps.Size(54,33),
		    new google.maps.Point(0,0),
		    new google.maps.Point(10, 28));


		    var marker = new google.maps.Marker({
		    position: myLatLng,
		    map: map,
		    title: job[0],
		    icon: image,
		    shadow: shadow,
		    zIndex: job[6]
		       });
		    var infowindow = new google.maps.InfoWindow(
		    { content: '<h1 style="margin:2px auto;text-align:center;font-family:arial,helvetica,sans-serif;color:#cc0000">'+job[0]+'</h1>'+job[3]+'<p style="font-size:0.8em;color:#000000;margin:0px 0px 5px 0px">'+job[4]+'</p>',
		    size: new google.maps.Size(200,100)
			 });
		    google.maps.event.addListener(marker, 'click', function()
		    {
		    infowindow.open(map,marker);
		    });
		    }
		    
function attachInfo(map, job) {
		    
 		    var myLatLng = new google.maps.LatLng(job[1], job[2]);
		    var image = new google.maps.MarkerImage(job[5],
		    new google.maps.Size(50, 27),
		    new google.maps.Point(0,0),
		    new google.maps.Point(25, 27));
		    //do shadow
		    var shadow = new google.maps.MarkerImage('images/maps/vanshadow.png',
		    // The shadow image is larger in the horizontal dimension
		    // while the position and offset are the same as for the main image.
		    new google.maps.Size(72,38),
		    new google.maps.Point(0,0),
		    new google.maps.Point(19,37));


		    var marker = new google.maps.Marker({
		    position: myLatLng,
		    map: map,
		    title: job[0],
		    icon: image,
		    shadow: shadow,
		    zIndex: job[6]
		       });
		    var infowindow = new google.maps.InfoWindow(
		    { content: '<h1 style="margin:2px auto;text-align:center;font-family:arial,helvetica,sans-serif;color:#cc0000">'+job[0]+'</h1>'+job[3]+'<p style="font-size:0.8em;color:#000000;margin:0px 0px 5px 0px">'+job[4]+'</p>',
		    size: new google.maps.Size(200,100)
		    });
		    google.maps.event.addListener(marker, 'click', function()
		    {
		    infowindow.open(map,marker);
		    });
		    }
    
	
