//Google Content Targeting Code
var kw = '';
_ref = new String(document.referrer);
_r = encodeURI(_ref);
if(!_r || _r == "" || _r == undefined)  _r = 'undefined';

_loc = new String(document.location);

if((_ref.indexOf('http://www.google.') != 0 && _loc.indexOf('gclid=') != -1) && _loc.indexOf("utm_source=") == -1 && _r != 'undefined') {

	var i, l, _a = new Array(), _aa = new Array();

	if(_ref.indexOf("pagead2.googlesyndication.com") == -1) {
        _a = _ref.split('/');
	    source = _a[0] + _a[1] + '//' + _a[2];
		source = encodeURI(source);
		_b = _ref.split('&');
		l = _b.length;
		for(i=0;i<l;i++) {
		    if(_b[i].indexOf("q=") != -1 || _b[i].indexOf("query=") != -1 || _b[i].indexOf("searchfor=") != -1) {
			    _c = decodeURI(_b[i]);
				_bb = _c.split("=");
				kw = '&utm_term=' + encodeURI(_bb[1]);
			}
		}
		if(kw == '') kw = '&utm_term=' + _r;

    } else {
	    _a = _ref.split('&');
	    l = _a.length;
	    for(i=0;i<l;i++) {
	        if(_a[i].indexOf("url=") != -1) {
		        _b = decodeURI(_a[i]);
				_aa = _b.split("=");
			    source = encodeURI(_aa[1]);
				break;
		    }
			if(_a[i].indexOf("searchfor=") != -1 || _a[i].indexOf("q=") != -1 || _a[i].indexOf("query=") != -1) {
			    _c = decodeURI(_a[i]);
				_bb = _c.split("=");
				kw = '&utm_term=' + encodeURI(_bb[1]);
			}
	    }

	}
	//in case source not found
	if(!source || source == "" || source == undefined) source = 'undefined';

	//get url without query
	_a = _loc.split('?');

	document.location = _a[0] + 'index.html?utm_source=' + source + '&utm_medium=gcn' + kw;
}
//End Of Google Content Targeting Code
var SlideShowSpeed = 6000;
var CrossFadeDuration = 5;
var Picture = new Array(); // don't change this
Picture[1]  = '/images/header_images_1.jpg';
Picture[2]  = '/images/header_images_2.jpg';
Picture[3]  = '/images/header_images_3.jpg';
Picture[4]  = '/images/header_images_4.jpg';
Picture[5]  = '/images/header_images_5.jpg';
Picture[6]  = '/images/header_images_6.jpg';
var tss;
var iss;
var jss = 1;
var pss = Picture.length-1;
var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = Picture[iss];}

function runSlideShow(){

document.images.PictureBox.src = preLoad[jss].src;

jss = jss + 1;
if (jss > (pss)) jss=1;
tss = setTimeout('runSlideShow()', SlideShowSpeed);

}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function runScripts() {


	MM_preloadImages('/adjustable_beds/images/homedown.gif','/adjustable_beds/images/healthdown.gif','/adjustable_beds/images/ourbedsdown.gif','/adjustable_beds/images/infodn.gif','/adjustable_beds/images/trade_dn.gif');


	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}

				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}


	}

	runSlideShow();
}

function addbookmark(bookmarktitle)
{
     _loc = document.location;
    if(_loc != 'http://www.laybrook.com' && _loc.indexOf('?') == -1) {
		url = document.location + '?utm_source=bookmark&utm_medium=bookmark';
	} else {
	    url = 'http://www.laybrook.com/index.html?utm_source=bookmark&utm_medium=bookmark';
	}


	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(bookmarktitle, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite(url, bookmarktitle); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
	}

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

onload=function(d,E,b,i,a){
   var tooltip={
'id3':'The money-back guarantee applies to all our adjustable bed range.<br>You must let us know within the 7 day period in writing and post your letter<br>to Laybrook, 196-198 Cheltenham Road, BRISTOL, BS6 5QZ. We must receive the cancellation<br>letter within the seven-day period. The bed must not be damaged or soiled in any<br>way as this will invalidate the money-back guarantee. The guarantee is for the<br>cost of the bed but unfortunately because of the length of time it takes to assemble/disassemble<br>at these prices, we must charge to pick up the bed &pound;59 ex VAT.',
'Delete':'<b>Delete application</b>'
   }
   var tclass={
'id3':'x',
'Delete':'x'
   }
  d=document;E=d.documentElement;b=d.body;if(!E)return;
  for(i=0;a=(d.all?b.all:b.getElementsByTagName("*"))[i];i++){
    if(a.id in tooltip){
      with(a.t=d.createElement("div")){
        className="tooltip"
        if(a.id in tclass)className+=' '+tclass[a.id]
        innerHTML=tooltip[a.id]
      }
      a.onmouseover=function(e){
        with(this){onmousemove(e)}
        b.appendChild(this.t)
      }
      a.onmouseout=function(){
        b.removeChild(this.t)
      }
      a.onmousemove=function(e){
        e=e||event;with(this.t.style){
         left=e.clientX+(E.scrollLeft||b.scrollLeft)+1+"px"
         top=e.clientY+(E.scrollTop||b.scrollTop)+1+"px"
        }
      }
    }
  }
}
