// JavaScript Document
// DHTML which controls the roll-over functions on the home page banners and butterfly diagram

function showhideBannerImage(layer_ref) {
	/*	if(showhideBannerImage.last == undefined) {
			showhideBannerImage.last = document.getElementById('butterfly_diagram');

		}
		showhideBannerImage.last.style.display = 'none';
	*/	
		showhideBannerImage.last = document.getElementById(layer_ref);
	/*	
		if(showhideBannerImage.last != undefined)
		{
			showhideBannerImage.last.style.display = 'block';
		}
	*/	

	setHomepageImageCookie(layer_ref);
}

function showhideButterflyDesc(layer_ref) {
	/*	if(showhideButterflyDesc.last == undefined) {
			showhideButterflyDesc.last = document.getElementById('blank');
		}
		showhideButterflyDesc.last.style.display = 'none';
		*/		
		showhideButterflyDesc.last = document.getElementById(layer_ref);
	/*
		if(showhideButterflyDesc.last != undefined)
		{
			showhideButterflyDesc.last.style.display = 'block';
		}
	*/	
}

//Get hompage image
function getHomepageImageCookie() {

var cookieValue = null;

//check if cookie exists
var cookieName = "homepageImage";
cookieValue = getCookie(cookieName);

if(cookieValue=="DataManagement")
{
	flashCookie="0";
}

else if(cookieValue=="Analytics")
{
	flashCookie="1";
}

else if(cookieValue=="MobileMiddleware")
{
	flashCookie="2";
}

else if(cookieValue=="MobileServices")
{
	flashCookie="3";
}
else if(cookieValue=="butterfly_diagram")
{
	flashCookie="noCookie";
}

else
{
	flashCookie="noCookie";
}

//if exists get value and pass to function that determines what image is displayed on homepage
  if (cookieValue != null) {
	showhideBannerImage(cookieValue);
  }
}



//Set homepage image
function setHomepageImageCookie(mapKey) {

	var pageValue = null;
	var cookieValue = null;
	var mapValue = null;


	//get mapvalue using mapkey
	mapValue = mapInfo.Get(mapKey);

	//check if cookie exists
	var cookieValue = getCookie("homepageImage");

	if (mapKey != undefined && mapValue != null) {
		pageValue = mapValue;

		//Create date object to help set expiration date for persistant cookie
		var cookieDate=new Date();
		cookieDate.setDate(cookieDate.getDate()+365);

		   if (cookieValue != "") 
		   {
				//compare the value of the cookie, with the pageValue
				if (cookieValue != pageValue) 
				{
					//reset cookie with pageValue
					setCookie("homepageImage",pageValue,cookieDate)
				}
		   } 
		   else 
		   {

				setCookie("homepageImage",pageValue,cookieDate)
		   }
	}
}

//Mapping Information
var mapInfo = {
	Set : function(id,object) {this[id] = object;},
	Get : function(id) {return this[id];}
}

mapInfo.Set('DataManagement', 	Array('DataManagement'));
mapInfo.Set('Analytics', 		Array('Analytics'));
mapInfo.Set('MobileMiddleware', Array('MobileMiddleware'));
mapInfo.Set('MobileServices', 	Array('MobileServices'));
mapInfo.Set('butterfly_diagram', Array('butterfly_diagram'));