	// general-purpose popup
	function popup(URL, winwidth, winheight, scroll) {
		day = new Date();
		id = day.getTime();
		pleft=(screen.width-winwidth)/2;
		ptop=(screen.height-winheight)/2;
		eval("page" + id + " = window.open('"+URL+"', '" + id + "', 'toolbar=0,scrollbars="+scroll+",location=0,statusbar=0,menubar=0,resizable=1,width="+winwidth+",height="+winheight+",left="+pleft+",top="+ptop+"');");
		}

	//  - trimming a string
	function trim(s)   {
		l=s.length; b=0; x=0;
		while (x<l&&b==0) { if (s.charAt(x)!=" ")  { b=1; } x++; }
		if (b==0) s="";  
		else { 
			b=0; s=s.substr(x-1); x=s.length-1;
			while(x>=0&&b==0) { if (s.charAt(x)!=" ")  { b=1; } x--; } 
			s=s.substr(0,x+2);
			}
		return s;
		}







/**
 * PPC PHONE NUMBER CODE
 *
 * Gets the value of the given parameter from the query string
 *
 * name            The parameter name
 *
 * Return value    The value of the parameter
 */
function getParameter(name)
{
// get the query string, ignore the ? at the front.
	var querystring=location.search.substring(1,location.search.length);

// parse out name/value pairs separated via &
	var args = querystring.split('&');

	var toReturn = "default"

// split out each name = value pair
	for (var i=0;i<args.length;i++)
	{
		var pair = args[i].split('=');

		// Fix broken unescaping
		currentName = unescape(pair[0]);

// Fix broken unescaping, and remove exclamation mark and anything after
		temp = unescape(pair[1]).split('!');
		currentValue = temp[0];

    if (name == currentName)
    {
        toReturn = currentValue;
    }
	}

	return toReturn;
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */

function setPPCCookie(name, value, expires, path, domain, secure)
{
    if(value!="default")
    {
    	var defaultExpireDate = new Date();
    	defaultExpireDate.setDate(defaultExpireDate.getDate()+30);

    	document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "; expires=" + defaultExpireDate.toGMTString()) +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
    }
}


/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getPPCCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function ChangePPCPhoneNo()
{	
    setPPCCookie("phone", getParameter("phone"));    
    if (getPPCCookie("phone") == "ppc")
    {

	var arrayOfSpans = document.getElementsByTagName("span"); 
	for(var i=0;i<arrayOfSpans.length;i++) 
        {
	    if(arrayOfSpans[i].className == "ppctelephoneno") 
            {
		arrayOfSpans[i].innerHTML = "0845 863 0528";
	    }
	}
    }	
}