var catalogInOut = 'in'	// the panel starts off as "in" - i.e. not showing. 	
var scrollSpeedIn = 10 // set this - movement repeat rate (milliseconds) - NB slower processors will not go <c.100 anyway
var scrollSpeedOut = 10 // ditto
var posCatalog = -255 //starting position of the catalog
var posHelpBar = -255
var helpBarInOut = 'in'	// the panel starts off as "in" - i.e. not showing. 	
var catalogStartPosition = posCatalog
var helpStartPosition = posHelpBar
var allowLayersToScroll = false
function createMyObject(what1,where1,what2,where2){
	this.what1 = what1;
	this.where1 = where1;
	this.what2  = what2;
	this.where2 = where2;
	}


function centerMyLayer(what1,where1,what2,where2){
	if(allowLayersToScroll == true){} //don't scroll if told not to
	else{
		// Keeps the catalog & help bar flush with the top of the screen, plus any nudgeDown if required	
	var nudgeDown1 = where1
	var nudgeDown2 = where2
	height = document.body.offsetHeight
	var top1 = document.body.scrollTop+nudgeDown1
	var top2 = document.body.scrollTop+nudgeDown2
	what1.style.top = parseInt(top1)
	what2.style.top = parseInt(top2)
	}
	myObject = new createMyObject(what1,where1,what2,where2)
	setTimeout("centerMyLayer(myObject.what1,myObject.where1,myObject.what2,myObject.where2)", 200)
}     
	
function hideCatalog() { // puts catalog away again, moving 10 steps at a time
	allowLayersToScroll = false // turns on keep-layers-centered again
	posCatalog = parseInt(theQuickCat.style.left)
	posCatalog = eval(posCatalog - 10)
	var endVal = eval(catalogStartPosition)
	theQuickCat.style.left = posCatalog
	if(posCatalog.valueOf() > endVal){ // hasn't gone all the way back yet so loop round again, after a delay
	setTimeout("hideCatalog()", scrollSpeedIn)
	}
	else{// it has reached or overshot the end, so put it in the right place
	theQuickCat.style.left = endVal}
	document.images.catalogTab.src="/cutlery2/images/catalog_handle.gif" // and switch the image back again
	catalogInOut = 'in'
	theQuickCat.style.zIndex = 1
}

function hideHelpLayer() { // puts catalog away again, moving 10 steps at a time
	allowLayersToScroll = false // turns on keep-layers-centered again
	posHelpBar = parseInt(helpBar.style.left)
	posHelpBar = eval(posHelpBar - 10)
	var endVal = eval(helpStartPosition)
	helpBar.style.left = posHelpBar
	if(posHelpBar.valueOf() > endVal){ // hasn't gone all the way back yet so loop round again, after a delay
	setTimeout("hideHelpLayer()", scrollSpeedIn)
	}
	else{// it has reached or overshot the end, so put it in the right place
	helpBar.style.left = endVal}
	document.images.helpTab.src="/cutlery2/images/helpHandle.gif" // and switch the image back again
	helpBarInOut = 'in'
}

function scrollInOrOut(inOrOut){ //scrolls in the div is currently out, and vice versa
	if(inOrOut == 'out'){hideCatalog()}
	else{scrollIn()}
	if(catalogInOut == 'in'){catalogInOut = 'out'}else{catalogInOut = 'in'}
}

function scrollHelpBarInOrOut(inOrOut){ //scrolls in the div is currently out, and vice versa
	if(inOrOut == 'out'){hideHelpLayer();}
	else{scrollHelpBarIn();}
	if(inOrOut == 'in'){helpBarInOut = 'out'}else{helpBarInOut = 'in'}
}



function scrollIn(){ // scrolls the catalog onto the page, 10 pixels at a time
	allowLayersToScroll = true // disables keep-layers-centered 
	if(helpBarInOut == 'out'){hideHelpLayer()} //put the help bar away before bringing on the catalog
	theQuickCat.style.zIndex = 11
	posCatalog = eval(posCatalog.valueOf() + 10)
	var endVal = 0
	theQuickCat.style.left = posCatalog // actually move the div from left = [oldi] to the new value of i
	if(posCatalog.valueOf() < endVal){ // it hasn't reached the end point yet, so loop round again
	setTimeout("scrollIn()", scrollSpeedOut)
	}
	else{ // it has reached the end point, or overshot it
	theQuickCat.style.left = endVal // put it in the right place if necessary
	document.images.catalogTab.src="/cutlery2/images/catalog_handle_back.gif" //set the image to back-pointing arrows.
	}
}


function scrollHelpBarIn(){ // scrolls the helpBar onto the page, 10 pixels at a time
	allowLayersToScroll = true // disables keep-layers-centered 
	if(catalogInOut == 'out'){hideCatalog()} //put the catalog away before bringing on the help bar
	posHelpBar = eval(posHelpBar.valueOf() + 10)
	var endVal = 0
	helpBar.style.left = posHelpBar // actually move the div from left = [oldi] to the new value of i
	if(posHelpBar.valueOf() < endVal){ // it hasn't reached the end point yet, so loop round again
	setTimeout("scrollHelpBarIn()", scrollSpeedOut)
	}
	else{ // it has reached the end point, or overshot it
	helpBar.style.left = endVal // put it in the right place if necessary
	document.images.helpTab.src="/cutlery2/images/helpHandle_back.gif" //set the image to back-pointing arrows.
	}
}
