
//=====================================================================
//  Bear Details
//=====================================================================

site     = "http://www.albionbears.com/"
imageFolder = "images/bears/";
baseImages = "images/";
urlSite  = site;
thisPic  = 0;
ldBear   = 1;
thisFlash = 0;

maxQuotes = 63;

ntlIP = "81.101.39.218";

setSite();


/* --------------------------------------------------------------- */

function setSite() 
{ 
	if(isLocal()) {
		site = "";
		urlSite = "http://127.0.0.1/albionbears/";
		imageFolder = "images/bears/";
		baseImages = "images/";
	}
	else if(document.domain.indexOf("smegsite") != -1)
	{
		site = "http://www.smegsite.co.uk/albionbears/";
		urlSite = "http://www.smegsite.co.uk/albionbears/";
		imageFolder = site + "images/bears/";
		baseImages = site + "images/";
	}
	else if(document.domain.indexOf(ntlIP) != -1)
	{
		site = "http://"+ntlIP+"/albionbears/";
		urlSite = site;
		imageFolder = site + "images/bears/";
		baseImages = site + "images/";
	}

	
}


/* --------------------------------------------------------------- */

function isLocal( dom )
{
	return (document.domain == "" || document.domain == "127.0.0.1" || document.domain == "localhost" || document.domain == "charon");
}

/* --------------------------------------------------------------- */

function setFrontPicture( pic )
{
	Pic1 = bearSmPics[thisPic];
	Pic2 = bearSmPics[thisPic + 1];
	Pic3 = bearSmPics[thisPic + 2];
	Pic4 = bearSmPics[thisPic + 3];
	document.front0.src = imageFolder + Pic1[0];
	document.front1.src = imageFolder + Pic2[0];
	document.front2.src = imageFolder + Pic3[0];
	document.front3.src = imageFolder + Pic4[0];
}

/* --------------------------------------------------------------- */

function rotateFrontPictures()
{
	Pic1 = bearSmPics[frontBears[thisPic]];
	Pic2 = bearSmPics[frontBears[thisPic + 1]];
	Pic3 = bearSmPics[frontBears[thisPic + 2]];
	Pic4 = bearSmPics[frontBears[thisPic + 3]];
	document.front0.src = imageFolder + Pic1[0];
	document.front1.src = imageFolder + Pic2[0];
	document.front2.src = imageFolder + Pic3[0];
	document.front3.src = imageFolder + Pic4[0];
	br0.href = getBearPage( 0 );
	br1.href = getBearPage( 1 );
	br2.href = getBearPage( 2 );
	br3.href = getBearPage( 3 );
	changeText();
	SetBear();
	thisPic += 4;
	if(thisPic >= homePageBears - 3) thisPic = 0;
	setTimeout("rotateFrontPictures()",7500);
}

function showBigPicture( pic ){ document.images["bigpic"].src = imageFolder + bearLgPic[pic]; }

function showSmallPicture( pic )
{
	document.write("<img id=\"sm" + (pic % 4) + "\"border=\"0\" style= \"border: 1px solid #EAE6E0; \" src=\"" +	imageFolder + bearSmPic[pic] + "\"" +
					 "width=\"170\" height=\"200\" alt=\"Click to see a bigger picture of me!\" onclick=\"javascript:showBigPicture(" + pic +" )\">");
}

function showSmallFeature( pic )
{
	document.write("<img id=\"sm" + (pic % 4) + "\"border=\"0\" src=\"" +	imageFolder + bearSmPic[pic] + "\"" +
					 "width=\"127\" height=\"150\" alt=\"Click to see a bigger picture of me!\" onclick=\"javascript:showBigPicture(" + pic +" )\">");
}

function showInitialPicture()
{
	document.write(	"<img border=\"0\" name=\"bigpic\" src=\"" + imageFolder + bearLgPic[0] + "\"" +
		                 "width=\"420\" height=\"500\" >");
}


function outputViewDetails( )
{
	document.write("<input type=hidden name=\"QUANTITY\" value=\"1\">" +    
				   "<input type=hidden name=\"PRICE\" value=\"" + bearPrice + "\">" +
			       "<input type=hidden name=\"NAME\" value=\"" + bearName + "\">" +
				   "<input type=hidden name=\"ID_NUM\" value=\"" + bearSerial + "\">" +
				   "<input type=hidden name=\"SHIPPING\" value=\"" + bearWeight +"\">");
}

function outputBearDetails( bear )
{
	document.write("<input type=hidden name=\"QUANTITY\" value=\"1\">" +    
				   "<input type=hidden name=\"PRICE\" value=\"" + bearPrices[bear] + "\">" +
			       "<input type=hidden name=\"NAME\" value=\"" + bearNames[bear] + "\">" +
				   "<input type=hidden name=\"ID_NUM\" value=\"" + bearSerials[bear] + "\">" +
				   "<input type=hidden name=\"SHIPPING\" value=\"" + bearWeights[bear] +"\">");
}



function showBearName( bear )
{

	document.write("<span style=\"letter-spacing: -1pt\"><b><font face=\"Comic Sans MS\" style=\"font-size: 14pt\" color=\"#800080\">");
	if(bearTypes[bear] & wantMohair)
	{
						
		document.write("&nbsp;<img border=\"0\" src=\"images/mohairsm.gif\" width=\"48\" height=\"33\" alt=\"I'm made from mohair!\">&nbsp;");
	}
	else
	{
		document.write("<img border=\"0\" src=\"images/1x1.gif\" width=\"48\" height=\"33\" >&nbsp;");
	}	

	document.write( bearNames[bear].substring(0,1) ); 
	document.write("</font><font face=\"Comic Sans MS\" style=\"font-size: 14pt\"  color=\"#4F5B75\">");
	document.write( bearNames[bear].substring(1) ); 
	
	if(bearTypes[bear] & wantGrowler)
	{
		document.write("&nbsp;<embed src=\"images/growler.mp3\" hidden=true autostart=false width=\"1\" height=\"1\"><img alt=\"Click to hear me ROAR!\" name=\"grw" + bear +"\" onclick=\"playSound(0);\" border=\"0\" src=\"images/growlersm.gif\" width=\"48\" height=\"33\">");
		document.all("grw" + bear).style.cursor = "hand";
	}
	else
	{
		document.write("<img  border=\"0\" src=\"images/1x1.gif\" width=\"48\" height=\"33\" >");
	}	
	
	document.write("</font></b></span>");

}


function showBearName2( bear ) { document.write( bearNames[bear].substring(1) ); }
function showBearWeight( bear ) { document.write( bearWeights[bear] ) ; }
function showBearDetails ( bear ) { document.write( bearDetails[bear] ) ; }

function showBearPrice( bear ) 
{ 
	if(!(bearTypes[ bear] & wantSold) && !(bearTypes[ bear ] & wantWon) && !(bearTypes[ bear] & wantReserved))
	{
		document.write( showPrice(bearPrices[bear])); 
	}
	else if(bearTypes[ bear ] & wantWon)
	{
		document.write("<img src='images/won.gif' align='center'>");
	}
	else if(bearTypes[ bear ] & wantSold)
	{
		document.write("<img src='images/sold.gif' align='center'>");
	}
	else
	{
		document.write("<img src='images/resv.gif' align='center'>");
	}
}

function showFlags()
{
	document.write(	"<a title=\"Show price in British Pounds\" href=\"javascript:toCurr('GBP');\">" +
			"<img border=\"0\" src=\"images/f0-uk.gif\" width=\"21\" height=\"14\"></a>" +
			"<a title=\"Show price in US Dollars\" href=\"javascript:toCurr('USD');\">" +
			"<img border=\"0\" src=\"images/f0-us.gif\" width=\"21\" height=\"14\"></a>" +
			"<a title=\"Show price in Euro's\" href=\"javascript:toCurr('EUR');\">" +
			"<img border=\"0\" src=\"images/f0-eu.GIF\" width=\"22\" height=\"14\"></a>" +
			"<a title=\"Show price in Australian Dollars\" href=\"javascript:toCurr('AUD');\">" +
			"<img border=\"0\" src=\"images/f0-au.gif\" width=\"21\" height=\"14\"></a>" +
			"<a title=\"Show price in Canadian Dollars\" href=\"javascript:toCurr('CAD');\">" +
			"<img border=\"0\" src=\"images/f0-ca.gif\" width=\"22\" height=\"14\"></a>" +
			"<a title=\"Show price in South African Rand's\" href=\"javascript:toCurr('ZAR');\">" +
			"<img border=\"0\" src=\"images/f0-sa.gif\" width=\"21\" height=\"14\"></a>" );
}

function showSmallBear( pic )
{
	Pics = bearSmPics[pic];
	
	if(!(bearTypes[pic] & wantSold) && !(bearTypes[pic] & wantWon) && !(bearTypes[pic] & wantReserved))
	{
		document.write("<a title=\"Play and WIN " + bearNames[pic] + "!\" href=\"javascript:doComp('" + imageFolder + Pics[firstPic] + "','" + bearNames[pic] + 
	                "','" + bearDetails[pic] + "'," + bearPrices[pic] + "," + bearWeights[pic] + ",'" + bearSerials[pic] + "');\">" +
	                "<img alt='Play and WIN " + bearNames[pic] + "!' border='0' src=\"images/winmelo.gif\" name=\"wm" + pic + "\" onmouseover=\"document.wm" + pic +".src='images/winmehi.gif'\" " +
	                "onmouseout=\"document.wm" + pic +".src='images/winmelo.gif'\"></a><br>");
	}
	else
	{
		document.write("<img src='images/1x1.gif' height='27' width='1'><br>");
	}
	
	if(bearTypes[pic] & wantMulti)
	{
		document.write("<img alt='More Pictues of " + bearNames[pic] + "' id=\"sm" + (pic % 4) + "\"border=\"0\" src=\"" +	imageFolder + Pics[firstPic] + "\"" +
							 "width=\"170\" height=\"200\" onclick=\"javascript:showFeatureViewer(" + pic +" )\">");
	}
	else
	{
		document.write("<img alt='More Pictues of " + bearNames[pic] + "' id=\"sm" + (pic % 4) + "\"border=\"0\" src=\"" +	imageFolder + Pics[firstPic] + "\"" +
						 "width=\"170\" height=\"200\" onclick=\"javascript:showSingleViewer(" + pic +" )\">");
	}
}

function showNav(type)
{
	if(prevPage != -1 && type == 0)
	{
		document.write( "<a title=\"Go back a page\" onmouseover=\"document.goback.src='images/obackhi.gif'\"" +
		                " onmouseout=\"document.goback.src='images/obacklo.gif'\" href=\"teddybear.htm?id=" + prevPage + "\">" +
					    "<img border=\"0\" src=\"images/obacklo.gif\" width=\"72\" height=\"28\" name=\"goback\" ></a>" );
	}
	if(nextPage != -1 && type == 1)
	{
		document.write( "<a title=\"Go forward a page\" onmouseover=\"document.gonext.src='images/onexthi.gif'\"" +
		                " onmouseout=\"document.gonext.src='images/onextlo.gif'\" href=\"teddybear.htm?id=" + nextPage + "\">" +
					    "<img border=\"0\" src=\"images/onextlo.gif\" width=\"74\" height=\"28\" name=\"gonext\"></a>" );
	}
}

function showSingleViewer( pic )
{
 	document.location.href = getSingleArgs( pic , false );
}

function getSingleArgs( pic, fromProductPage )
{
	Pics = bearLgPics[pic];
	return "viewbear.htm?name=" + bearNames[pic] + "&price=" + bearPrices[pic] + "&weight=" + bearWeights[pic] + "&pp=" + ((fromProductPage) ? "1" : "0") +
 						     "&id=" + bearSerials[pic] + "&det=" + bearDetails[pic] + "&pic=" + Pics[firstPic] +
 						     "&avail=" + ((bearTypes[pic] & wantSold) ? "1" : ((bearTypes[pic] & wantWon) ? "2" : ((bearTypes[pic] & wantReserved) ? "4" : "0")));
}


function showFeatureViewer( pic )
{
 	document.location.href = getFeatureArgs( pic , false );
}

function getFeatureArgs( pic , fromProductPage )
{
	SPics = bearSmPics[pic];
	LPics = bearLgPics[pic];
 	return "viewfeature.htm?name=" + bearNames[pic] + "&price=" + bearPrices[pic] + "&weight=" + bearWeights[pic] + 
 		   "&id=" + bearSerials[pic] + "&det=" + bearDetails[pic] + "&pp=" + ((fromProductPage) ? "1" : "0") + "&ex=" + ((bearTypes[pic] & wantExtra) ? bearExtras[pic] : "") +
 		   "&spic0=" + SPics[firstPic] + "&spic1=" + SPics[secondPic] + "&spic2=" + SPics[thirdPic] + "&spic3=" + SPics[fourthPic] + 
 		   "&lpic0=" + LPics[firstPic] + "&lpic1=" + LPics[secondPic] + "&lpic2=" + LPics[thirdPic] + "&lpic3=" + LPics[fourthPic] +
 		   "&avail=" + ((bearTypes[pic] & wantSold) ? "1" : ((bearTypes[pic] & wantWon) ? "2" : ((bearTypes[pic] & wantReserved) ? "4" : "0")));
}

function showBearPage( loc )
{
	document.location.href = getBearPage( loc );
}

function getBearPage( loc )
{
	return (bearTypes[frontBears[thisPic + loc]] & wantMulti) ? getFeatureArgs( frontBears[thisPic + loc]) : getSingleArgs( frontBears[thisPic + loc] );
}

function showBearLink( loc )
{
	if(bearTypes[loc] & wantMulti)
	{
		document.location.href = getFeatureArgs( loc );
	}
	else
	{
		document.location.href = getSingleArgs( loc );
	}
}

function showAdoptMe( bear )
{
	if(!(bearTypes[bear] & wantSold) && !(bearTypes[bear] & wantWon) && !(bearTypes[bear] & wantReserved))
	{
		document.write("<a title=\"Add me to your basket\" href=\"javaScript:AddToCart(document.adoptme" + (bear % 4) + ");\" " +
		               "onmouseout=\"document.adopt" + bear + ".src='images/oadoptlo.gif'\" " +
		               "onmouseover=\"document.adopt" + bear + ".src='images/oadopthi.gif'\"> " +
		               "<img src=\"images/oadoptlo.gif\" border=\"0\" name=\"adopt" + bear + "\" width=\"111\" height=\"28\"  ></a>");
		Pics = bearLgPics[bear];
	}
}

function doComp(imgName , bearName , bearDetails , bearPrice , bearWeight , bearSerial)
{
	SetCompBear( imgName , bearName , bearDetails , bearPrice , bearWeight , bearSerial);
	document.location.href = "comp.htm?id=" + imgName + "&name=" + bearName + "&det=" + bearDetails + "&prc=" + bearPrice + "&wgt=" + bearWeight + "&ser=" + bearSerial;
}


function outputPrice( bear ) 
{ 

	if(!(bearTypes[bear] & wantSold) && !(bearTypes[bear] & wantWon) && !(bearTypes[bear] & wantReserved))
	{
		document.write( showPrice(BearPrice) + "&nbsp;" );
		document.write(
			"<a title=\"Show price in British Pounds\" href=\"javascript:toCurr('GBP');\">" +
			"<img border=\"0\" src=\"images/f0-uk.gif\" width=\"21\" height=\"14\"></a>" +
			"<a title=\"Show price in US Dollars\" href=\"javascript:toCurr('USD');\">" +
			"<img border=\"0\" src=\"images/f0-us.gif\" width=\"21\" height=\"14\"></a>" +
			"<a title=\"Show price in Euro's\" href=\"javascript:toCurr('EUR');\">" +
			"<img border=\"0\" src=\"images/f0-eu.GIF\" width=\"22\" height=\"14\"></a>" +
			"<a title=\"Show price in Australian Dollars\" href=\"javascript:toCurr('AUD');\">" +
			"<img border=\"0\" src=\"images/f0-au.gif\" width=\"21\" height=\"14\"></a>" +
			"<a title=\"Show price in Canadian Dollars\" href=\"javascript:toCurr('CAD');\">" +
			"<img border=\"0\" src=\"images/f0-ca.gif\" width=\"22\" height=\"14\"></a>" +
			"<a title=\"Show price in South African Rand's\" href=\"javascript:toCurr('ZAR');\">" +
			"<img border=\"0\" src=\"images/f0-sa.gif\" width=\"21\" height=\"14\"></a>" ); 
	}
	else if(bearTypes[bear] & wantSold)
	{
		document.write( "SOLD" );
	}
	else if(bearTypes[bear] & wantReserved)
	{
		document.write( "WON!" );
	}
	else
	{
		document.write( "RESERVED!" );
	}	
	
}

function toCurr( iso )
{
   	SetCookie("ISO", iso, null, "/");
   	
   	self.location.replace(self.location);

}

function showPrice( ukPrice )
{

	iso = GetCookie("ISO");
	
	if(iso == null || iso == "" || iso == 'GBP' || FXRates == null) return "£"+ukPrice;
	
	return FXRates.Symbol( iso )+Math.round(FXRates.Convert( ukPrice , iso ));
}
	
	

function GetCookie(name) 
{
	var arg = name + "=";
   	var alen = arg.length;
   	var clen = document.cookie.length;
   	var i = 0;

   	while ( i < clen ) {
      	var j = i + alen;
      	if( document.cookie.substring(i, j) == arg) 
      	{
    		var endstr = document.cookie.indexOf (";", j);
	 		if( endstr == -1) endstr = document.cookie.length;
   			var x = unescape(document.cookie.substring(j, endstr));
   			return x;
		}
      	i = document.cookie.indexOf(" ", i) + 1;
      	if(i == 0) break;
   	}

   return null;
}

function onBear()
{
	ob = GetCookie("ONBEAR");
	if(ob == null || ob == "") return 0;
	return parseInt(ob);
}

function SetBear()
{
	SetCookie("ONBEAR",thisPic,null,"/");
}


function GetCompBear()
{
	bearArgs_Parse();
	bearID = bearArgs("id");
	bearName = bearArgs("name");
	bearDetails = bearArgs("det");
	bearPrice = bearArgs("prc");
	bearWeight = bearArgs("wgt");
	bearSerial = bearArgs("ser");
	
	var person = bearArgs("person");
	var location = bearArgs("location");
	
	var msg = bearArgs("message");
	
	if(!bearID || bearID == "") 
	{
		bearID = GetCookie("COMPBEAR");
		bearName = GetCookie("COMPNAME");
		bearDetails = GetCookie("COMPDETAILS");
		bearPrice = GetCookie("COMPPRICE");
		bearWeight = GetCookie("COMPWEIGHT");
		bearSerial = GetCookie("COMPSERIAL");
		if(!bearID || bearID == "")
		{
			bearID  = baseImages + "1x1.gif";
			bearName = "";
		}
	}
	
	if(person && person != "")
	{
		SetCookie("VISITOR",person,null,"/");
		SetCookie("LOCATION",location,null,"/");
	}
	
	if(msg && msg != "")
	{
		wantMessage = true;
	}
	
	for(i = 0 ; i < numBears ; i++)
	{
		if(bearName == bearNames[i])
		{
			if((bearTypes[i] & wantSold) || (bearTypes[i] & wantReserved) || (bearTypes[i] & wantWon))
			{
				alert("I'm sorry but "+bearName+" has recently been sold, reserved or won and can no longer be played for!");
				document.location.href = "teddybear.htm";
				break;
			}
		}
	}

}

function GetVisitorName()
{
	var person = unescape(GetCookie("VISITOR"));
	if(person && person != "" && person != "null")
	{
		document.write("Welcome back <b>" + person + "</b>");
	}
}

function SetCompBear( bear , bearName , bearDetails , bearPrice , bearWeight , bearSerial )
{
	SetCookie("COMPBEAR",bear,null,"/");
	SetCookie("COMPNAME",bearName,null,"/");
	SetCookie("COMPDETAILS",bearDetails,null,"/");
	SetCookie("COMPPRICE",bearPrice,null,"/");
	SetCookie("COMPWEIGHT",bearWeight,null,"/");
	SetCookie("COMPSERIAL",bearSerial,null,"/");
}
	

function SetCookie(name,value,expires,path,domain,secure) 
{
	var exp = new Date();
	var mn = exp.getMonth() + 1;
	
	if(mn != 12)
	{
		exp.setMonth(mn+1);
	}
	else
	{
		exp.setMonth(0);
		exp.setFullYear(exp.getFullYear()+1);
	}
	
	document.cookie = name + "=" + escape (value) +
                     "; expires=" + exp.toGMTString() +
                     ((path) ? "; path=" + path : "") +
                     ((domain) ? "; domain=" + domain : "") +
                     ((secure) ? "; secure" : "");
}

function playSound( snd ) { document.embeds[snd].play(); }

function adLocation()
{
	document.location.href = thisAdURL;
}


thisAd = 0;
thisAdURL = "";

function doLoader()
{

	preLoadSrc = new Array(

			"images/bg9.jpg" ,
			"images/bg664.gif" ,
			"images/otopframe2.gif" ,
			"images/oalbion.gif" ,
			"images/otbears3.gif" ,
			"images/oleftframebit2.gif" , 
			"images/oleftframecbit3.gif" ,
			"images/orightframecbit2.gif" ,
			"images/orightframefeet4x1.gif" ,
			"images/ohpbut2.gif" ,
			"images/obrbut.gif" ,
			"images/omatbut.gif" ,
			"images/obkbu2t.gif" ,
			"images/orightframefeet4.gif" ,
			"images/oleftframe2.gif" ,
			"images/obline75l.gif" ,
			"images/obline75r.gif" ,
			"images/osig.gif" , 
			"images/orightframe2.gif" ,
			"images/obotmenu.gif" ,
			"images/uk.gif" ,
			"images/obotthin3.gif" ,
			"images/bbn.gif" ,
			"images/ddc.gif" ,
			"images/tbutton.gif" ,
			"images/tbon.gif" ,
			"images/tft2.gif" ,
			"images/ohihpbut.gif" ,
			"images/ohibrbut.gif" ,
			"images/ohibkbut.gif" ,
			"images/ohiinbut.gif" ,
			"images/ohimtbut.gif" ,
			"images/oinbut.gif" ,
			"images/piano.gif" ,
			"images/oanimebay3.gif" ,
			"images/looklo.gif" ,
			"images/lookhi.gif" ,
			"images/hellolo.gif" ,
			"images/hellohi.gif" 
	
	)
	

	preLoadImg = new Array(preLoadSrc.length)

	for(i = 0 ; i < preLoadImg.length ; i++)
	{
		preLoadImg[i] = new Image;
		preLoadImg[i].src = preLoadSrc[i];
	}
	
	
	bearLoader();
	
	rotateFrontPictures();
	
  //  rotateLinks();
}

function doBanner()
{
	document.location.href = thisAdURL;	
}

function bearLoader()
{
	if(!document.front3.complete) return;
	
	if(ldBear > numBears) 
	{
		ldBear = 1;
		return;
	}
	
	preLoad = new Image;

	if(ldBear < 10)
	{
		preLoad.src = "images/bears/bears00" + ldBear++ + ".jpg";
	}
	else
	{
		preLoad.src = "images/bears/bears0" + ldBear++ + ".jpg";
	}

	
	setTimeout("bearLoader()",500);
}


function rotateLinks() 
{
	if(document.voter.complete)
	{
	
		switch (thisAd) {
			case 0:
				thisAd = 1;
				thisAdURL = "http://www.tbonnet.com/";
				document.voter.src = "images/tbon.gif";
				break;
			case 1 :
				thisAd = 0;
				thisAdURL = "http://www.teddybearsearch.com/";
				document.voter.src = "images/tbutton.gif";
				break;
		}
	}
	setTimeout("rotateLinks()",5000);
}
		


function doGalleryLoader()
{
	document.gl0.src = imageFolder + galleryPics[getIndex(0)];
	document.gl1.src = imageFolder + galleryPics[getIndex(1)];
	document.gl2.src = imageFolder + galleryPics[getIndex(2)];

	preGallerySrc = new Array(

			"banner.jpg",
			"images/bg9.jpg" ,
			"images/bg664.gif" ,
			"images/otopframe2.gif" ,
			"images/oalbion.gif" ,
			"images/otbears3.gif" ,
			"images/oleftframebit2.gif" , 
			"images/oleftframecbit3.gif" ,
			"images/orightframecbit2.gif" ,
			"images/orightframefeet4x1.gif" ,
			"images/ohpbut2.gif" ,
			"images/obrbut.gif" ,
			"images/omatbut.gif" ,
			"images/obackbutt.gif" ,
			"images/orightframefeet4.gif" ,
			"images/oleftframe2.gif" ,
			"images/orightframe2.gif" ,
			"images/obotmenu.gif" ,
			"images/uk.gif" ,
			"images/obotthin3.gif" ,
			"images/ohihpbut.gif" ,
			"images/ohibrbut.gif" ,
			"images/ohibkbut.gif" ,
			"images/ohiinbut.gif" ,
			"images/ohimtbut.gif" ,
			"images/oinbut.gif" ,
			"images/gramo.gif" ,
			"images/gramr.gif" ,
			"images/bears/gallery1.jpg" ,
			"images/bears/gallery2.jpg" ,
			"images/bears/gallery3.jpg" ,
			"images/bears/gallery4.jpg" ,
			"images/bears/gallery5.jpg" ,
			"images/bears/gallery6.jpg" ,
			"images/piano3.gif" ,
			"images/obackbut.gif"
			
	)

	preGalleryImg = new Array(preGallerySrc.length)

	for(i = 0 ; i < preGalleryImg.length ; i++)
	{
		preGalleryImg[i] = new Image;
		preGalleryImg[i].src = preGallerySrc[i];
	}
	
	addNotes( );
	
	setTimeout("rotateGallery()",5000);
}

function doDsnLoader()
 {
	preDsnSrc = new Array(

			"images/combofrm.jpg" ,
			"images/eyesfrm.jpg" ,
			"images/fillsfrm.jpg" ,
			"images/jointsfrm.jpg" ,
			"images/mohairfrm.jpg" ,
			"images/velvetfrm.jpg" 
	
	)

	preDsnImg = new Array(preDsnSrc.length)

	for(i = 0 ; i < preDsnImg.length ; i++)
	{
		preDsnImg[i] = new Image;
		preDsnImg[i].src = preDsnSrc[i];
	}
}

bearArgs.keys = new Array();
bearArgs.values = new Array();

function bearArgs(key) 
{
	var value = null;
	for (var i=0;i<bearArgs.keys.length;i++) 
	{
    	if(bearArgs.keys[i]==key) 
    	{
        	value = bearArgs.values[i];
        	break;
      	}
   	}
   	return value;
} 

function bearArgs_Parse() 
{
	var query = window.location.search.substring(1);
   	var pairs = query.split("&"); 
   	
   	for (var i=0;i<pairs.length;i++) 
   	{
    	var pos = pairs[i].indexOf('=');
		if(pos >= 0) 
		{
    		var argname = pairs[i].substring(0,pos);
    	    var value = pairs[i].substring(pos+1);
    	    bearArgs.keys[bearArgs.keys.length] = argname;
    	    bearArgs.values[bearArgs.values.length] = value;
    	 }
   	}
}

function getPageID()
{
	var query = window.location.search.substring(1);
	if(query)
	{
	   	var pairs = query.split("&"); 
	   	var pos = pairs[0].indexOf('=');
		if(pos >= 0) 
		{
		    return parseInt(pairs[0].substring(pos+1));
		}
	}
	return 0;
}


function changeText( )
{

	for(i = 0 ; i < 4 ; i++)
	{
		switch(i) {
			case 0 :
				odiv = gp0;
				break;
			case 1 :
				odiv = gp1;
				break;
			case 2 :
				odiv = gp2;
				break;
			case 3 :
				odiv = gp3;
				break;
		}

		ochild = odiv.children(0);
		ihtml = ochild.innerHTML;
		onew = document.createElement("P");
		odiv.replaceChild(onew,ochild);
	    onew.innerHTML = getName( i );
	 }
}


function showText ( theText )
{
	document.write( getName( theText ) );
}

function getName( theText )
{
	return "<span style=\"letter-spacing: -1pt\" dir=\"ltr\"><b><font color=\"#800080\" face=\"Comic Sans MS\" size=\"3\">" + bearNames[frontBears[thisPic + theText]].substring(0,1) + "</font></b>" +
           "<font color=\"#4F5B75\" face=\"Comic Sans MS\" size=\"3\">" + bearNames[frontBears[thisPic + theText]].substring(1) + "</font></span>" ;
}

/* --------------------------------------------------------------- */

function showDetails()
{
	document.write(bearDetails);
}

/* --------------------------------------------------------------- */

function flashLook()
{
	switch(thisFlash) {
		case 0:
			document.hl.src="images/hellohi.gif";
			document.lk1.src="images/looklo.gif";
			document.lk2.src="images/looklo.gif";
			break;
		case 1:
			document.hl.src="images/hellolo.gif";
			document.lk1.src="images/lookhi.gif";
			document.lk2.src="images/looklo.gif";
			break;
		case 2:
			document.hl.src="images/hellolo.gif";
			document.lk1.src="images/looklo.gif";
			document.lk2.src="images/lookhi.gif";
			break;
	}
	
	if(++thisFlash == 3) thisFlash = 0;
	
	setTimeout("flashLook()",750);
}
	
/* --------------------------------------------------------------- */

function getEntryURL()
{
	return "http://www.smegsite.co.uk/albionbears/entry.asp?compbear="+bearID;
}

/* --------------------------------------------------------------- */

function getQuote() { return Math.floor(Math.random() * maxQuotes); }

/* --------------------------------------------------------------- */

function setQuote()
{
    var q = getQuote();
//    alert(q);
	document.all["qu" + q].style.display = "";
}

/* --------------------------------------------------------------- */

function doBearPage()
{
	fromProductPage = true;

	p = document.location.href.lastIndexOf("/")
	q = document.location.href.lastIndexOf(".")
	pic = bearOrder[parseInt(document.location.href.substring(p + 10,q),10) - 1];
	
	if(bearTypes[pic] & wantMulti)
	{
		document.location.href = getFeatureArgs( pic , true);
	}
	else
	{
		document.location.href = getSingleArgs( pic , true);
	}
	

}

/* --------------------------------------------------------------- */

function doViewerBack( fromProductPage )
{
	if(fromProductPage == "1")
	{
		fromProductPage = false;
		history.go(-2);
	}
	else
	{
		history.back();
	}
}
	
/* --------------------------------------------------------------- */

