
var mousex=400;
var mousey=300;
var originx=0;
var originy=0;
var orrel=1;

var speedlimit=2;

left=0;
right=1;
h_ix = 0;
h_iy = 1;
h_x = 2;
h_y = 3;
h_wx = 4;
h_wy = 5;
h_ani = 6;

var hands = new Array(
	//	inix,iniy, curx,cury, wantx,wanty, animframe
	Array(400,820,	0,0,	0,0,	1),
	Array(750,820,	0,0,	0,0,	1),
//head
	//	inix,iniy, curx,cury, wantx,wanty
	Array(295,1800, 295,1800, 295,1800),
//closer
	//	inix,iniy, curx,cury, wantx,wanty, onposx,y
	Array(1020,0,	1020,0,	1020,0,	806,0),
//icons
	//	inix,iniy, curx,cury, wantx,wanty, onposx,y
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0),
	Array(0,0,		0,0,	0,0,	0,0)
);
toticons=0;

var anims = new Array(
	//	w,h,	offx,offy
	Array(247,886,	-137,-19),	// left hand pointing
	Array(241,886,	-59,-20),	// right hand pointing
	Array(504,753,	-479,-21),	// left hand pointing angled
	Array(511,775,	-20,-20),	// right hand pointing angled
	Array(504,753,	-140,-89),	// left hand yawning
	Array(511,775,	-20,-20),	// right hand yawning (unused)
	Array(504,753,	-141,-43),	// left hand tap 1
	Array(511,775,	-20,-20),	// right hand tap 1 (unused)
	Array(504,753,	-124,+55),	// left hand tap 2
	Array(511,775,	-20,-20)	// right hand tap 2 (unused)
);

var headtopoffs_normal = new Array(
	//	offx,offy
	Array(0,0), // default
	Array(0,0), // yawn
	Array(0,0), // sad
	Array(0,0) // angry
);

var headtopoffs_stpat = new Array(
	//	offx,offy
	Array(0,-100), // default
	Array(0,-100), // yawn
	Array(0,-100), // sad
	Array(0,-100) // angry
);

var headtopoffs_crown = new Array(
	//	offx,offy
	Array(0,-40), // default
	Array(0,-50), // yawn
	Array(-2,-64), // sad
	Array(5,-50) // angry
);

hands[left][h_x]=hands[left][h_wx]=hands[left][h_ix];
hands[left][h_y]=hands[left][h_wy]=hands[left][h_iy];
hands[right][h_x]=hands[right][h_wx]=hands[right][h_ix];
hands[right][h_y]=hands[right][h_wy]=hands[right][h_iy];

var seq = new Array(
	Array(1, 295,111, 6,0, 7,0, 20,0, 17,50,18, 21,0),
	Array(0)
);
	clear_seq();
	add_headdest(295,111);
	add_headwait();
	add_seteyes(0); // default
	add_setmouth(0); // default
	add_bubbleon(0); // welcome
	add_wait(75);
	add_bubbleoff();
	add_wait(2);
	add_bubble2on(0); // welcome 2
	add_wait(intro2_time);
	add_enableicons();
	add_bubbleoff();
	end_seq();

desturl='';
desttitle='';

mouthanim=0;//1;
eyeanim=0;//2;
cureyeanim=0;
headtopanim=0;
neckanim=0;
blinktime=0;
boredtime=0;
firstbored=0;
boredcount=0;
waiter=0;
glowhand=-1;
windowmode=0;
eyefocus=-1;
eyefix=1;
urlwinx=0;
iconsdisabled=1;


function getorigin()
{
	var e = document.getElementById('active_main');
	var offset = {x:0,y:0};
	while (e)
	{
		 offset.x += e.offsetLeft;
		 offset.y += e.offsetTop;
		 e = e.offsetParent;
	}
	if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft))
	{
		offset.x -= document.documentElement.scrollLeft;
		offset.y -= document.documentElement.scrollTop;
	}
	else if (document.body && (document.body.scrollTop || document.body.scrollLeft))
	{
		offset.x -= document.body.scrollLeft;
		offset.y -= document.body.scrollTop;
	}
	else if (window.pageXOffset || window.pageYOffset)
	{
		offset.x -= window.pageXOffset;
		offset.y -= window.pageYOffset;
	}
	originx=offset.x;
	originy=offset.y;
}

function MouseMv(e)
{
	orrel=1;
	if (!e) e = window.event;
	if (typeof e.pageY == "number")
	{
		mousex = e.pageX
		mousey = e.pageY
	}
	else
	{
		mousex = e.clientX
		mousey = e.clientY
	}
	boredtime=0;

}
function MouseMvsub(e)
{
	orrel=0;
	if (!e) e = window.event;
	if (typeof e.pageY == "number")
	{
		mousex = e.pageX
		mousey = e.pageY
	}
	else
	{
		mousex = e.clientX
		mousey = e.clientY
	}
	mousex+=urlwinx;
	boredtime=0;
}

function reset_lefthand()
{
	reset_hand(left);
}
function reset_righthand()
{
	reset_hand(right);
}
function reset_hand(h)
{
	hands[h][h_ani]=0;
	hands[h][h_wx]=hands[h][h_ix];
	hands[h][h_wy]=hands[h][h_iy];
}

function aim_lefthand(x,y,title,addr,newwindow)
{
	aim_hand(left,x,y,title,addr,newwindow);
}
function aim_righthand(x,y,title,addr,newwindow)
{
	aim_hand(right,x,y,title,addr,newwindow);
}
function aim_hand(h,x,y,title,addr,newwindow)
{
	iconsdisabled=0;
	buboff();
	eyefix=0;
	desttitle=title;
	desturl=addr;
	blinktime=0;
	boredtime=0;
//	alert(desturl);
//	hands[h][h_wx]=x;
//	hands[h][h_wy]=y;
    //document.getElementById('title_bar').innerHTML = desttitle;
	clear_seq();
	add_setwindow(0);
	add_setglow(-1);
	add_headdest(295,111);
	add_setheadtop(0); // default
	add_seteyes(0); // default
	add_setmouth(0); // default
	add_setneck(0); // default
	add_handanim(h,0);
	if(!newwindow)	add_seteyefocus(h+2);
	add_handdest(h,x,y);
	add_handwait(h);
	if(newwindow)
	{
		add_to_seq(25); // open new window
	}
	else
	{
		add_seteyes(2); // happy
		add_setmouth(1); // happy
		add_discardicons();
		add_setglow(h);
		add_seteyefocus(h);
		add_handdest(h,500,400);
		add_handwait(h);
		add_to_seq(9); // set url
		add_setglow(2);
		add_handanim(h,1);
		xm=1;
		if(h==0) xm=-1;
		add_handdest(h,500+(60*xm),400-60);
		add_handdest(1-h,500-(60*xm),400+60);
		add_handwait(1-h);
		add_setwindow(1);
		add_handdest(h,500+(320*xm),30);
		add_handdest(1-h,500-(320*xm),30+560);
		add_handwait(h);
		add_setwindow(2);
		add_seteyes(0); // default
		add_setmouth(0); // default
		add_initcloser();
		add_seteyefocus(-1);
		add_setglow(-1);
	}

	add_handdest(0,400,820);
	add_handdest(1,750,820);
	end_seq();
}

function setframe(h,x,y,frame)
{
	frindex=(frame*2)+h;
	hx_0=0;
	hy_0=720;
	hx_1=hx_0;
	hy_1=hy_0;
	hx_2=hx_0;
	hy_2=hy_0;
	hx_3=hx_0;
	hy_3=hy_0;
	hx_4=hx_0;
	hy_4=hy_0;
	eval("hx_"+frame+" = x+anims[frindex][2]");
	eval("hy_"+frame+" = y+anims[frindex][3]");
	document.getElementById("hand"+h+"_0").style.left = hx_0+'px';
	document.getElementById("hand"+h+"_0").style.top = hy_0+'px';
	document.getElementById("hand"+h+"_1").style.left = hx_1+'px';
	document.getElementById("hand"+h+"_1").style.top = hy_1+'px';
	document.getElementById("hand"+h+"_2").style.left = hx_2+'px';
	document.getElementById("hand"+h+"_2").style.top = hy_2+'px';
	document.getElementById("hand"+h+"_3").style.left = hx_3+'px';
	document.getElementById("hand"+h+"_3").style.top = hy_3+'px';
	document.getElementById("hand"+h+"_4").style.left = hx_4+'px';
	document.getElementById("hand"+h+"_4").style.top = hy_4+'px';
}
function remove_seq(n)
{
	seq[0].splice(0,n);
}
function clear_seq()
{
	seq[0].length=0;
}
function end_seq()
{
	add_to_seq(0);
}
function add_to_seq(n)
{
	l=seq[0].length;
	seq[0][l]=n;
}
function add_handdest(h,x,y)
{
	add_to_seq(4+h);
	add_to_seq(x);
	add_to_seq(y);
}
function add_handanim(h,a)
{
	add_to_seq(10);
	add_to_seq(h);
	add_to_seq(a);
}
function add_setwindow(a)
{
	add_to_seq(11);
	add_to_seq(a);
}

function add_handwait(h)
{
	add_to_seq(2+h);
}
function add_headwait()
{
	add_to_seq(22);
}
function add_wait(w)
{
	add_to_seq(17);
	add_to_seq(w);
	add_to_seq(18);
}
function add_setglow(h)
{
	add_to_seq(8);
	add_to_seq(h);
}
function add_seteyefocus(h)
{
	add_to_seq(13);
	add_to_seq(h);
}
function add_setmouth(a)
{
	add_to_seq(6);
	add_to_seq(a);
}
function add_setheadtop(a)
{
	add_to_seq(15);
	add_to_seq(a);
}
function add_setneck(a)
{
	add_to_seq(16);
	add_to_seq(a);
}
function add_seteyes(a)
{
	add_to_seq(7);
	add_to_seq(a);
}
function add_initcloser()
{
	add_to_seq(12);
}
function add_knocksfx()
{
	add_to_seq(19);
}
function add_bubbleon(b)
{
	add_to_seq(20);
	add_to_seq(b);
}
function add_bubble2on(b)
{
	add_to_seq(24);
	add_to_seq(b);
}
function add_bubbleoff()
{
	add_to_seq(21);
}
function add_enableicons()
{
	add_to_seq(23);
}
function add_discardicons()
{
	add_to_seq(14);
}
function add_headdest(x,y)
{
	add_to_seq(1);
	add_to_seq(x);
	add_to_seq(y);
}

function closeurl()
{
	document.getElementById('urlframe').innerHTML = '';
	alliconson();
	hands[3][h_wx]=hands[3][0];
	hands[3][h_x]=hands[3][h_wx];
	windowmode=3;
}
function iconsready()
{
	if(hands[0+4][h_x]==hands[0+4][6])
	{
		if(hands[0+4][h_y]==hands[0+4][7]) return 1;
	}
	return 0;
}

function alliconson()
{
	for(x=0;x<toticons;x++)
	{
		hands[x+4][h_wx]=hands[x+4][6];
		hands[x+4][h_wy]=hands[x+4][7];
	}
}
function alliconsoff()
{
	for(x=0;x<toticons;x++)
	{
		hands[x+4][h_wx]=hands[x+4][h_ix];
		hands[x+4][h_wy]=hands[x+4][h_iy];
	}
}

function getdelta(wp,cp)
{
	var d=wp-cp;
	de=parseInt(d/3);
	if(d>=0)
	{
		if(de<speedlimit) de=speedlimit;
		if(de>d) de=d;
	}
	else
	{
		if(de>-speedlimit) de=-speedlimit;
		if(de<d) de=d;
	}
	return de;
}

function DHTMLSound(surl) {
  document.getElementById("sfxspan").innerHTML="<embed src='"+surl+"' hidden=true autostart=true loop=false>";
}

function imgin()
{
	numimages++;
}
function startTime()
{
	totim=41;
	if(specialbgr==1) totim--;
	impc=parseInt(numimages*100/totim);
	if(document.getElementById("progress")) document.getElementById("progress").innerHTML = "Loading: "+impc+"%";
	if(numimages==totim)
	{
		document.getElementById("progress").innerHTML = "";
		getorigin();
		mx=mousex;
		if(orrel!=0) mx-=originx;
	    //document.getElementById('debug').innerHTML = "x="+mx;
		if(mx>1000)mx=1000;
		if(mx<0)mx=0;
		my=mousey-originy;
		if(my>620)my=620;
		if(my<0)my=0;



		repseq=1;
		while(repseq==1)
		{
			repseq=0;
			f=seq[0][0];
			switch(f)
			{
				case 0: // doing nothing. bored?
					blinktime++;
					if(blinktime>50)
					{
						blinktime=0;
						rand = Math.floor(Math.random()*100);
						if(rand<6) blinktime=48;
					}
					if(boredtime==0) boredcount=0;
					boredtime++;
					boredlimit=100;
					if(firstbored!=0) boredlimit=300;
					if(boredtime>boredlimit)
					{
						firstbored=1;
						boredtime=1;
						//if(iconsready()!=0)
						clear_seq();
						if(iconsready()==0)
						{
							add_setheadtop(2); // sad
							add_seteyes(4); // sad
							add_setmouth(3); // sad
							add_setneck(2); // sad
							add_headdest(10,111);
							add_headwait();
							add_wait(15);
							add_setheadtop(0); // default
							add_seteyes(0); // default
							add_setmouth(0); // default
							add_setneck(0); // default
							add_headdest(295,111);
						}
						else
						{
							//alert(boredcount);
							boredcount++;
							//randomnumber=Math.floor(Math.random()*101);
							//if(randomnumber<50)
							if(boredcount<10)
							{
								add_handanim(0,2);
								add_handdest(0,483,488);
								add_setheadtop(1); // yawn
								add_seteyes(3); // yawn
								add_setmouth(2); // yawn
								add_setneck(1); // yawn
								add_handwait(0);
								add_wait(15);
								add_setheadtop(0); // default
								add_seteyes(0); // default
								add_setmouth(0); // default
								add_setneck(0); // default
								add_handdest(0,400,820);
							}
							else
							{
								add_handanim(0,3);
								add_handdest(0,300,288);
								add_setheadtop(3); // angry
								add_seteyes(5); // angry
								add_setmouth(4); // angry
								add_setneck(3); // angry
								add_handwait(0);
//								add_wait(5);
								add_knocksfx();
//								add_wait(0);
								add_handanim(0,4);
								add_wait(0);
								add_handanim(0,3);
								add_wait(0);
								add_handanim(0,4);
								add_wait(0);
								add_handanim(0,3);
								add_wait(0);
								add_handanim(0,4);
								add_wait(0);
								add_handanim(0,3);
								add_wait(2);
								add_handdest(0,383,820);
								add_setheadtop(0); // default
								add_seteyes(0); // default
								add_setmouth(0); // default
								add_setneck(0); // default
							}
						}
						end_seq();
					}
					break;
				case 1: // move head to pos
					wx=seq[0][1];
					wy=seq[0][2];
					hands[2][h_wx]=wx;
					hands[2][h_wy]=wy;
					remove_seq(3);
					break;
				case 2: // wait for left hand
					if(hands[left][h_x]==hands[left][h_wx])
					{
						if(hands[left][h_y]==hands[left][h_wy])
						{
							remove_seq(1);
						}
					}
					break;
				case 3: // wait for right hand
					if(hands[right][h_x]==hands[right][h_wx])
					{
						if(hands[right][h_y]==hands[right][h_wy])
						{
							remove_seq(1);
						}
					}
					break;
				case 4: // set left hand wanted
					hands[left][h_wx]=seq[0][1];
					hands[left][h_wy]=seq[0][2];
					remove_seq(3);
					break;
				case 5: // set right hand wanted
					hands[right][h_wx]=seq[0][1];
					hands[right][h_wy]=seq[0][2];
					remove_seq(3);
					break;
				case 6: // set mouth
					mouthanim=seq[0][1];
					remove_seq(2);
					repseq=1;
					break;
				case 7: // set eyes
					eyeanim=seq[0][1];
					cureyeanim=eyeanim;
					remove_seq(2);
					repseq=1;
					break;
				case 8: // set glow
					glowhand=seq[0][1];
					remove_seq(2);
					break;
				case 9: // set url
					remove_seq(1);
	//				document.getElementById('urlframe').innerHTML = '<iframe name="iframecontent" id="iframecontent" height="150px" width="400px" frameborder="0" scrolling="no" src="commentcards/'+clist[0]+'"></iframe>';
	//	alert(desturl);
					document.getElementById('urlframe').innerHTML = '<iframe name="iframecontent" id="iframecontent" height="150px" width="400px" frameborder="0" scrolling="no" src="'+desturl+'"></iframe>';
					break;
				case 10: // set hand anim
					h=seq[0][1];
					hands[h][h_ani]=seq[0][2];
					remove_seq(3);
					repseq=1;
					break;
				case 11: // set window
					windowmode=seq[0][1];
					remove_seq(2);
					repseq=1;
					break;
				case 12: // init closer
					hands[3][h_wx]=hands[3][6];
					hands[3][h_x]=hands[3][h_wx]-100;
					remove_seq(1);
					repseq=1;
					break;
				case 13: // set eye focus
					eyefocus = seq[0][1];
					remove_seq(2);
					repseq=1;
					break;
				case 14: // discard icons
					alliconsoff();
					remove_seq(1);
					repseq=1;
					break;
				case 15: // set headtop
					headtopanim=seq[0][1];
					remove_seq(2);
					repseq=1;
					break;
				case 16: // set neck
					neckanim=seq[0][1];
					remove_seq(2);
					repseq=1;
					break;
				case 17: // init wait
					waiter=seq[0][1];
					remove_seq(2);
					break;
				case 18: // wait
					waiter--;
					if(waiter<=0) remove_seq(1);
					break;
				case 19: // knock sfx
					DHTMLSound('knock.wav');
					remove_seq(1);
					break;
				case 20: // bubble on
					bub=seq[0][1];
					if(secssince<30) // first visit
					{
						if(secssince<0) // time traveller
						{
							document.getElementById('sbubbletxt').innerHTML = '<font size="6" '+txttype+'>'+hiagain_message+'<br>'+goodday_message+', time traveller!</font>';
							document.getElementById('sbubbletxtbox').style.top = '55px';
						}
						else
						{
							document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Hi, I\'m Steve, the landlord of the Kings Head and welcome<br>to our website! We wanted a light-hearted website that had<br>all the information you need in a very easily-accessible<br>format, so have fun...</font>';
							document.getElementById('sbubbletxtbox').style.top = '40px';
						}
					}
					else
					{
						if(himespos==0)
						{
							document.getElementById('sbubbletxt').innerHTML = '<font size="6" '+txttype+'>'+hiagain_message+'<br>'+goodday_message+', and welcome back to the<br>King\'s Head website!</font>';
							document.getElementById('sbubbletxtbox').style.top = '40px';
						}
						else
						{
							document.getElementById('sbubbletxt').innerHTML = '<font size="6" '+txttype+'>'+goodday_message+', and welcome back to the<br>King\'s Head website!<br>'+hiagain_message+'</font>';
							document.getElementById('sbubbletxtbox').style.top = '40px';
						}
					}
					document.getElementById('sbubble').style.top = '34px';
					document.getElementById('sbubbletxtbox').style.left = '210px';
					remove_seq(2);
					break;
				case 21: // bubble off
					buboff();
					remove_seq(1);
					break;
				case 22: // wait for head
					if(hands[2][h_x]==hands[2][h_wx])
					{
						if(hands[2][h_y]==hands[2][h_wy])
						{
							remove_seq(1);
						}
					}
					break;
				case 23: // enable icons
					iconsdisabled=0;
					remove_seq(1);
					break;
				case 24: // bubble 2 on
					bub=seq[0][1];
 					document.getElementById('sbubbletxt').innerHTML = '<font size="6" '+txttype+'>'+intro2_message+'</font>';
 					document.getElementById('sbubbletxtbox').style.top = '40px';
					document.getElementById('sbubble').style.top = '34px';
					document.getElementById('sbubbletxtbox').style.left = '210px';
					remove_seq(2);
					break;
				case 25: // open url in new window
					remove_seq(1);
//					alert(desturl);
//					window.open(desturl,'newwindow','width=400,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
//					window.open('http://www.google.co.uk','newwindow','width=300,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
//					window.open('http://www.google.com');
//   var pageUrl = 'http://www.google.com/';
//   window.open(pageUrl);
					window.location.href = desturl;
					break;
			}
		}

		speedlimit=8; // for hands
		for(h=0;h<(4+toticons);h++)
		{
			if(h==3) speedlimit=2; // for icons
			if((hands[h][h_x]!=hands[h][h_wx])||(hands[h][h_y]!=hands[h][h_wy]))
			{
				d=getdelta(hands[h][h_wx],hands[h][h_x]);
	//			d=hands[h][h_wx]-hands[h][h_x];
	//			d=parseInt(d/3);
				hands[h][h_x]+=d;
				d2=getdelta(hands[h][h_wy],hands[h][h_y]);
	//			d2=hands[h][h_wy]-hands[h][h_y];
	//			d2=parseInt(d2/3);
				hands[h][h_y]+=d2;
	//			if((d==0)&&(d2==0))
	//			{
	//				hands[h][h_x]=hands[h][h_wx];
	//				hands[h][h_y]=hands[h][h_wy];
	//				if(hands[h][h_y]!=hands[h][h_iy])
	//				{
	//					document.getElementById('urlframe').innerHTML = '<iframe name="header" height="150px" width="400px" frameborder="0" scrolling="no" src="'+desturl+'"></iframe>';
	//				}
	//			}
			}
	//		document.getElementById('hand'+h).style.left = (hands[h][h_x]-308)+'px';
	//    	document.getElementById('hand'+h).style.top = (hands[h][h_y]-50)+'px';
			if(h<2) setframe(h,hands[h][h_x],hands[h][h_y],hands[h][h_ani]);
		}
		// closer
			document.getElementById('closer').style.left = hands[3][h_x]+'px';
		// icons
		for(x=0;x<toticons;x++)
		{
			ic="icon_"+(x+1);
			document.getElementById(ic).style.left= hands[x+4][2]+"px";
			document.getElementById(ic).style.top= hands[x+4][3]+"px";
		}

		gx=0;
		gy=720;
		if(glowhand==0)
		{
			gx = hands[glowhand][h_x]-75;
			gy = hands[glowhand][h_y]-75;
		}
		if(glowhand==1)
		{
			gx = hands[glowhand][h_x]-75;
			gy = hands[glowhand][h_y]-75;
		}
		if(glowhand==2)
		{
			gx = 500-75;
			gy = 400-75;
		}
		document.getElementById('iglow').style.left = gx+'px';
		document.getElementById('iglow').style.top = gy+'px';

		wx=0;
		wy=720;
		ww=150;
		wh=150;
		if(windowmode==1)
		{
			wx = hands[0][h_x];
			ww = hands[1][h_x]-wx;
			wy = hands[0][h_y];
			wh = hands[1][h_y]-wy;
			if(wh<0)
			{
				wy+=wh;
				wh=0-wh;
			}
		}
		if(windowmode==2)
		{
			wx = 180;
			ww = 640;
			wy = 30;
			wh = 560;
		}
		if(windowmode==3)
		{
			windowmode=0;
		}
		urlwinx=wx;
		document.getElementById('urlframe_tl').style.left = (wx-4)+'px';
		document.getElementById('urlframe_tl').style.top = (wy-4)+'px';
		document.getElementById('urlframe_top').style.left = wx+'px';
		document.getElementById('urlframe_top').style.top = (wy-4)+'px';
		document.getElementById('urlframe_top').style.width = ww+'px';
		document.getElementById('urlframe_tr').style.left = (wx+ww)+'px';
		document.getElementById('urlframe_tr').style.top = (wy-4)+'px';
		document.getElementById('urlframe_left').style.left = (wx-4)+'px';
		document.getElementById('urlframe_left').style.top = wy+'px';
		document.getElementById('urlframe_left').style.height = wh+'px';
		document.getElementById('urlframe').style.left = wx+'px';
		document.getElementById('urlframe').style.top = wy+'px';
		document.getElementById('urlframe').style.width = ww+'px';
		document.getElementById('urlframe').style.height = wh+'px';
		document.getElementById('urlframe_right').style.left = (wx+ww)+'px';
		document.getElementById('urlframe_right').style.top = wy+'px';
		document.getElementById('urlframe_right').style.height = wh+'px';
		document.getElementById('urlframe_bl').style.left = (wx-4)+'px';
		document.getElementById('urlframe_bl').style.top = (wy+wh)+'px';
		document.getElementById('urlframe_bot').style.left = wx+'px';
		document.getElementById('urlframe_bot').style.top = (wy+wh)+'px';
		document.getElementById('urlframe_bot').style.width = ww+'px';
		document.getElementById('urlframe_br').style.left = (wx+ww)+'px';
		document.getElementById('urlframe_br').style.top = (wy+wh)+'px';
		if(document.getElementById('iframecontent'))
		{
			document.getElementById('iframecontent').style.width = ww+'px';
			document.getElementById('iframecontent').style.height = wh+'px';
		}

//		dodraw=1;
//		if(specialbgr==1) // hologram
//		{
//			randholo = Math.floor(Math.random()*100);
//			if(randholo>70) dodraw=0;
//		}
		m=mx;
		if(is_mobile)
		{
		}
		else
		{
			document.getElementById('bgr').style.left = (0-parseInt(m/100))+'px';
			if(specialbgr==1) document.getElementById('bgr2').style.left = (0-parseInt(m/100))+'px';
		}
		hx = (hands[2][h_x]-parseInt(m/200));
		hy = hands[2][h_y];
		eyex_0=0;
		eyey_0=-260;
		eyex_1=eyex_0;
		eyey_1=eyey_0;
		eyex_2=eyex_0;
		eyey_2=eyey_0;
		eyex_3=eyex_0;
		eyey_3=eyey_0;
		eyex_4=eyex_0;
		eyey_4=eyey_0;
		eyex_5=eyex_0;
		eyey_5=eyey_0;
		cureyeanim=eyeanim;
		if((blinktime>49)&&(eyeanim==0)) cureyeanim=1;
		eval("eyex_"+cureyeanim+" = hx+8");
		eval("eyey_"+cureyeanim+" = hy+68");
		document.getElementById('eyes_0').style.left = eyex_0+'px';
		document.getElementById('eyes_0').style.top = eyey_0+'px';
		document.getElementById('eyes_1').style.left = eyex_1+'px';
		document.getElementById('eyes_1').style.top = eyey_1+'px';
		document.getElementById('eyes_2').style.left = eyex_2+'px';
		document.getElementById('eyes_2').style.top = eyey_2+'px';
		document.getElementById('eyes_3').style.left = eyex_3+'px';
		document.getElementById('eyes_3').style.top = eyey_3+'px';
		document.getElementById('eyes_4').style.left = eyex_4+'px';
		document.getElementById('eyes_4').style.top = eyey_4+'px';
		document.getElementById('eyes_5').style.left = eyex_5+'px';
		document.getElementById('eyes_5').style.top = eyey_5+'px';

		headtopx_0=0;
		headtopy_0=-260;
		headtopx_1=headtopx_0;
		headtopy_1=headtopy_0;
		headtopx_2=headtopx_0;
		headtopy_2=headtopy_0;
		headtopx_3=headtopx_0;
		headtopy_3=headtopy_0;
		htx=hx+8;
		hty=hy;
		eval("htx+="+headtopoffs+"[headtopanim][0]");
		eval("hty+="+headtopoffs+"[headtopanim][1]");
		eval("headtopx_"+headtopanim+" = htx");
		eval("headtopy_"+headtopanim+" = hty");
		document.getElementById('headtop_0').style.left = headtopx_0+'px';
		document.getElementById('headtop_0').style.top = headtopy_0+'px';
		document.getElementById('headtop_1').style.left = headtopx_1+'px';
		document.getElementById('headtop_1').style.top = headtopy_1+'px';
		document.getElementById('headtop_2').style.left = headtopx_2+'px';
		document.getElementById('headtop_2').style.top = headtopy_2+'px';
		document.getElementById('headtop_3').style.left = headtopx_3+'px';
		document.getElementById('headtop_3').style.top = headtopy_3+'px';

		document.getElementById('eyebgr').style.left = (hx+8)+'px';
		document.getElementById('eyebgr').style.top = (hy+68)+'px';
		mouthx_0=0;
		mouthy_0=-300;
		mouthx_1=mouthx_0;
		mouthy_1=mouthy_0;
		mouthx_2=mouthx_0;
		mouthy_2=mouthy_0;
		mouthx_3=mouthx_0;
		mouthy_3=mouthy_0;
		mouthx_4=mouthx_0;
		mouthy_4=mouthy_0;
		eval("mouthx_"+mouthanim+" = hx+8");
		eval("mouthy_"+mouthanim+" = hy+267");
		document.getElementById('mouth_0').style.left = mouthx_0+'px';
		document.getElementById('mouth_0').style.top = mouthy_0+'px';
		document.getElementById('mouth_1').style.left = mouthx_1+'px';
		document.getElementById('mouth_1').style.top = mouthy_1+'px';
		document.getElementById('mouth_2').style.left = mouthx_2+'px';
		document.getElementById('mouth_2').style.top = mouthy_2+'px';
		document.getElementById('mouth_3').style.left = mouthx_3+'px';
		document.getElementById('mouth_3').style.top = mouthy_3+'px';
		document.getElementById('mouth_4').style.left = mouthx_4+'px';
		document.getElementById('mouth_4').style.top = mouthy_4+'px';

		neckx_0=0;
		necky_0=-260;
		neckx_1=neckx_0;
		necky_1=necky_0;
		neckx_2=neckx_0;
		necky_2=necky_0;
		neckx_3=neckx_0;
		necky_3=necky_0;
		eval("neckx_"+neckanim+" = hx");
		eval("necky_"+neckanim+" = hy+483");
		document.getElementById('neck_0').style.left = neckx_0+'px';
		document.getElementById('neck_0').style.top = necky_0+'px';
		document.getElementById('neck_1').style.left = neckx_1+'px';
		document.getElementById('neck_1').style.top = necky_1+'px';
		document.getElementById('neck_2').style.left = neckx_2+'px';
		document.getElementById('neck_2').style.top = necky_2+'px';
		document.getElementById('neck_3').style.left = neckx_3+'px';
		document.getElementById('neck_3').style.top = necky_3+'px';

		efx=mx;
		efy=my;
		if(eyefocus>=0)
		{
			if(eyefocus>=2)
			{
				efx = hands[eyefocus-2][h_wx];
				efy = hands[eyefocus-2][h_wy];
			}
			else
			{
				efx = hands[eyefocus][h_x];
				efy = hands[eyefocus][h_y];
			}
		}
		eyex = parseInt(efx/100)-5;
		eyey = parseInt(efy/70)-3;//5;
		if(eyey<-1) eyey=-1;
		if(eyefix!=0)
		{
			eyex=0;
			eyey=0;
		}
		document.getElementById('eyeballs').style.left = (hx+8+eyex)+'px';
		document.getElementById('eyeballs').style.top = (hy+68+eyey)+'px';

	//	document.getElementById('status').innerHTML = "x:"+mx+" y:"+my;
	//	document.getElementById('status').innerHTML = "HR x:"+hands[right][h_x]+" y:"+hands[right][h_y];
	//	document.getElementById('status').innerHTML = "eyeanim:"+eyeanim;


	}
	t=setTimeout('startTime()',80);
}

function nexteyes(){
	eyeanim++;
	if(eyeanim==4) eyeanim=0;
}
function nextmouth(){
	mouthanim++;
	if(mouthanim==4) mouthanim=0;
}
function bubon(icon){
	if(iconsready()==0) return;
	if(iconsdisabled==1) return;

	switch(icon)
	{
		case 1:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>A clear display of all opening and closing times, for both<br>drinks & food.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 2:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Here you\'ll find copies of all the current menus and<br> prices as displayed in the pub - food, wine & other drinks.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 3:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Click here to view galleries ranging from shots of<br>the local area to various events</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 4:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Get directions, get in touch, or any other contact details<br> you may need.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 5:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>We\'re a friendly bunch, come and meet us! There\'s also a<br> Bio on the pub itself, at the end of the list...</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 6:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>We don\'t believe in random comments typed on a website,<br> see REAL comments from REAL customers, scanned from<br>our in-pub comment\'s cards! Is yours here...?</font>';
			document.getElementById('sbubbletxtbox').style.top = '55px';
		break;
		case 7:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Visit our Facebook page for details on all upcoming events<br> & offers, plus lots more photos & videos. Press the \'like\'<br> button while you\'re there to keep updated.</font>';
			document.getElementById('sbubbletxtbox').style.top = '55px';
		break;
		case 8:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'><br>Why not follow the pub on Twitter? <br>You might also find my account while you\'re there!</font>';
			document.getElementById('sbubbletxtbox').style.top = '40px';
		break;
		case 9:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Read my blogs; sometimes pub related, sometimes <br>personal...</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 10:
			document.getElementById('sbubbletxt').innerHTML = '<font size="6" '+txttype+'>Those fantastic guys at Cosy Enterprises Ltd<br>designed this website!</font>';
			document.getElementById('sbubbletxtbox').style.top = '60px';
		break;
		case 11:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Mastercard - We accept all major credit cards.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 12:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Visa - We accept all major credit cards.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 13:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>American Express - We accept all major credit cards.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 14:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Diners Club International - We accept all major credit cards.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 15:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Food Hygiene - We\'re proud to have the maximum score on<br>the EHO Food Hygiene rating system. You can be confident<br>of our standards of cleanliness!</font>';
			document.getElementById('sbubbletxtbox').style.top = '55px';
		break;
		case 16:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Walk in Wifi - We have REAL free Wi-fi, which means<br>NO COST to you! Available in all pub areas.</font>';
			document.getElementById('sbubbletxtbox').style.top = '65px';
		break;
		case 17:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>PPL - We have licenses for almost every kind of event.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 18:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>PRS - We have licenses for almost every kind of event.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 19:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Filmbank PVS license - Did you know we have a cinema<br>room? We\'re licensed for public screenings of any movie.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 20:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Lialta - All Lialta members are very welcome with us.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 21:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Pub Tokens - Lucky enough to have received a Pub Tokens<br>Gift Voucher? We\'ll happily take them from you!</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 22:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>GFM - We sponsor GFM, a small, community radio station<br>based in Glastonbury. We always support local!</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 23:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Click here for the latest news...</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 24:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Click here to view all videos arranged in various...</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		case 25:
			document.getElementById('sbubbletxt').innerHTML = '<font size="5" '+txttype+'>Click here to view all the current events.</font>';
			document.getElementById('sbubbletxtbox').style.top = '70px';
		break;
		}
	document.getElementById('sbubble').style.top = '34px';
	document.getElementById('sbubbletxtbox').style.left = '210px';
}
function buboff(){
	if(iconsdisabled==1) return;
	document.getElementById('sbubble').style.top = '834px';
	document.getElementById('sbubbletxtbox').style.top = '844px';
}


function initbgr()
{
	bl=blist.length;
	if(bl==0)
	{
		t=setTimeout('initbgr()',100);
		return;
	}
	randbgrimg = Math.floor(Math.random()*bl);

	numimages=0;

	if (window.attachEvent)
	{
		document.attachEvent("onmousemove",MouseMv);
	}
	else
	{
		document.addEventListener("mousemove",MouseMv,false);
	}


	ms = '<div style="position:absolute; left:0px; top:0px; width:100%; height:620px; overflow:hidden;">';
	bgrw=1010;//1040;
	if(is_mobile) bgrw=1000;
	//ms+= '	<div id="bgr" name="bgr" style="position:absolute; left:0px; top:0px; z-index:10;"> <img src="active_centre/white_bg.jpg" width="'+bgrw+'" height="700"></div>';
	if(specialbgr==1)
	{
		ms+= '	<div id="bgr" name="bgr" style="position:absolute; left:0px; top:0px; z-index:10;"> <img src="active_centre/bgr/cbday1.gif" width="'+bgrw+'" height="460"></div>';
		ms+= '	<div id="bgr2" name="bgr2" style="position:absolute; left:0px; top:460px; z-index:10;"> <img src="active_centre/bgr/cbday2.gif" width="'+bgrw+'" height="160"></div>';
	}
	if(specialbgr==0)
	{
		if(forcebgr=='')
		{
			ms+= '	<div id="bgr" name="bgr" style="position:absolute; left:0px; top:0px; z-index:10;"> <img onload="imgin()" src="uploads/backgrounds/'+blist[randbgrimg]+'" width="'+bgrw+'" height="700"></div>';
		}
		else
		{
			ms+= '	<div id="bgr" name="bgr" style="position:absolute; left:0px; top:0px; z-index:10;"> <img onload="imgin()" src="'+forcebgr+'" width="'+bgrw+'" height="700"></div>';
		}
	}
	ms+= '	<div id="headtop_0" name="headtop_0" style="position:absolute; left:100px; top:1200px; z-index:30;"> <img onload="imgin()" src="active_centre/'+ipath+'/headtop_default.png"></div>';
	ms+= '	<div id="headtop_1" name="headtop_1" style="position:absolute; left:100px; top:1200px; z-index:30;"> <img onload="imgin()" src="active_centre/'+ipath+'/headtop_yawn.png"></div>';
	ms+= '	<div id="headtop_2" name="headtop_2" style="position:absolute; left:100px; top:1200px; z-index:30;"> <img onload="imgin()" src="active_centre/'+ipath+'/headtop_sad.png"></div>';
	ms+= '	<div id="headtop_3" name="headtop_3" style="position:absolute; left:100px; top:1200px; z-index:30;"> <img onload="imgin()" src="active_centre/'+ipath+'/headtop_angry.png"></div>';

	ms+= '	<div id="eyebgr" name="eyebgr" style="position:absolute; left:100px; top:1200px; z-index:21;"> <img onload="imgin()" src="active_centre/'+ipath+'/eyes_background.png"></div>';
	ms+= '	<div id="eyeballs" name="eyeballs" style="position:absolute; left:223px; top:1312px; z-index:23;"> <img onload="imgin()" src="active_centre/'+ipath+'/eyeballs.png"></div>';
	ms+= '	<div id="eyes_0" name="eyes_0" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/eyes_default_open.png"></div>';
	ms+= '	<div id="eyes_1" name="eyes_1" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/eyes_default_closed.png"></div>';
	ms+= '	<div id="eyes_2" name="eyes_2" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/eyes_happy.png"></div>';
	ms+= '	<div id="eyes_3" name="eyes_3" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/eyes_yawn_closed.png"></div>';
	ms+= '	<div id="eyes_4" name="eyes_4" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/eyes_sad.png"></div>';
	ms+= '	<div id="eyes_5" name="eyes_5" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/eyes_angry_open.png"></div>';

	ms+= '	<div id="mouth_0" name="mouth_0" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/mouth_default.png"></div>';
	ms+= '	<div id="mouth_1" name="mouth_1" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/mouth_happy.png"></div>';
	ms+= '	<div id="mouth_2" name="mouth_2" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/mouth_yawn.png"></div>';
	ms+= '	<div id="mouth_3" name="mouth_3" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/mouth_sad.png"></div>';
	ms+= '	<div id="mouth_4" name="mouth_4" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/mouth_angry.png"></div>';

	ms+= '	<div id="neck_0" name="neck_0" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/shoulders_default.png"></div>';
	ms+= '	<div id="neck_1" name="neck_1" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/shoulders_yawn.png"></div>';
	ms+= '	<div id="neck_2" name="neck_2" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/shoulders_sad.png"></div>';
	ms+= '	<div id="neck_3" name="neck_3" style="position:absolute; left:100px; top:1200px; z-index:25;"> <img onload="imgin()" src="active_centre/'+ipath+'/shoulders_angry.png"></div>';

	ms+= '	<div id="hand0_0" name="hand0_0" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/lefthand_default.png"></div>';
	ms+= '	<div id="hand0_1" name="hand0_1" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/lefthand_rotated_45.png"></div>';
	ms+= '	<div id="hand0_2" name="hand0_2" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/hand_yawn.png"></div>';
	ms+= '	<div id="hand0_3" name="hand0_3" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/lefthand_tap_pos1.png"></div>';
	ms+= '	<div id="hand0_4" name="hand0_4" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/lefthand_tap_pos2.png"></div>';
	ms+= '	<div id="hand1_0" name="hand1_0" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/righthand_default.png"></div>';
	ms+= '	<div id="hand1_1" name="hand1_1" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/righthand_rotated_45.png"></div>';
	ms+= '	<div id="hand1_2" name="hand1_2" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img src="active_centre/'+ipath+'/hand_yawn.png"></div>';
	ms+= '	<div id="hand1_3" name="hand1_3" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/lefthand_tap_pos1.png"></div>';
	ms+= '	<div id="hand1_4" name="hand1_4" style="position:absolute; left:100px; top:1200px; z-index:40;"> <img onload="imgin()" src="active_centre/'+ipath+'/lefthand_tap_pos2.png"></div>';
	ms+= '	<div id="iglow" name="iglow" style="position:absolute; left:100px; top:1200px; z-index:42;"> <img onload="imgin()" src="active_centre/'+iconpath+'/button_glow.png"></div>';
	ms+= '	<div id="urlframe_tl" name="urlframe_tl" style="position:absolute; left:300px; top:1010px; width:4; height:4; z-index:200;"><img onload="imgin()" src="active_centre/'+iconpath+'/url_tl.png"></div>';
	ms+= '	<div id="urlframe_top" name="urlframe_top" style="position:absolute; left:300px; top:1010px; width:100; height:4; z-index:200;"><img onload="imgin()" src="active_centre/'+iconpath+'/url_top.png" width="100%" height="4px"></div>';
	ms+= '	<div id="urlframe_tr" name="urlframe_tr" style="position:absolute; left:300px; top:1010px; width:4; height:4; z-index:200;"><img onload="imgin()" src="active_centre/'+iconpath+'/url_tr.png"></div>';
	ms+= '	<div id="urlframe_left" name="urlframe_left" style="position:absolute; left:300px; top:1010px; width:4; height:100; z-index:200;"><img onload="imgin()" src="active_centre/'+iconpath+'/url_left.png" width="4px" height="100%"></div>';
	ms+= '	<div id="urlframe" name="urlframe" style="position:absolute; left:300px; top:1010px; width:150; height:150; z-index:200;">urlframe</div>';
	ms+= '	<div id="urlframe_right" name="urlframe_right" style="position:absolute; left:300px; top:1010px; width:4; height:100; z-index:200;"><img onload="imgin()" src="active_centre/'+iconpath+'/url_right.png" width="4px" height="100%"></div>';
	ms+= '	<div id="urlframe_bl" name="urlframe_bl" style="position:absolute; left:300px; top:1010px; width:4; height:4; z-index:200;"><img onload="imgin()" src="active_centre/'+iconpath+'/url_bl.png"></div>';
	ms+= '	<div id="urlframe_bot" name="urlframe_bot" style="position:absolute; left:300px; top:1010px; width:100; height:4; z-index:200;"><img onload="imgin()" src="active_centre/'+iconpath+'/url_bot.png" width="100%" height="4px"></div>';
	ms+= '	<div id="urlframe_br" name="urlframe_br" style="position:absolute; left:300px; top:1010px; width:4; height:4; z-index:200;"><img onload="imgin()" src="active_centre/'+iconpath+'/url_br.png"></div>';
	ms+= '	<div id="closer" name="closer" style="position:absolute; left:1020px; top:34px; z-index:145; color:green;"><a onclick="closeurl();"><img onload="imgin()" src="active_centre/'+iconpath+'/icon_close.png"></a></div>';

	ms+= '	<div id="sbubble" name="sbubble" style="position:absolute; left:200px; top:834px; z-index:210;"><img src="active_centre/'+iconpath+'/sbubble.png"></div>';
	ms+= '	<div id="sbubbletxtbox" name="sbubbletxtbox" style="position:absolute; left:200px; top:844px; width:594; z-index:211;"><div id="sbubbletxt" name="sbubbletxt">&nbsp;</div></div>';

	ms+=json;
	ms+='	<span id="sfxspan"></span>';

	ms+= '</div>';
	//ms+= '<div id="status" name="status" style="position:absolute; left:10px; top:10px; z-index:150; color:red;">Status</div>';
	//ms+= '<div style="position:absolute; left:800px; top:10px; z-index:150; color:red;"><a onclick="nexteyes();">EYES</a></div>';
	//ms+= '<div style="position:absolute; left:800px; top:25px; z-index:150; color:red;"><a onclick="nextmouth();">MOUTH</a></div>';
	document.getElementById('active_main').innerHTML = ms;

	for(x=0;x<10;x++)
	{
		ic="icon_"+(x+1);
		if(document.getElementById(ic))
		{
			ha=x+4;
			hands[ha][h_ix]=parseInt(document.getElementById(ic+"_off").style.left);
			hands[ha][h_iy]=parseInt(document.getElementById(ic+"_off").style.top);
			hands[ha][6]=parseInt(document.getElementById(ic).style.left);
			hands[ha][7]=parseInt(document.getElementById(ic).style.top);
			hands[ha][h_wx]=hands[ha][6];
			hands[ha][h_wy]=hands[ha][7];
			hands[ha][h_x]=hands[ha][h_wx];
			hands[ha][h_y]=hands[ha][h_wy];
			toticons++;
		}
	}
	//alert(toticons+" icons");

//	txttype='face="Times New Roman" color="#000000"';
//	if(iconpath=="inner-icons-stpat") txttype='face="Times New Roman" color="#008800"';
//	if(iconpath=="inner-icons-xmas") txttype='face="Times New Roman" color="#800800"';

	startTime();
}

initbgr();

