/* javascript */

HouseOrderArray = [ 'bellamy', 'marram', 'pomfrets', 'salt' ]
disabledForSafariStartup = true

function getHouseDiv (theID){
	switch ( theID ){
		case 'hov01': var idee = 'bellamy';break;
		case 'hov011': var idee = 'bellamy';break;
		case 'hov02': var idee = 'marram';break;
		case 'hov021': var idee = 'marram';break;
		case 'hov022': var idee = 'marram';break;
		case 'hov03': var idee = 'pomfrets';break;
		case 'hov032': var idee = 'pomfrets';break;
		case 'hov04': var idee = 'salt';break;
	}
	return idee
}

/*
	1 find house in array
	2 take it out
	3 put it on end
	4 assign each div in array a z index
*/
function hov( theID ){
	if ( disabledForSafariStartup ){ return false }
	var idee = getHouseDiv ( theID ) // get this houses's name.
	ReshuffleArray ( idee ) // delete this house's current entry in array, and push to end
	rezindex () // set all houses new z-index
}


function ReshuffleArray ( thisHouse ){
	var i = 0
	while ( i < 4 ){
		var h = HouseOrderArray [ i ]
		if ( h == thisHouse){
			HouseOrderArray.splice ( i , 1 )
			HouseOrderArray.push( thisHouse )
		}
		i ++ 
	}
}

function rezindex (){
	var i = 0
	while ( i < 4 ){
		var a = document.getElementById ( HouseOrderArray [ i ] )
		var b = ( i * 10 ) + 310
		a.style.zIndex = b
		var c = document.getElementById ( HouseOrderArray [ i ] + "ContentText" )
		c.style.display = "none"
		var d = document.getElementById ( HouseOrderArray [ i ] + "houseImages" )
		d.style.display = "none"
		hideThisHouse ( HouseOrderArray [ i ] , 'hide' ) 
		i ++ 
	}
	//display last
	var a = document.getElementById ( HouseOrderArray [ 3 ] + "ContentText" )
	var d = document.getElementById ( HouseOrderArray [ 3 ] + "houseImages" )
	a.style.display = "block"
	d.style.display = "block"
	hideThisHouse ( HouseOrderArray [ 3 ] , 'show' ) 
}

function start( whichOne ){
	/*
		We wait 40millisec before 'setting up' the page. 
		Safari does sifr wrong if you hide the text it has to sifr (before it has siffered it)
		So we leave the text on the page so that safari can render the sifr and THEN hide it. 
		I know setting a fixed delay is a hack, but it'll work... (except on really slow computers...)
	*/
	disabledForSafariStartup = false // disbale the users JS-ing so safari can catch up...
	setTimeout("hov('" + whichOne + "')",40)
}






/*
	Depending on the house, 
	will hide the divs which trigger hover events - to get a better 'shape' for the houses.
	
	creates an array of IDs, hides them. 
*/
function hideThisHouse ( house , hide ){
	var arrayOfIds = new Array()
	switch ( house ){
		case 'bellamy': 
			arrayOfIds = [ 'hov011' ]
			break;
		case 'marram': 
			arrayOfIds = [ 'hov021' , 'hov022' ]
			break;
		case 'pomfrets': 
			arrayOfIds = [ 'hov032' ]
			break;
		case 'salt': 
			break;
	}
	for (i = 0; i < arrayOfIds.length ; i++  ){
		
		var x = document.getElementById ( arrayOfIds [ i ] ) // hide this
		if ( hide == 'hide'){
			x.style.display = "none"
		}else{
			x.style.display = "block"
		}
	}
}



















