var theStyle = 0;
var theBrowser;
var ie = false;

/*
function switchStyle()
{
 if(theStyle == 0)
 {
 document.getElementsByTagName('body')[0].id="plainbody";
 document.getElementById('header').id="plainhead";
 document.getElementById('nav').id="plainnav";
 document.getElementById('content').id="plaincont";
 document.getElementById('footer').id="plainfoot";
  document.getElementById('stylebutt').value="normal style";
  theStyle = 1;
 }

 else
 {
 document.getElementsByTagName('body')[0].id="body";
 document.getElementById('plainhead').id="header";
 document.getElementById('plainnav').id="nav";
 document.getElementById('plaincont').id="content";
 document.getElementById('plainfoot').id="footer";
 document.getElementById('stylebutt').value="plain style";
  theStyle = 0;
 }
}
*/

function overImage(imageName, picWidth)
{
	document.getElementById('bigPic').src="images/"+imageName;
	document.getElementById('bigPic').style.width=(""+picWidth+"px");
}

door2 = new Image();
door2.src = "images/dooropen.gif";

function doorOpen(doorName)
{
	document.getElementById(doorName).src=door2.src;
	document.getElementById('message').value="are you sure you want to go in the " +doorName + " ?";
}

function doorClose(doorName)
{
	document.getElementById(doorName).src="images/door.gif";
	document.getElementById('message').value=" ";
}

house2 = new Image();
house3 = new Image();
house2.src = "images/12abc.jpg";
house3.src = "images/12a.jpg";

function swapHouse()
{document.getElementById('image').src=house2.src;}

function returnHouse()
{document.getElementById('image').src=house3.src;}
/*nb this swaps it to a third image??*/

function addPic(picType)
{
	var num = parseInt(Math.floor(Math.random()*16));
	var picnum = parseInt(Math.floor(Math.random()*4));
	if(picnum<1)
		picnum=1;
	if(num<1)
		num=1;
	var whichPic;
	if(picType == 'ghost')
		whichPic = "images/gh";
	else if(picType == 'witch')
		whichPic = "images/wi";
	else
		whichPic = "images/de";
	document.getElementById('d'+num).src=whichPic+picnum+".gif";
}

function setPic(picName)
{document.getElementsByTagName('table')[0].id=picName;}

function overIt(){alert('over');}

var bedNode = document.createElement('a');
bedNode.appendChild(document.createTextNode(' bedroom '));
bedNode.id='newBed';
bedNode.href='bedroom.html';
var loungeNode = document.createElement('a');
loungeNode.appendChild(document.createTextNode(' lounge '));
loungeNode.id='newLounge';
loungeNode.href='lounge.html';
var bathNode = document.createElement('a');
bathNode.appendChild(document.createTextNode(' bathroom '));
bathNode.id='newBath';
bathNode.href='bathroom.html';


function roomList(room)
{
	if(ie)
	{
//	document.getElementById('IEnav').id="onIENav";
		document.getElementById('nav').id="onNav";
		if(room=="false")
		{
			document.getElementsByTagName('a')[4].style.background="white";
			document.getElementsByTagName('a')[5].style.background="white";
			document.getElementsByTagName('a')[6].style.background="white";
		}
		else
		{
			document.getElementsByTagName('a')[5].style.background="white";
			document.getElementsByTagName('a')[6].style.background="white";
			document.getElementsByTagName('a')[7].style.background="white";
		}
	}
	else
		document.getElementById('nav').id="onNav";
	
	document.getElementById('bedLink').appendChild(bedNode);
//document.getElementById('bedLink').href='bedroom.html';
	document.getElementById('loungeLink').appendChild(loungeNode);
//document.getElementById('loungeLink').href='lounge.html';
	document.getElementById('bathLink').appendChild(bathNode);
//document.getElementById('bathLink').href='bathroom.html';

	this.onLink('insideLink');
}

function removeList()
{
	document.getElementById('onNav').id="nav";
//	alert('bla');
	document.getElementById('bedLink').removeChild(bedNode);
	document.getElementById('loungeLink').removeChild(loungeNode);
	document.getElementById('bathLink').removeChild(bathNode);
}

function linkOver(linkID, linkName)
{
	document.getElementById(linkID).id='overLink';
	document.getElementById(linkName).style.color='black';
}

function linkOff(linkID, linkName)
{
	document.getElementById('overLink').id=linkID;
	document.getElementById(linkName).style.color='#00cc00';
}

function onLink(linkName)
{
	document.getElementById(linkName).style.color="#000000";
	if(linkName=='homeLink')
		removeList();
	else if(linkName=='gallLink')
		removeList();
	if(linkName=='picLink')
		removeList();
	if(linkName=='resLink')
		removeList();

// || linkName=='gallLink' || linkName=='picLink' linkName=='resLink'
}

function offLink(linkName)
{document.getElementById(linkName).style.color="#00cc33";}

function getBrowser()
{	
	theBrowser = navigator.appName;
//	alert(theBrowser);
	if(theBrowser=="Microsoft Internet Explorer")
	{
		ie = true;
		var version = navigator.appVersion;
		var vnum = version.charAt(0);
//document.getElementById('nav').id="IEnav";
		if(typeof document.body.style.maxHeight != "undefined")
		{
			document.getElementById('ssheet').href="mmie7.css";
		}
		else
			document.getElementById('ssheet').href="mmie.css";
	}
	else
	{
		document.getElementById('ssheet').href="mm.css";
		if(theBrowser=="Opera")
		{
			document.getElementById('gall').style.width="960px";		
		}
	}
}

function onButton(buttName)
{
	document.getElementById(buttName).style.color="yellow";
	document.getElementById(buttName).style.background="black";
}

function offButton(buttName)
{
	document.getElementById(buttName).style.color="black";
	document.getElementById(buttName).style.background="white";
}

function onPicButt(picType)
{
	if(picType=='ghostButt')
	{
		document.getElementById(picType).style.color="white";
	    document.getElementById(picType).style.background="black";
	}
	else if(picType=='witchButt')
	{
		document.getElementById(picType).style.color="#33ff00";
	    document.getElementById(picType).style.background="black";
	}
	else
	{
		document.getElementById(picType).style.color="red";
	    document.getElementById(picType).style.background="black";
	}
}
