var Cookie={set:function(C,D,B){var A="";if(B!=undefined){var E=new Date();E.setTime(E.getTime()+(86400000*parseFloat(B)));A="; expires="+E.toGMTString()}return(document.cookie=escape(C)+"="+escape(D||"")+A+"; path=/")},get:function(A){var B=document.cookie.match(new RegExp("(^|;)\\s*"+escape(A)+"=([^;\\s]*)"));return(B?unescape(B[2]):null)},erase:function(A){var B=Cookie.get(A)||true;Cookie.set(A,"",-1);return B},accept:function(){if(typeof navigator.cookieEnabled=="boolean"){return navigator.cookieEnabled}Cookie.set("_test","1");return(Cookie.erase("_test")==="1")}};
function addLoadEvent(func){var oldonload = window.onload;if (typeof window.onload != 'function'){window.onload = func;} else {window.onload = function(){oldonload();func();}}}
function getQVar(variable) {var query = window.location.search.substring(1);var vars = query.split("&");for (var i=0;i<vars.length;i++) {var pair = vars[i].split("=");if (pair[0] == variable) {return pair[1]; } }} 

function loadPersonalisation() {
	var script = document.createElement('script');
	if(getQVar("acceu")) { var acceu = getQVar("acceu"); } else if(Cookie.get("acceu")!=null) { var acceu = Cookie.get("acceu"); }
	if(getQVar("accec")) { var accec = getQVar("accec"); } else if(Cookie.get("accec")!=null) { var accec = Cookie.get("accec"); }
	script.src = 'http://www.dashboard.co.uk/bosaccelerator/bosaccelerator.php?acceu='+acceu+'&accec='+accec;
	script.type = "text/javascript";
	document.getElementsByTagName('head')[0].appendChild(script);
	if(getQVar("acceu") && getQVar("accec")) {
		Cookie.set("acceu", getQVar("acceu"),60);
		Cookie.set("accec", getQVar("accec"),60);
	}
}

function displayPersonalisation() {
	if(relationshipManager.name) {
		var phone = relationshipManager.mobile;
		
		if(relationshipManager.mobile == "" || relationshipManager.mobile == "n/a") phone = relationshipManager.phone; 
		
		var cta = document.createElement("p");
		
		var welcome = document.getElementById("header-personalisation-welcome");
		var contact = document.getElementById("header-personalisation-contact");
		
		welcome.innerHTML = "Contact your personal Relationship Manager";
		contact.innerHTML = "Call " + relationshipManager.name + " on <strong>" + phone + "</strong>";						
		
		if(document.getElementById("sector-gateway")) {
			var li = document.createElement("li"); li.id="personalisation";
			var h = document.createElement("h2"); h.innerHTML="Are you ready to take the next step?";
			li.appendChild(h); li.appendChild(cta);
			cta.innerHTML = "Contact your personal Relationship Manager <strong>"+relationshipManager.name+"</strong>,<br /> on <strong>"+phone+"</strong>";
			document.getElementById("sector-gateway").appendChild(li);
		}
		if(document.getElementById("product-gateway")) {
			var li = document.createElement("li"); li.id="personalisation";
			var h = document.createElement("h2"); h.innerHTML="Are you ready to take the next step?";
			li.appendChild(h); li.appendChild(cta);
			cta.innerHTML = "Contact your personal Relationship Manager <strong>"+relationshipManager.name+"</strong>,<br /> on <strong>"+phone+"</strong>";
			document.getElementById("product-gateway").appendChild(li);
		}
		if(document.getElementById("sector-details")) {
			var div = document.createElement("div"); div.id="personalisation";
			var h = document.createElement("h2"); h.innerHTML="Are you ready to take the next step?";
			div.appendChild(h); div.appendChild(cta);
			cta.innerHTML = "Contact your personal Relationship Manager <strong>"+relationshipManager.name+"</strong>, on <strong>"+phone+"</strong>";
			document.getElementById("sector-details").appendChild(div);
		}
	}
}

function displayHeaderPersonalisation() {
	if(relationshipManager.name) {
		var phone = relationshipManager.mobile;
		if(relationshipManager.mobile == "" || relationshipManager.mobile == "n/a") phone = relationshipManager.phone;
		var cta = document.createElement("p");
		cta.id = "personalisation";
		cta.innerHTML = "Call " + relationshipManager.name + " on <span>" + phone + "</span>";
		document.getElementById("mainnav").insertBefore(cta, document.getElementById("mainnav"));
	}
}

addLoadEvent(loadPersonalisation);