	var winWidth;
	var newWindow;

	function popWin (url,win_width,win_height,win_options)
	{
	if (window.newWindow)
		{
		if (!newWindow.closed)
				{newWindow.close();
				}
		}

	if (navigator.appName == "Netscape")
		{
		winWidth = window.screen.width - win_width - 15;
		window.newWindow = window.open(url,'newWin',win_options + ',screenY=0,screenX=' + winWidth + ',width=' + win_width + ',height=' + win_height );
		}
	else {
		winWidth = window.screen.availwidth - win_width - 15;
		window.newWindow = window.open(url,'newWin',win_options + ',top=0,left=' + winWidth + ',width=' + win_width + ',height=' + win_height );
		}
	window.newWindow.focus();
	}


	function jumptolink(where){
		if (where.value !="")
			document.location.href=where.value;
		}


	function virtualAssistantSubmit(){
	//document.form_lingubot.submit();
	strVar = document.form_lingubot.entry.value;

	strVar = strVar.replace(/'/, " ");
	strVar = strVar.replace(/&/, " ");
	strVar = strVar.replace(/@/, " ");

	//strURL = "http://help2.creativevirtual.com/LloydsTSB/?entry=" + strVar;
	strURL = "http://help2.creativevirtual.com/LloydsTSB/?SiteContext=COM&JSIN=1&StartContext=Help_Centre&entry=" + strVar;
	popWin(strURL,'580','480');
	}



// ***************************************************************************************
// here on is processing for online surveys IPR 2103
// change IM62622 while amending load/unlaod also add 'x' to end all function names
// to nake them unique compared to pre-existing virtualsurveys code on homepage and IB-logoff
// note functions: getCookieValx & GetCookiex are standard 'cookie' fetching code
function getCookieValx (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookiex (name) {
	var cname = name + "=";
	var cnlen = cname.length;
	var cklen = document.cookie.length;
	var i = 0;
	while (i < cklen) {
	var j = i + cnlen;
	if (document.cookie.substring(i, j) == cname)
	return getCookieValx (j);
	i = document.cookie.indexOf(" ", i) + 1;
	if (i == 0)
	break;
	}
	return null;
}

// sets the cookie with expiry date calculated using current date & re-survey frequency (how long cookie is valid)
function SetCookiex (name, value, exp) {
	expires = exp.toGMTString();
	document.cookie = name + "=" + escape (value) + "; expires=" + expires + "; path=/";
}

var lNum = 1;    // virtual surveys querystring detail only
// note resurveyFreq is a 'site' wide setting - expecetd to be 30 days but can be amended
var resurveyFreq = 30*24*60*60*1000; //set to 30*24*60*60*1000 if 30 day cookie required.
// -------------- Important: only above field can be amended ------------------------------------------

var popH = 0;
var popW = 0;
var popUrl = "";
var original = "";
var inSN='x';  // will be reset by 2nd param to surveycheck (survey name/id) - this is just to make avail to all code
var inPOP='x'; // will be reset by 3rd param to surveycheck (pop above or below) - this is just to make avail to all code
var inURL='x'; // will be reset by 4th param to surveycheck (url) - this is just to make avail to all code

// set some variables
var vpageload = 'xxx';
var vpageunload = 'xxx';
var vunloadurl = 'x';
var vloadurl = 'x';
var surveyfreq = 1; // note will be rest in surveycheck by parameter from function call

//variable for popup window
var pu;


// the following code identifies screen width/height & if cookies enabled details that are as used by the homepage
// VirtualSurveys survey - it is included here as our generic survey call includes VirtualSurveys details in the
// querystring in case virtualsurveys are asked to provide any other surveys.
// Confirmit would not require such details
var sWidth = 0;
var sHeight = 0;
var wWidth = 0;
var wHeight = 0;
var cook;

// size of screen
if (window.screen)      {
    sWidth = window.screen.width;
    sHeight = window.screen.height;
  }
// size of browser window, excluding chrome.
if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    wWidth = window.innerWidth;
    wHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    wWidth = document.documentElement.clientWidth;
    wHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    wWidth = document.body.clientWidth;
    wHeight = document.body.clientHeight;
  }
 //  following used by visrtualsurveys homepage survey, so preserved in case required
 if (navigator.appName=="Microsoft Internet Explorer") {
	if (navigator.cookieEnabled==true)
		{var cook = 1;}
	else
		{var cook = 2;}
      }
else
{
  var cook = 3;
}
// ------------- end of 'for virtualsurveys' -----------------------


function surveycheck(inF,SN,POP,pURL,fT,inhgt,inwdth) {

// reset variables
pH=inhgt;
pW=inwdth;
uC=lNum;
inSN=SN;
inPOP=POP;
inURL=pURL;
surveyfreq=inF;

	// Screen out those with cookies turned off (IE only check)
	//if (cook != "2"){

		// 1 is the value given as the name/value pair when setting cookie, so will only be '1' here
		// if the cookie exists and hasn't expired (in which case we won't re-survey)
		if (GetCookiex(inSN) != 1){
			var nth = surveyfreq;
			today = new Date();
			randomnum = today.getTime();
			randomnum = Math.round(Math.abs(Math.sin(randomnum) * 1000000)) % 1000;
			// decide if it is time to offer a survey
	
			if ((randomnum + 1) * nth /1000 <= 1) {
				var expdate = new Date();
				expdate.setTime(expdate.getTime() + (resurveyFreq));
				SetCookiex(inSN,"1",expdate);

					function fixPage(h,w,u,inft){
						
					popH = h;
					popW = w;
					popUrl = u;
					// decide if survey is on page load,  page unlaod, or individual link
					if (inft == 'pageload')
					{
						//setloadps(lNum,h,w,u,inft);
						setloadps(u);
					}
					else if (inft == 'pageunload')
					{
						//setunloadps(lNum,h,w,u,inft);
						setunloadps(u);
					}
					else
					{
						fixLinks(inft);
					}
				}

				function doPop(){
				  // the function that actually opens the pop-up for a link asset
					if(pu != undefined && !pu.closed && pu.location)
						 {pu.location.href = popUrl+"?c="+uC+"&w="+sWidth+"&h="+sHeight+"&wW="+wWidth+"&wH="+wHeight;}
					else
					{
						pu=window.open(popUrl+"?c="+uC+"&w="+sWidth+"&h="+sHeight+"&wW="+wWidth+"&wH="+wHeight+"&k="+cook,inSN+Math.floor(Math.random()*10e20),"height="+popH+",width="+popW+",resizable=yes,scrollbars=yes,toolbar=no,menubar=no");

						if (!pu.opener) {pu.opener = self;}
						if (inPOP=='below') {self.focus()}
					}
				}

				function fixLinks(inftx){
					docPs = document.getElementsByTagName("a");
					for(i=0;i<docPs.length;i++){
						// check to see if the element has already got an onclick event handler
						if (!docPs[i].onclick)
						{
							// check to see if it is the correct link using passed link title
							if (inftx == docPs[i].title)
							{
								docPs[i].onclick = doPop;
							}

						}
					}
				}

				// passes height,  width,  url and survey type
 				fixPage(pH,pW,inURL,fT);

			}  //  end of randomnum check using survey frequency
		}  // end of check to see if non-expired cookie ie don't resurvey
}   // end of surveycheck function


function setunloadps(a) {
  // incident IM62622 'onunload' function moved here so function only 'exists' if it's really required  
  window.onunload = function(){
	pu=window.open(popUrl+"?c="+uC+"&w="+sWidth+"&h="+sHeight+"&wW="+wWidth+"&wH="+wHeight+"&k="+cook,inSN+Math.floor(Math.random()*10e20),"height="+popH+",width="+popW+",resizable=yes,scrollbars=yes,toolbar=no,menubar=no");
  // decide which window should be on top
	if (inPOP=='below') {self.focus()};
  }
}

function setloadps(a) {

  // incident IM62622 'onload' function moved into here ... if separate function that always exists then
  // causes problems with IB log-off page survey (where offers stylesheet sets up an attribute of 'onload' for the page')
  window.onload = function(){
 	window.open(popUrl+"?c="+uC+"&w="+sWidth+"&h="+sHeight+"&wW="+wWidth+"&wH="+wHeight+"&k="+cook,inSN+Math.floor(Math.random()*10e20),"height="+popH+",width="+popW+",resizable=yes,scrollbars=yes,toolbar=no,menubar=no");
	// on page load survey can be above or below main window
	if (inPOP=='below') {self.focus()};
  }
}

// next function not really required post -IM62622 as load/unload functions themeselves not even 
// created unless they're required - however to remove function form here would need to remove
// from generic-you-first.xsl and text only version - to be done next time these change anyway
function killunload() {
  vpageload = 'xxx';
  vpageunload = 'xxx';
}


