var isIe4=false, isDom=false, isMac=false, isWin=false, isNs=false, isNs4=false, isFlash=-1, isLoaded=false, isIe=false, isIe50=false;
var hpStartY, hpStartX, Hsrc, Asrc;

function init()
{
	if (isDom)
	{
		isLoaded=true;
		hpStartY=130;
		hpStartX=380;
		apStartY=130;
		apStartX=220;
	}
}

function showMe(divID)
{
	if (isLoaded) document.getElementById(divID).style.visibility='visible';
}
function hideMe(divID)
{
	if (isLoaded) document.getElementById(divID).style.visibility='hidden';
}
function writeMe(divID,divText)
{
	if (isLoaded)
	{
		document.getElementById(divID).innerHTML=divText;
	}
	if (isNs4)
	{
		document.layers[divID].document.open()
		document.layers[divID].document.write(divtext)
		document.layers[divID].document.close()
	}
}
function positionMe(divID,l,t)
{
	if (isLoaded)
	{
		document.getElementById(divID).style.display="block";
		document.getElementById(divID).style.position="absolute";
		document.getElementById(divID).style.top=t+"px";
		document.getElementById(divID).style.left=l+"px";
	}
}

function showMap(mapId)
{
	mapRef="/_resources/images/maps/map"+mapId+".gif";
	mapHref="<img src="+mapRef+" alt='MAP "+mapId+"' />";
	writeMe("mapBox",mapHref);
	if(mapId==2)
	{
		writeMe("mapH1","Maps and Directions: Whitby in relation to York, Darlington and Leeds");
		writeMe("mapTitle","Map 2");
	}
	else if(mapId==3)
	{
		writeMe("mapH1","Maps and Directions: Museum location in Whitby");
		writeMe("mapTitle","Map 3");
	}
	else
	{
		writeMe("mapH1","Maps and Directions: Whitby in relation to London, York, Edinburgh and Manchester");
		writeMe("mapTitle","Map 1");
	}
}

function showHighlight(hId)
{
	compileString(hId);	
	hideMe("highlightContainer");
	positionMe("highlightContainer",hpStartX,hpStartY);
	writeMe("highlightContainer",Hsrc);
	showMe("highlightContainer");
}
function closeHighlight()
{
	hideMe("highlightContainer");
}
function compileString(num)
{
	iName="";
	hTitle="";
	hText="";
	switch(num)
	{
		case 1: iName="walkers-house"; hTitle="John Walker's house - the House on the Harbour:"; hText="The Museum is housed in an historic building on the harbourside – Walker’s House.  In 1746 James Cook, then a youth aged seventeen, came here to be apprenticed to Captain John Walker. A beautiful 17th century house, this is the sole remaining building which can with certainty be connected to Cook.</p><p>This picture was taken when the Endeavour visited Whitby recently  Imagine the scene from the attic window when there was a forest of tall masts of the many ships berthed there"; break;
		case 2: iName="the-attic"; hTitle="The Attic"; hText="This high attic is where, according to established tradition, the young apprentice seaman spent much of his time ashore and where he shared sleeping space with sixteen others.   The kindly housekeeper, Mary Prowd, supplied him with candles so that he could study on dark winter evenings. The attic with its high timbered roof, retains the atmosphere it had in the period when a lasting friendship was forged between Cook and his Whitby master, John Walker."; break;
		case 3: iName="resolution"; hTitle="The Resolution model"; hText="Cook’s ship for the second voyage.   The hull is cut away to show the holds.   Models of the crew and the huge quantity of stores are set out in front.   Very popular with children."; break;
		case 4: iName="letter-to-hammond"; hTitle="Cook's letter to Captain Hammond."; hText="Hammond had sold Resolution to the Navy.   In this letter Cook thanks Hammond for providing a sound ship perfect for his needs. The Museum has original letters telling one part or another of the Cook story."; break;
		case 5: iName="tattoos"; hTitle="Tattoos"; hText="A head of a New Zealander Europeans were fascinated by the Pacific islanders’ elaborate tattoos.  Sailors quickly adopted the practice. Soon it spread worldwide."; break;
		case 6: iName="omai"; hTitle="Between Two Worlds.<br />Portrait of  Omai, Joseph Banks and Dr Solander by William Parry."; hText="We have many original paintings – by Thomas Gainsborough, William Hodges (artist on  Resolution) and others.</p><p>The painting of Omai, an early Whitby visitor, is shared with our partners in London and Cardiff."; break;
		case 7: iName="bligh"; hTitle="Captain Bligh of the Bounty by John Russell"; hText="Bligh at his best, an Admiral by the time these pastels were painted, and as he would prefer us to remember him! He had been Cook’s sailing master on Resolution."; break;
		case 8: iName="betsy"; hTitle="Bligh's wife Betsy by John Russell"; hText=""; break;
	}
	imgSrc="<div class='imgBox'><img src='/_resources/images/highlights/large/"+iName+".jpg' /></div>";
	txtString="<div id='details'>";
	txtString+="<h2>"+hTitle+"</h2>";
	txtString+="<p>"+hText+"</p>";
	txtString+="</div>";
	closeString="<div id='closeLink'><a href='#' onclick='closeHighlight(); return false;'>close</a></div>";
	
	Hsrc = imgSrc + txtString + closeString ;
}


function showAquisition(aId)
{
	compileStringA(aId);	
	hideMe("highlightContainer");
	positionMe("highlightContainer",apStartX,apStartY);
	writeMe("highlightContainer",Asrc);
	showMe("highlightContainer");
}

function compileStringA(num)
{
	iName="";
	hTitle="";
	hText="";
	switch(num)
	{
		case 1: 
			iName="forster"; 
			hTitle="Portrait of George Forster, after Anton Graff, c. 1784"; 
			hText="tbc";
			hText="<p>George (or Georg as he is often called) accompanied his father, Johann Reinhold Forster, on Cook's Second Voyage. He was an excellent naturalist, talented artist, and a perceptive observer. He also seems to have been much more popular both with the crew and with Cook than his father, the difficult but immensely learned scientist officially appointed to the Voyage.";
			hText+="<p>George (1754-1794) was the oldest of Johann Reinhold's seven surviving children, and was born near Gdansk in modern Poland. From the age of eleven, he accompanied his father on his travels, and came to England in 1766. He was only nineteen when he sailed with Cook on the Second Voyage.</p>";
			hText+="<p>After the voyage, George wrote an account based on his father's journals.  This was A Voyage Round the World in His Britannic Majesty's Sloop, Resolution, commanded by Capt. James Cook, during the years 1772, 3, 4, 5. He hoped the publication would help solve the family's perennial financial problems, which were caused mainly by Johann Reinhold's inability to manage his finances, a tendency which George seemed to have inherited.</p>";
			hText+="<p>The book was praised but did not sell well in comparison to the official account by Cook, and the Forsters returned to Germany in 1778. George eventually became university librarian in Mainz. Always a political radical and inspired by the French Revolution, he joined the Jacobins and went to Paris in 1793. Once there however he became disillusioned by the Terror, and died of illness in his fortieth year.</p>";
			hText+="<p>This portrait was painted after George's return to Germany, and belonged to descendents of his daughter, Clara, until its donation to the Museum in 2005.</p>";
			break;
		case 2: iName="bread"; hTitle="Transplanting of the Bread Fruit Trees from Otaheite by Thomas Gosse"; hText="<p>acquired with the help of <em>The Art Fund</em></p>"; break;
		case 3: 
			iName="resolution"; 
			hTitle="William Hodges, The Resolution in a stream of pack-ice";
			hText+="<p>William Hodges (1744-1797) was the official artist on Cook’s Second Voyage.   His scenes of Pacific islands and peoples, with dramatic contrasts of light and colour, remain key images of this remarkable period of exploration.  This is a small sketch made by Hodges during one of the two sweeps towards the South Pole 1772-73.  It depicts the Resolution in a choppy sea under overcast skies with streams of pack ice floating past.</p>";
			hText+="<p>Surviving sketches by Hodges are extremely rare.  </p>";
			hText+="<p>The Voyage marked the first crossing of the Antarctic Circle.  The ship came nearly within sight of the Continent itself, further south than anyone had sailed before.   The sketch is testimony to European efforts to find an unknown southern continent, to the dangers of voyaging among the ice floes and the hardships endured by the crew in freezing conditions.</p>";
			hText+="<p>J.R. Forster complained his bedding was always damp from a leaking hatch, and the goat brought down from the deck to the next door cabin bleated piteously all night.   Cook wrote at the most southern point – '<em>I whose ambition leads me not only farther than any other man has been before me, but as far as I think it possible for man to go</em>'.</p>";
			hText+="<p>Acquired with the help of the <em>Garfield Weston Foundation</em>, the <em>MLA/V&amp;A Purchase Grant Fund</em>, <em>The Art Fund</em>, the <em>Normanby Trust</em>, and the <em>UK Antarctic Heritage Trust</em>.</p>";
			break;
	}
	
	if(num!=2)
	{
	imgSrc="<div class='imgBox'><img src='/_resources/images/acquisitions/large/"+iName+".jpg' /></div>";
	txtString="<div id='details'>";
	txtString+="<h2>"+hTitle+"</h2>";
	txtString+= hText;
	txtString+="</div><div class='clear'></div>";
	closeString="<div id='closeLink'><a href='#' onclick='closeHighlight(); return false;'>close</a></div>";
	containerClose = "</div>";
		
	Asrc = imgSrc + txtString + closeString + containerClose;
	}
	else
	{
	imgSrc="<br /><img src='/_resources/images/acquisitions/large/"+iName+".jpg' />";
	txtString="<h2>"+hTitle+"</h2>";
	txtString+= hText;
	closeString="<div id='closeLink'><a href='#' onclick='closeHighlight(); return false;'>close</a></div>";
	
	Asrc = imgSrc + txtString + closeString;
	}
}

function showRoom(roomId)
{
	compileStringRoom(roomId);	
	hideMe("highlightContainer");
	positionMe("highlightContainer",hpStartX,hpStartY);
	writeMe("highlightContainer",Rsrc);
	showMe("highlightContainer");
}

function compileStringRoom(num)
{
	iName="";
	hTitle="";
	hText="";
	switch(num)
	{
		case 1: iName="orientation-room"; hTitle="The Orientation Room"; hText="The Orientation Room Entrance through the new wing brings the visitor into the Orientation Room. Maps show the known world before Cook’s voyages. The Parry group portrait of Omai, Banks and Solander hangs here when not housed with our partner museums in London and Cardiff."; break;
		case 2: iName="old-kitchen"; hTitle="The Old Kitchen"; hText="This the oldest part of the house, as Cook would have known it. The brick floor of the old kitchen has recently been discovered. This was the housekeeper Mary Prowd’s domain, who saved candles for the young Cook.   It is furnished with pots, pans and cooking utensils according to the 1774 inventory"; break;
		case 3: iName="green-room"; hTitle="The Green Room"; hText="Passers-by in Grape Lane can see the paneled dining room. The table is laid for a meal, complete with crockery, cutlery and glasses with home-brewed ale.  It would have been in the Blue and Green rooms that Walker entertained Cook when he visited at the New Year of 1772."; break;
		case 4: iName="blue-room"; hTitle="The Blue Room"; hText="The view across the busy harbour from this charming room is a reminder of the port as it would have been in the 18th century. In accordance with Quaker custom, the room has no pictures on the walls. </p><p>Furniture includes ‘cane’ chairs with upright backs, an escritoire - a utilitarian piece of furniture with drawers and pigeon holes - and a longcase clock."; break;
		case 5: iName="whitby-room"; hTitle="The Whitby Room"; hText="Two early watercolours provide views of the town and harbour in the 18th century. As well as the fine model of the house in Walker’s time, other exhibits include Walker’s own copy of Cook’s account of the second voyage, A Voyage towards the South Pole, 1777."; break;
		case 6: iName="london-room"; hTitle="The London Room"; hText="The exhibits here illustrate aspects of Cook’s London activities.  There are contemporary prints of the places he was associated with, in particular Deptford and Greenwich.   There is a reproduction of a portrait of Cook’s wife Elizabeth, which suggests she must have been a handsome and strong-minded character.   She suffered many tragedies.   Three of her children died in infancy, and her three remaining sons all died before her, two of them at sea. "; break;
		case 7: iName="voyages-room"; hTitle="The Voyages Room"; hText="The map shows the tracks of Captain Cook’s three great voyages of discovery.  A scale model of the Resolution fills the central case, and is surrounded by prints, paintings and documents relating to the second and third voyages."; break;
		case 8: iName="scientists-room"; hTitle="The Scientists Room"; hText="Artifacts from the voyages, pictures and botanical prints demonstrate how the frontiers of knowledge were pushed back by scientific advances made by Captain Cook, Sir Joseph Banks and other expedition members.  Forster’s desk from Resolution has pride of place here, together with the portrait of Lord Sandwich, by Thomas Gainsborough"; break;
		case 9: iName="artists-room"; hTitle="The Artists Room"; hText="In the days before the camera ‘froze time’, prints taken from original watercolours illustrated reports and journals.  Europe was captivated by images of exotic 'terrestrial paradises'."; break;
		case 10: iName="the-attic"; hTitle="View onto the harbour, through the Attic window"; hText="The one time quarters of the young James Cook now provides a home for our special exhibitions.  We borrow relevant material from museums all over the country and bring it to Whitby.</p><p>The 2008 exhibition is Smoking Coasts and ice-bound Seas:  Cook's Voyage to the Arctic'. For more information, click <a href='/special-exhibition/'>Special Exhibition</a>."; break;
		case 11: iName="ends-of-the-earth"; hTitle="The Ends of the Earth"; hText="Cook on the Second Voyage was the first to cross the Antarctic Circle.   He just missed sighting the land-mass of Antarctica, but sailed further south than any man had before, until turned back by ice and appalling weather.   This finally put paid to the belief that there was a Southern Continent with a temperate climate."; break;
	}

	imgSrc="<div class='imgBox'><img src='/_resources/images/tour/large/"+iName+".jpg' /></div>";
	txtString="<div id='details'>";
	txtString+="<h2>"+hTitle+"</h2>";
	txtString+="<p>"+hText+"</p>";
	txtString+="</div>";
	closeString="<div id='closeLink'><a href='#' onclick='closeHighlight(); return false;'>close</a></div>";
	
	Rsrc = imgSrc + txtString + closeString ;
}


function showNewAquisition(aId)
{
	compileStringA(aId);	
	hideMe("highlightContainer");
	positionMe("highlightContainer",hpStartX,hpStartY);
	writeMe("highlightContainer",Rsrc);
	if (aId==6)
	{
		document.getElementById("highlightContainer").style.width=530+"px";
		document.getElementById("closeLink").style.width=500+"px";		
	}
	else document.getElementById("highlightContainer").style.width=484+"px";
	showMe("highlightContainer");
}

function compileStringA(num)
{
	iName="";
	hTitle="";
	hText="";
	switch(num)
	{
		case 1: iName="k1"; hTitle="'Kamtskadales' or Natives of Kamtshatka"; hText="With his heavy winter clothing and staff, this may have been one of the drivers of the dog-sledges which took a group, including Webber, to visit the Russian governor of Kamchatka at Bolsheretsk.  The visitors enjoyed travelling by sledge and were much impressed by the driver’s skill, but were not allowed to try driving the dogs themselves."; break;
		case 2: iName="k2"; hTitle="'A Woman of Kamtshatka' or 'Kamtskadales'"; hText="Portrait of a woman of dignified bearing;  Captain King noted that 'the married women had handsome Silk Handkerchiefs bound round their heads'."; break;
		case 3: iName="k3"; hTitle="A Man of Kamtshatka"; hText="The fur clothing of the inhabitants, made from rich sea otter and other pelts, fascinated the travellers. Such furs too were bought for high prices in China. Captain King apparently brought an example like this man's coat and hat back to England."; break;
		case 4: iName="k4"; hTitle="A Native of Kamtshatka"; hText="A striking portrait of a young Kamchadal, with high cheekbones, ruddy complexion and tousled hair.  Webber always managed to convey the individuality of each person, and did not simply record indigenous people as specimens of another previously unknown exotic race."; break;
		case 5: iName="k5"; hTitle="'A Woman of Kamtshatka' or 'Kamtskadales'"; hText="Confusingly also titled 'A Woman of Kamtshatka', but a full length study.  Perhaps drawn when the visitors went to the ostrog of Karatchin where 'every one was drest out in their best, &amp; the womens dress was very pretty' made from different coloured cotton cloths with silk shifts and head scarves."; break;
		case 6: iName="k6"; hTitle="Inside of a Summer Habitation Kamtshatka"; hText="(this is mistakenly labelled a 'Winter Habitation')<br /><br/>However with the sharply angled roof it is clearly a balagan or summer habitation, rather than the yurt-shaped winter dwellings which had domed roofs.  The summer dwellings were built on stilts and served in winter as storehouses safe from wild animals and vermin."; break;
	}

	imgSrc="<div class='imgBox'><img src='/_resources/images/acquisitions/large/"+iName+".jpg' /></div>";
	txtString="<div id='details'>";
	txtString+="<h2>"+hTitle+"</h2>";
	txtString+="<p>"+hText+"</p>";
	txtString+="</div>";
	closeString="<div id='closeLink'><a href='#' onclick='closeHighlight(); return false;'>close</a></div>";
	
	Rsrc = imgSrc + txtString + closeString ;
}











/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 * Script featured on Dynamic Drive (http://www.dynamicdrive.com) 12.08.2005
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};

/*******************************************************************/



isMac=(navigator.platform=="MacPPC")? true:false;
isWin=(navigator.appVersion.indexOf("Win")!=-1)? true:false;
isIe=(navigator.appName=="Microsoft Internet Explorer")? true:false;
isIe4=(document.all)? true:false;
isDom=(document.getElementById)? true:false;
if ((parseInt(navigator.appVersion)==4) && (navigator.appName=="Netscape"))
{
	isNs4 = true;
	isImg = true;
}
window.onload=init;