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": "/products-2020/sunrise-2020",
//                    "link": "../main/products-2020.php?section=2&sid=37&content=sunrise_2020",
                    "alt": content['home-sunrise2020']
                },
                "pink": {
//                    "link":"../main/products.php?section=2&sid=176&content=sostenuto_itsm_techology_providers_and_msps",
                    "link":"/products/sostenuto-itsm-techology-providers-and-msps",
                    "alt": content['home-sostenuto-itsm']
                },
                "blue": {
//                    "link":"../main/products.php?section=2&sid=177&content=sostenuto_customised_applications",
                    "link":"/products/sostenuto-customised-applications",
                    "alt":content['home-sostenuto']
                }
            };


            var tabs = $$("#tabPanel .tab");

			tabs.invoke("observe", "click", function(e) {
//                alert('test');
				name = e.element().id.replace("link","");
				$("tabImage").src = "/images/home_"+name+"_on.jpg";
				$("contentText").update(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");
}