var teleNo = '0845 408 07 69';
function getHeadTel(){
	var allcookies = document.cookie;
	var pos = allcookies.indexOf("ref=");
	if(pos<0){
		var ref = document.location.href;
		var pos = ref.indexOf("AID");
		if(pos>=0){
		document.cookie = 'ref=affiliate; path=/; domain=leger.co.uk'
		}
		else{
		document.cookie = 'ref=direct; path=/; domain=leger.co.uk'
		}
	}
	
	var pos = allcookies.indexOf("webapp=");
	if(pos != -1){
		var start = pos + 7;
		var end = allcookies.indexOf(";", start);
		if (end == -1) end = allcookies.length;
		var value = allcookies.substring(start, end);
		value = unescape(value);
		var arrValues = value.split("&");
		for(var iCount = 0; iCount < arrValues.length;iCount++){
			if(arrValues[iCount].substring(0,2) == "T="){
				teleNo = arrValues[iCount].substring(2,arrValues[iCount].length);
				break;
				}
			}
		}
		var allcookies = document.cookie;
		var pos = allcookies.indexOf("ref=affiliate");
		if(pos<0){
		document.write('<div id="phone_1">Phone us on ' + teleNo + '</div>');
		}
		else {
		document.write('<div id="phone_1">Book Your Holiday Online</div>');
		}
	}
	
function getTel(){
	var allcookies = document.cookie;
	var pos = allcookies.indexOf("webapp=");
	if(pos != -1){
		var start = pos + 7;
		var end = allcookies.indexOf(";", start);
		if (end == -1) end = allcookies.length;
		var value = allcookies.substring(start, end);
		value = unescape(value);
		var arrValues = value.split("&");
		for(var iCount = 0; iCount < arrValues.length;iCount++){
			if(arrValues[iCount].substring(0,2) == "T="){
				teleNo = arrValues[iCount].substring(2,arrValues[iCount].length);
				break;
				}
			}
		}
		document.write(teleNo);
	}
	
function getCallUs(){
		document.getElementById('CallUsID').alt="Call Us.. "+teleNo;
	}


function tracker(){
	var sQueryString = document.location.search.toLowerCase();
	sQueryString = unescape(sQueryString);
	if(sQueryString.length != 0){
		sQueryString = sQueryString.substring(1);
		var arrSplit = sQueryString.split("&");
		var sNameValue = "";
		for(sNameValue in arrSplit){
			if(arrSplit[sNameValue].substring(0,8) == "srccode="){
				var r=document.referrer;
				document.write("<IMG SRC=\"https://rs0.co.uk/gif.php?bbcid=471&bbact=a1&bbval='0'&bbref='"+r+"'\" height='1' width='1' border='0'>");
				}
			}
		}
	}
