




// JavaScript Document
// AF 2008 O2 Online

$(document).ready(
	function()
	{
	  var idmNameCookieValue = readCookie("IMDataGivenName");
	  var idmTokenCookieValue = readCookie("iPlanetDirectoryPro");
	  /*var idmCTNCookieValue = readCookie("IMDataCtn");*/
	  
	  if( (idmNameCookieValue!=null) && (idmTokenCookieValue!=null)  )
	  {
			// do nothing, do not change the onClick event on the dashboard links
	  }
	  else
	  {
			$('div.dashboard-column a').each(function (){ $(this).click(onDashboardLinkClick); });
			$('#dashboard-login-left-container a').each(function (){ $(this).click(onDashboardCloseLinkClick); });
	  }

	}
);

function onDashboardLinkClick(e)
{
	doRemoveSelectedBoldStyle();
	$(this).addClass("dashboard-bold-link");
	
	var gotoAction = $(this).prev(".IDM-GOTO").attr('value');
	
	if( gotoAction != null)
	{
		if( gotoAction == "none" )
		{
			$('#dashboard-login-form').attr('action','https://www.o2online.ie/amserver/UI/Login');
		}
		else
		{
			$('#dashboard-login-form').attr('action','https://www.o2online.ie/amserver/UI/Login?goto='+gotoAction);
		}
		
		$('#dashboard-login-container').fadeIn(350);
		$('#dashboard-login-header-label').hide();
		$('#dashboard-login-header-label').fadeIn(350);
		$('#dashboard-login-header-label').text($(this).attr('title'));
	}
	else
	{
	    $('#dashboard-login-container').hide();
		
		// do not override the current href
		return true;
	}
	
	return false;
};

function onDashboardCloseLinkClick(e)
{
	$('#dashboard-login-container').fadeOut(350);
	return false;
}

function doRemoveSelectedBoldStyle()
{
$("div.dashboard-column a").removeClass("dashboard-bold-link");
}



