document.observe( "dom:loaded", function() {
	
	new Ajax.Request('../site_includes/xhr_index.php', {
		method:     'POST',
		parameters: '',
		onSuccess: function(t) {
			
			var content = t.responseText.evalJSON();
			
			var name = "green";
			var links = {"green" : {"link": "../main/products_2020.php?section=2&sid=37&content=sunrise_2020", "alt":content.sunrise2020 }, "pink": {"link":"../main/products.php?section=2&sid=176&content=sostenuto_itsm_techology_providers_and_msps","alt": content.sostenuto_itsm} , "blue" : {"link":"../main/products.php?section=2&sid=177&content=sostenuto_customised_applications","alt":content.sostenuto}};
			
			$$("#tabPanel .tab").invoke("observe","click", function(e) {
				name = e.element().id.replace("link","");
				//alert("../images/home_"+src+"_on.jpg");
				$("tabImage").src = "../images/home_"+name+"_on.jpg";
				$("contentText").update(links[name]["alt"]);
				//console.log(links[name]["alt"]);
			});
			$("clickArea").observe("click", function(l) {
				location = links[name]["link"];
			});
		}
	});
	
	
});

function imageSwap(image,mode) {
	var suffix;
	switch(mode) {
		case "off":
		suffix = "off";
		break;
		case "on":
		suffix = "on";
		break;
		case "toggle":
		var suffix = image.replace(/(.*_)(.*)(\..*)/,"$2");
		if(suffix == "off") {
			suffix = "on";
		} else {
			suffix = "off";
		}
	}
	
	return image.replace(/(.*_)(.*)(\..*)/,"$1"+suffix+"$3");
}