$(document).ready(function() {
	
	
	$(".superlink").css("cursor", "pointer");
	
	$(".superlink .forsuper").each(function(i) {
		//	this.innerHTML = this + " is the element, " + index + " is the position";
		url = $(this).attr('href');
		//console.log($(this).parent());
		$(this).parent().click(function() {
			window.location = $(this).children('.forsuper').attr('href');;
		});
		//console.log($(this).parent());
	});
	initialize();
	/*$("#block_big").click(function() {
		window.location = $("#block_big .subtitle").attr('href');
	});*/
});




	var visible_bounds = new Array();
	var all_bounds = new Array();
	var all_bound_data = new Array();
	var map;
	var tinyIcon;
	function createMarker(point, infohtml, model, icon) {
		if (model.substr(0,3) == "GOT" || model.substr(0,2) == "RR") { 
			markerOptions = { icon:tinyIcon };
		} else {
			markerOptions = { icon:regIcon };
		}
		var marker = new GMarker(point, markerOptions);
		GEvent.addListener(marker, 'click', function() {
			marker.openInfoWindowHtml(infohtml);
		});
		GEvent.addListener(marker, 'mouseover', function() {
			jQuery.each(all_bounds, function() {
				this.hide();
			}); 
			if (all_bounds[model]) {
				all_bounds[model].show();
			} else {
				createBounds(model,all_bound_data[model][0],all_bound_data[model][1],all_bound_data[model][2],all_bound_data[model][3]);
			}
		});
		GEvent.addListener(marker, 'mouseout', function() {
			all_bounds[model].hide();
		});
		return marker;
	}
	
	function createBounds(model,n,s,e,w) {
		//console.log("create bounds " + model + " " + n + " " + s + " " + e + " " + w);
		var polygon = new GPolygon([
		    new GLatLng(n,w),
		    new GLatLng(n,e),
		    new GLatLng(s,e),
		    new GLatLng(s,w),
		    new GLatLng(n,w)
		  ], '#E4652B', 1, 1, '#E4652B', 0.4);
		map.addOverlay(polygon);
		all_bounds[model] = polygon;
		//console.log(all_bounds[model]);
		// #E4652B ffb30f
		all_bounds[model].show();
	}
	
	function show_bounds(model) {
		all_bounds[model].show();
	}
	
	function hide_visible_bounds() {
		jQuery.each(visible_bounds, function(i, val) {
			map.addOverlay(boundary);
		}); 
	}
	