// JavaScript Document
// Scrooling tom images	
	
	/*var imageCount = 0;*/
	var delay = 5000;
	
Drupal.behaviors.myModuleBehavior = function (context) {
		
	// Map replacement
	var mapContainerBig = $("#openlayers-views-map-auto-id-wildmob_map_projects_view_OpenLayers_Container");
	if (mapContainerBig.length)
		mapContainerBig.append('<div class="wildmob-map-big"></div>');
	var mapContainerSmall = $("#openlayers-cck-formatter-map-field-location-0_OpenLayers_Container");
	if (mapContainerSmall.length)
		mapContainerSmall.append('<div class="wildmob-map-small"></div>');
	
	// on hover
	if ((document.getElementsByTagName("rect").length > 0) || (document.getElementsByTagName("image").length > 0))
	{
	
		var oElement;
		
		if (document.getElementsByTagName("rect").length > 0)
		{
			oElement = $('rect'); // for IE
		}
		else if (document.getElementsByTagName("image").length > 0)
		{
			oElement = $('image'); // other browsers. Tested in Safari, Opera, Firefox, Chrome
		}
	
		oElement.mouseover(function(){
			//$('image').each().attr("href", "sites/default/files/maps_resources/hand_o_33x30.png"); 
			
			try
			{
				
				// Display tree iamge
				var features = OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features;
				for(var iCount = 0; iCount < features.length; iCount++)
				{
					geometry_id = OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].geometry.id;
					
					id = OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].data.nid;
					current_hover_div = $(".view-project-hovers .views-row .nid" + id).parent().parent().parent();
					
					if ($(this).attr("id") == geometry_id)
					{
						// change hover image
						OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].style.externalGraphic = "/sites/default/files/maps_resources/hand_o_33x30.png";
						OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].style.cursor = "pointer";
						OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].style.hoverPointRadius = 5;
						current_hover_div.show();
					}
					else
					{
						OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].style.externalGraphic = "/sites/default/files/maps_resources/hand_s_33x30.png";
						//OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].style.cursor = "inherit";
						//OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].style.hoverPointRadius = 1;
						current_hover_div.hide();
					}
					
					
				}
			
				OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].redraw();
				//alert();
			}
			catch(e)
			{
			}
		});
		
		// add clicking finction to redirect to project
		oElement.click(function(){
			
			// loop through points and redirect on correct one
			var features = OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features;
			for(var iCount = 0; iCount < features.length; iCount++)
			{
				//var opacity = 0;
				//var display = "none";
				//alert($(this).attr("id") + " >> ");
				geometry_id = OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].geometry.id;
				if ($(this).attr("id") == geometry_id)
				{
					// TODO :: investigate why object property called :: unknown_rendered
					link_href = OL.maps["openlayers-views-map-auto-id-wildmob_map_projects_view"].layers.openlayers_views_layer_wildmob_map_projects_view.map.layers[1].features[iCount].data.unknown_rendered;
					document.location.href = link_href;
				}
			}
		});
	}

}

