//Open a link on a click fur the main menu.
function openLink(link)
{
	window.open(link, '_self');
}

//Show the network map from google maps.
function showNetworkMap()
{
	//Distributors array
	//Coordonates obtains from http://itouchmap.com/latlong.html
	var distributors = new Array();
	distributors.push(new Array(46.147057,-70.906059)); //Saint-Victor
	distributors.push(new Array(46.909137,-71.385577)); //Lac St-Charles,
	distributors.push(new Array(45.570882,-74.09951)); //Saint-Benoit
	distributors.push(new Array(45.624741,-72.950188)); //Saint-Hyacinthe
	distributors.push(new Array(45.849083,-70.636969)); //Saint-Gédéon
	distributors.push(new Array(45.885036,-72.764355)); //Saint-Guillaume
	distributors.push(new Array(46.765223,-71.689768)); //Pont-Rouge
	distributors.push(new Array(45.364478,-73.57264)); //Saint-Constant
	distributors.push(new Array(45.207784,-72.749826)); //Cowansville
	distributors.push(new Array(45.398697,-72.722116)); //Granby
	distributors.push(new Array(45.404826,-71.892876)); //Sherbrooke
	distributors.push(new Array(45.633333,-72.566667)); //Action Vale
	distributors.push(new Array(47.835877,-69.536136)); //Rivière du loup
	distributors.push(new Array(45.108683,-71.83157)); //Coaticook
	distributors.push(new Array(45.88116,-71.943945)); //Tingwick
	distributors.push(new Array(45.962879,-71.821636)); //Chesterville
	distributors.push(new Array(45.533791,-72.048801)); //St-Francois-Xavier-De-Brompton
	distributors.push(new Array(46.058159,-71.964523)); //Victoriaville
	distributors.push(new Array(45.775778,-71.938638)); //Asbestos
	distributors.push(new Array(46.21822,-70.775667)); //Beauceville
	distributors.push(new Array(45.737819,-71.807095)); //Wotton
	distributors.push(new Array(47.684499,-68.895754)); //Cabano
	distributors.push(new Array(47.365386,-70.037873)); //La Pocatière
	distributors.push(new Array(45.35,-73.15)); //St-Brigide d'Iberville
	distributors.push(new Array(47.760448,-69.479129)); //St-Antonin
	distributors.push(new Array(45.95949,-70.656531)); //St-Martin
	distributors.push(new Array(46.616267,-72.292514)); //St-Prosper
	distributors.push(new Array(46.713764,-70.887562)); //St-Gervais
	distributors.push(new Array(46.877784,-71.192076)); //Beauport
	distributors.push(new Array(45.969144,-70.938059)); //La Guadeloupe
	distributors.push(new Array(46.046888,-71.360775)); //Black Lake
	distributors.push(new Array(46.219445,-71.772135)); //Plessisville
	distributors.push(new Array(47.128453,-70.371089)); //L'Islet sur Mer
	distributors.push(new Array(46.354519,-72.58215)); //Trois-Rivièves
	distributors.push(new Array(46.802071,-71.244926)); //Québec
	distributors.push(new Array(46.581827,-71.219664)); //Ste-Marie de Beauce
	distributors.push(new Array(46.116667,-70.666667)); //St-Georges
	distributors.push(new Array(46.08604,-70.861503)); //St-Ephrem
	distributors.push(new Array(46.300272,-71.654576)); //Laurierville
	distributors.push(new Array(46.837596,-70.851779)); //La Durantaye
	distributors.push(new Array(45.65,-74.1)); //Mirabel
	distributors.push(new Array(46.942236,-71.299511)); //Lac Beauport
	distributors.push(new Array(46.410578,-70.348593)); //Ste-Justine
	distributors.push(new Array(46.576899,-70.290234)); //St-Magloire
	distributors.push(new Array(46.739894,-70.580246)); //Armagh
	distributors.push(new Array(45.591904,-71.126277)); //Milan
	distributors.push(new Array(45.710332,-71.157835)); //Stornoway
	distributors.push(new Array(45.583333,-70.883333)); //Lac Mégantic
	distributors.push(new Array(47.589849,-69.731732)); //Ste-Hélène
	distributors.push(new Array(45.242345,-71.826976)); //Compton
	distributors.push(new Array(46.966667,-70.55)); //Montmagny
// 	distributors.push(new Array()); //Coop St-Francois,St-Francois,
	distributors.push(new Array(46.861472,-71.357111)); //Wendake
	distributors.push(new Array(46.925368,-70.732037)); //Berthier sur mer
	distributors.push(new Array(46.889505,-71.071268)); //St-Pierre de l'Île d'Orléans
	distributors.push(new Array(46.892539,-70.823017)); //St-Vallier
	distributors.push(new Array(45.799661,-72.199056)); //St-Félix de Kingsey
	distributors.push(new Array(45.301296,-72.315042)); //Eastman
	distributors.push(new Array(45.656377,-73.300448)); //St-Amable
	distributors.push(new Array(45.372716,-73.724291)); //Châteauguay
	distributors.push(new Array(46.289308,-72.696877)); //Pointe du Lac (Dans le coin de Trois-rivières)
	distributors.push(new Array(45.24836,-71.507849)); //St-Isidore d'Auckland
	distributors.push(new Array(45.959742,-70.830231)); //A. Champagne,St-Honoré,
	distributors.push(new Array(46.5585,-70.983934)); //Ste-Hénédine
	distributors.push(new Array(46.06942,-70.792465)); //Quincaillerie Royal et Gilles Inc., St-Benoit
//	distributors.push(new Array()); //Unicoop St-Joseph,Saint-Joseph,
	distributors.push(new Array(46.630569,-70.970955)); //St-Anselme

	if (GBrowserIsCompatible())
	{
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(46.569051, -71.892383), 7); //Center the map
		//map.setUIToDefault(); //Basic controls
		map.disableDragging();
		map.disableContinuousZoom();
		map.disableDoubleClickZoom();
		map.disableScrollWheelZoom();
		map.disablePinchToZoom();

		// Create marker icon
		var icon = new GIcon();
		icon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png";
		icon.shadow = "http://chart.apis.google.com/chart?chst=d_map_pin_shadow";
		icon.iconSize = new GSize(18, 18);
		icon.shadowSize = new GSize(26, 18);
		icon.iconAnchor = new GPoint(9, 14);
		// Set up our GMarkerOptions object literal
		markerOptions = { icon:icon };
		
		//Add icons to the map
		for (var i=0; i<distributors.length; i++)
		{
			map.addOverlay(new GMarker(new GLatLng(distributors[i][0],distributors[i][1]), markerOptions));
		}
		
		// Creating a new marker  
		//var marker = new GMarker(new GLatLng(47.009051, -71.892383))  
		
		// // Adding a click-event to the marker  
		// GEvent.addListener(marker, 'click', function() {  
		// 	// When clicked, open an Info Window  
		// 	marker.openInfoWindowHtml('<div style="color:blue">Test</div>');  
		// });  

		// Add marker to map  
	//	map.addOverlay(blueIcon);  
	}
}

//Get the content of a product.
function ajax_showProduct(product)
{
	$.ajax({
		type: "POST",
		url: "product_class.php",
		data: "product="+product,
		beforeSend: function() {
			$("#productContent").hide();
			$("#ajaxLoader").show();
		},
		success: function(html) {
			$("#ajaxLoader").hide();
			$("#productContent").empty().hide().append(html).fadeIn('slow', function() {
				// Animation complete
			});
		}
	});
}

//Get all pictures for an achievement.
function ajax_showAchievement(cat)
{
	$.ajax({
		type: "POST",
		url: "admin_achievements_ajax.php",
		data: "cat="+cat,
		beforeSend: function() {
			$("#achievementAllPictures").hide();
			$("#ajaxLoader").show();
		},
		success: function(html) {
			$("#ajaxLoader").hide();
			$("#achievementAllPictures").empty().hide().append(html).fadeIn('slow', function() {
				// Animation complete
			});
		}
	});
}

