/*/////////////////////////////////////////////////////////////////////////////



	DHTML Menu System

	

	This java script program implements configurable, vertical or horizontal cascading menus and is

	designed to use css classes and/or images for all menu cells.

	There are two javascript classes defined below, MenuController and MenuItem. MenuItems can be organized 

	into dynamically opening submenus to an arbitrary depth.



	Example usage:

	

		var Menu = new MenuController(0,"MenuTable","MainMenuItemForeground","MainMenuItemHover",

			"SubMenuTable",	"SubMenuItemForeground","SubMenuItemHover",

			"/images/arrow_down.gif","/images/arrow_right.gif")

			

		The arguments are: 

		1) 0=horizontal, 1=vertical

		2) table style class for table that encloses the entire menu

		3) column style class for normal top level menu item

		4) column style class for hovering over top level menu item

		5) table style class for table that encloses any submenus

		6) column style class for normal submenu item (optional,defaults to top level style)

		7) column style class for hovering over submenu item (optional, defaults to top level style)

		8) background image that is right-aligned behind items with no submenu (optional)

		9) background image that is right-aligned behind items with a submenu (optional)

		

	You can create as many menu controllers as you like if you want more than one menu on a page. Just assign 

	them to differnet variables.

	To add menu items, use:

	

		Menu.addMenuItem (1, 0, "index.htm","First First", "/images/navhome.gif", "/images/navhome_over.gif")

	

		The arguments are: 

		1) unique menu item number

		2) number of the parent menu item (or 0 if its at the top level)

		3) new URL if this is clicked on (Use an empty string if you don't want a link from here.)

		4) text displayed on the menu item

		5) image displayed normally (optional - text will not show if this is used)

		6) image displayed when mouse is hovering over it. (optional)

	

	You can set these up with inline java script in the header sections or from a linked file, and then insert this in

	the html where you want the menu to appear:

	

	<script language="JavaScript">

<!--

	Menu.drawMenu();

//-->

	</script>

	

	You can modify many display characteristics for different submenus or even individual menu items, using these commands

	before the menu is drawn but after the menu items are defined with the addMenuItem command above:

	

		Menu.menuItem[1].submenuHAlign="left" (or "center" or "right")

	This will align the submenu that opens from menu item 1 with the left of its display text or image.

	

		Menu.menuItem[1].submenuVAlign="top" (or "middle" or "bottom")

	This will align the submenu that opens from menu item 1 with the top of its display text or image.

	

		Menu.menuItem[1].submenuX = 5

		Menu.menuItem[1].submenuY = -4

	These will offset the submenu by 5 pixels to the right and 4 up.

	

		Menu.menuItem[1].addOnPageImage("contact.html,request.html","/images/navcontact.gif","/images/navcontact_over.gif")

	This will display the special images if you are currently on one of the pages in the first argument. Third arg is optional.

	

		Menu.menuItem[1].addOnPageStyle("contact.html,request.html","normalClass","hoverClass")

	This will display the special classes if you are currently on one of the pages in the first argument. Third arg is optional.

	

		Menu.menuItem[2].submenuWidth=150

	This will force a minimum width on the submenu that opens from menu item 2.

	

		Menu.menuItem[2].setSubmenuStyle("MainMenuItemHover", "MainMenuItemForeground")

	This will override the style classes for the entire submenu that opens from menu item 2.

	

		Menu.menuItem[21].normalClass="MainMenuItemForeground"

		Menu.menuItem[21].hoverClass="MainMenuItemHover"

		Menu.menuItem[21].normalImage="/images/navcontact.gif"

		Menu.menuItem[21].hoverImage="/images/navcontact_over.gif"

		

	For the ultimate in control, these last commands set the class or image for an individual menu item, in this case item 21.

	

		Menu.menuItem[13].popup = true

		Menu.menuItem[13].popupArgs = "scrolling stuff, etc"

	This will force the URL to load in a new page, using whatever argument string you want that is passed directly in to the

	java script window.open command.



 	by Ken Otwell, 2005

*//////////////////////////////////////////////////////////////////////////////displayThisObject(navigator, 'navigator')

//Remove this method if using Rob's jscripts.js script.

//function popUp(url,title,args)

//{

//	window.open(url,title,args)

//}



//Utility vars

var vdsmDelayTimer=[]

var vdsmDelayMilliseconds=750

var vdsmMenuArray=[]

var vdsmDebug=false



//Browser-specific vars and functions go here.

//Get the crappy part out of the way first.

var vdsBrowserXOffset = 0

var vdsBrowserYOffset = 0

if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.platform.indexOf('Mac')>=0)

{

	vdsBrowserYOffset = -32

}

var	vdsmDOM=(document.getElementById)?true:false

var vdsmNS4=(document.layers)?true:false

var vdsmIE=(document.all)?true:false

var vdsmUnkBrowser=false

var vdsmLayerRef,vdsmStyleSwitch,vdsmVisibleVar

if (vdsmNS4)

{ 

	vdsmLayerRef="document.layers"

	vdsmStyleSwitch=""

	vdsmVisibleVar="show"

} 

else if(vdsmIE)

{ 

	vdsmLayerRef="document.all"

	vdsmStyleSwitch=".style"

	vdsmVisibleVar="visible"

} 

else if(vdsmDOM)

{ 

	vdsmLayerRef="document.getElementByID"

	vdsmStyleSwitch=".style"

	vdsmVisibleVar="visible"

} 

else

{ 

	vdsmUnkBrowser = true

}

function vdsmGetElementbyID(ID)

{    

	return (vdsmDOM)? document.getElementById(ID) : (vdsmNS4) ? document.layers[ID] : document.all[ID]

}

function showLayer(layerID)

{ 

	if (vdsmUnkBrowser)

	{ 

		return 

	} 

	if (vdsmDOM)

	{ 

		document.getElementById(layerID).style.visibility=vdsmVisibleVar

		document.getElementById(layerID).style.display = 'block'

	}

	else

	{ 

		eval(vdsmLayerRef+'["'+layerID+'"]'+vdsmStyleSwitch+'.visibility="'+vdsmVisibleVar+'"')

		eval(vdsmLayerRef+'["'+layerID+'"]'+vdsmStyleSwitch+'.display="block"')

	}

} 

function hideLayer(layerID)

{ 

	if (vdsmUnkBrowser)

	{ 

		return

	} 

	if (vdsmDOM)

	{ 

		document.getElementById(layerID).style.visibility="hidden"

		document.getElementById(layerID).style.display = 'none'

	}

	else

	{ 

		eval(vdsmLayerRef+'["'+layerID+'"]'+vdsmStyleSwitch+'.visibility="hidden"')

		eval(vdsmLayerRef+'["'+layerID+'"]'+vdsmStyleSwitch+'.display="none"')

	}

} 

////////////////////////////////////////////

// Prototype objects defined next followed by their methods.

// 1) MenuItem - one of these objects are needed for each single cell or link in the menu.

// 2) MenuController - one of these objects are needed for each separate menu. 

//	  You can have more than one on a page.



function MenuItem ()//optional args: (my MenuController, unique ID, parent's ID, link URL, display label, normal image, hover image)

{

//  This creation method should only be called from within MenuController.addMenuItem().

//	Parse the argument array manually to enable optional args at end.

//	Note: There are no breaks inside of the switch statement to allow fall-through processing for remaining arguments.

	var alength = (arguments.length>7)?7:arguments.length

	switch(alength)

	{

		case 7:

			this.hoverImage = arguments[6]

			//remove any leading periods in image URL

			while(this.hoverImage.length>0 && this.hoverImage.charAt(0)=='.') 

			{this.hoverImage=this.hoverImage.substring(1,this.hoverImage.length)}

		case 6:

			this.normalImage = arguments[5]

			while(this.normalImage.length>0 && this.normalImage.charAt(0)=='.') 

			{this.normalImage=this.normalImage.substring(1,this.normalImage.length)}

		case 5:

			this.label = arguments[4]

			//Convert spaces in label to &nbsp;

			while(this.label.indexOf(" ") >=0)

			{this.label = this.label.replace(" ","&nbsp;")}

		case 4:

			this.url = arguments[3]

		case 3:

			this.parentID = arguments[2]

		case 2:

			this.id = arguments[1]

		case 1:

			this.menu = arguments[0]

	}

	this.tagID = "menu_"+this.menu.id+"_"+this.id

	this.imageID = this.tagID+"_image"

	this.layerNumber = 0

	this.popup = false

	this.popupArgs = ""

	this.children = []

	this.isSpotLit = false

	this.submenuHAlign = "left"

	this.submenuVAlign = "top"

	this.submenuWidth = 1

	this.submenuX = 0

	this.submenuY = 0

	this.submenuHtml = ""

}



//Add special images to appear only on certain pages for this menu item

function addOnPageImage(onPageURL,onPageImageNormal)

{

	if(!this._onPageCheck(onPageURL)) return

	//remove any leading periods

	while(onPageImageNormal.length>0 && onPageImageNormal.charAt(0)=='.') 

	{onPageImageNormal=onPageImageNormal.substring(1,onPageImageNormal.length)}

	this.normalImage = onPageImageNormal



	//check for special hover image too, if 3rd argument is there

	if(arguments.length>=3)

	{

		var onPageImageHover = arguments[2]

		//remove any leading periods

		while(onPageImageHover.length>0 && onPageImageHover.charAt(0)=='.') 

		{onPageImageHover=onPageImageHover.substring(1,onPageImageHover.length)}

		this.hoverImage = onPageImageHover

	}

}

MenuItem.prototype.addOnPageImage = addOnPageImage;



//Add special style classes to appear only on certain pages for this menu item

function addOnPageStyle(onPageURL,onPageNormalClass)

{

	if(!this._onPageCheck(onPageURL)) return

	this.normalClass = onPageNormalClass

	

	//check for special hover style too, if 3rd argument is there

	if(arguments.length>=3)	this.hoverClass = arguments[2]

}

MenuItem.prototype.addOnPageStyle = addOnPageStyle;



//Cascade this setting down one level of menu items

function setSubmenuStyle(normalClass, hoverClass)

{

	for(var i in this.children)

	{

		this.children[i].normalClass = normalClass

		this.children[i].hoverClass = hoverClass

	}

}

MenuItem.prototype.setSubmenuStyle = setSubmenuStyle;



//Open the submenu under the trigger object. Only one array of layers is needed to hold the submenus,

//because only one menu path is ever open at the same time. Just reload the contents for each submenu as needed and 

//reposition the layer at the correct offset.

function _openSubmenu(trigger)//"trigger" is the DOM object for the menu item that was clicked

{

	this._closeSubmenu() //just in case.

	if(this.children.length==0) return false

	if(vdsmDebug)confirm("Opensubmenu from "+this.id)

	

	//Here's the magic positioning stuff.

	//Start with any desired or necessary offsets...

	var leftpos = this.submenuX + vdsBrowserXOffset

	var toppos = this.submenuY + vdsBrowserYOffset

	//Then, basically, add up all the offsets of your parent DOM objects to get

	//the absolute position for this submenu.

	var aTag = trigger

	do {

		leftpos += aTag.offsetLeft;

		toppos += aTag.offsetTop;

		aTag = aTag.offsetParent;

	} while(aTag)

	var layerName = this.menu.layerID[this.layerNumber]

	var layer = vdsmGetElementbyID(layerName)

	

	//Now adjust final placement based on menu orientation

	//All submenus are vertical---- not necessary, just a choice I made.

	if ((this.menu.isVertical)||(this.parentID>0))

	{

		layer.top = toppos - 1 //Don't know why this is necessary, but it is.

		layer.left = leftpos + trigger.offsetWidth 

	}

	else 

	{

		layer.top = toppos + trigger.offsetHeight 

		layer.left = leftpos 

	}



	layer.innerHTML = this.submenuHtml

	layer.style.width=this.submenuWidth  + "px" // Firefox REQUIRES the 'px'!!

	//Have to show the layer first for browser to adjust the width if needed, then quickly realign it if desired.

	showLayer(layerName)

	switch(this.submenuHAlign.toLowerCase())

	{

		//"left" is default, nothing needed

		case "center":

		layer.left += (trigger.offsetWidth  - layer.firstChild.offsetWidth) / 2

		break

		case "right":

		layer.left += (trigger.offsetWidth  - layer.firstChild.offsetWidth)

	}

	switch(this.submenuVAlign.toLowerCase())

	{

		//"top" is default, nothing needed

		case "middle":

		layer.top += (trigger.offsetHeight  - layer.firstChild.offsetHeight) / 2

		break

		case "bottom":

		layer.top += (trigger.offsetHeight  - layer.firstChild.offsetHeight)

	}

	layer.style.top = layer.top + "px" // Firefox REQUIRES the 'px'!!

	layer.style.left = layer.left + "px"

}

MenuItem.prototype._openSubmenu = _openSubmenu;



function _closeSubmenu()

{

	if(vdsmDebug)confirm("closing layer "+this.menu.layerID[this.layerNumber]+" at "+this.layerNumber)

	for (var cnt=this.menu.numLayers-1; cnt>=this.layerNumber;cnt--)

		hideLayer(this.menu.layerID[cnt])

}

MenuItem.prototype._closeSubmenu = _closeSubmenu;



//Compute html for the menu item table cell once and save it. Insert it into the layer when needed.

function _getMenuItemHtml()

{

	var sHTML = ""

	var itemStyle = ""



	if ((this.menu.isVertical)||(this.layerNumber>0))

		sHTML = "<tr>"

		

	if(this.menu.simpleBgImage && this.children.length==0)

		itemStyle = " style=\"background-image: url('"+this.menu.simpleBgImage+"'); background-repeat: no-repeat; background-position: 100% 50%\""

	else if(this.menu.expandBgImage && this.children.length>0)

		itemStyle = " style=\"background-image: url('"+this.menu.expandBgImage+"'); background-repeat: no-repeat; background-position: 100% 50%\""

		

	sHTML += "<td id='"+this.tagID+"' class='"+this.normalClass+"'"+itemStyle

	if(this.normalImage && this.normalImage.length>0)

	{

		sHTML += "><img id=\""+this.imageID+"\" alt=\""+this.label+"\" src=\""+this.normalImage+"\" style=\"cursor: pointer;\" "

		sHTML += this._getMouseBehavior()

	}

	else

	{

		sHTML += this._getMouseBehavior()

		sHTML += this.label

	}

	sHTML += "</td>"



	if ((this.menu.isVertical)||(this.layerNumber>0))

		sHTML += "</tr>"

	return sHTML

}

MenuItem.prototype._getMenuItemHtml = _getMenuItemHtml;



//Wrap submenu items in their own table.

function _getSubmenuHtml()

{

	if(this.children.length==0) return ""

	var sHTML="<table class='"+this.menu.submenuTableClass+"' cellspacing=0 cellpadding=0>"

	for (var i in this.children) 

		sHTML += this.children[i]._getMenuItemHtml()

	sHTML += "</table>"

	return sHTML

}

MenuItem.prototype._getSubmenuHtml = _getSubmenuHtml;



//Create java script mouse behavior as needed.

function _getMouseBehavior()

{

	var html = " onmouseover='javascript:processMenuItemHover("+this.menu.id+","+this.id+",this)'"

	if(this.url!="")

	{

		if(this.popup)

			html += " onclick='javascript:popUp(\""+this.url+"\",\"\",\""+this.popupArgs+"\")'"

		else

			html += " onclick='javascript:document.location.href=\""+this.url+"\"'"

	}

	html += " onmouseout='javascript:processMenuItemExit("+this.menu.id+","+this.id+")'>"

	return html

}

MenuItem.prototype._getMouseBehavior = _getMouseBehavior;



//Dynamically change image or class for mouse-over highlighting.

function _spotlightMe()

{	

	this.isSpotLit = false

	if(vdsmDebug)confirm("SpotlightMe "+this.id)

	this.menu.nowAt=this

	var checkItems, image

	

	//Turn off the spotlight for any submenus.

	if (this.layerNumber>0)

		checkItems=this.menu.menuItem[this.parentID].children

	else

		checkItems=this.menu.menuItem

	for (var i in checkItems) 

		if(checkItems[i].isSpotLit) checkItems[i]._killMySpotlight()



	//Turn on my spotlight!

	this.isSpotLit = true

	image = vdsmGetElementbyID(this.imageID)

	if(image && image != "") image.src=this.hoverImage

	if(this.hoverClass && this.normalClass) changeClass(this.tagID,this.hoverClass)

}

MenuItem.prototype._spotlightMe = _spotlightMe;



//Change image or class when mouse-over highlighting goes away

function _killMySpotlight()

{

	this.isSpotLit = true

	if(vdsmDebug)confirm("_killMySpotlight from "+this.id)

	this._closeSubmenu()

	this.isSpotLit = false

	image = vdsmGetElementbyID(this.imageID)

	if(image && image!="") image.src=this.normalImage	

	if(this.hoverClass && this.normalClass) changeClass(this.tagID,this.normalClass)

	if(this.menu.nowAt==this) this.menu.nowAt=""

}

MenuItem.prototype._killMySpotlight = _killMySpotlight;



// Check to see if the browser is on a special page for using a special image or style class

// If onPageURL is a substring of the actual URL, return true.

// Allow multiple URL Checks to be separated by commas.

function _onPageCheck(onPageURL)

{

	var URLArray = onPageURL.split(",") 

	for (var i in URLArray)

	{

		var URL = URLArray[i]

		//remove any leading periods.

		while(URL.length>0 && URL.charAt(0)=='.') {URL=URL.substring(1,URL.length)}

		if(window.location.href.indexOf(URL) >= 0)return true

	}

	return false

}

MenuItem.prototype._onPageCheck = _onPageCheck;



// End of MenuItem methods.

//

///////////////////////////////////////////////////////////////////////////////////////////

// Define the MenuController object 

//

// One MenuController should be created for each separate menu if multiple menus are needed

function MenuController ()

//optional args: (vertical/horizontal flag, table class, normal cell class, hover cell class, 

//				submenu table class, sm normal cell class, sm hover cell class,

//				background image if no submenu, background image if there is a submenu)

//	Parse the argument array manually to enable optional args at end of arg list.

//	Note: There are no breaks inside of the switch statement to allow fall-through processing.

{

	var alength = (arguments.length>9)?9:arguments.length

	switch(alength)

	{

		case 9:

			this.expandBgImage = arguments[8]

		case 8:

			this.simpleBgImage = arguments[7]

		case 7:

			this.submenuClassHover = arguments[6]

		case 6:

			this.submenuClassNormal = arguments[5]

		case 5:

			this.submenuTableClass = arguments[4]

		case 4:

			this.hoverClass = arguments[3]

		case 3:

			this.normalClass = arguments[2]

		case 2:

			this.menuTableClass= arguments[1]

		case 1:

			this.isHorizontal = arguments[0]==0

			this.isVertical = arguments[0]==1

	}

	if(!this.submenuClassHover)this.submenuClassHover = this.hoverClass

	if(!this.submenuClassNormal)this.submenuClassNormal = this.normalClass

	this.menuItem = []

	this.numLayers = 0

	this.layerID = []

	this.id = vdsmMenuArray.length

	vdsmMenuArray[this.id] = this

	this.nowAt=""// The lowest-level menu item that is hovered over or "spotlighted."

}



//	This is the only method that should create MenuItems

function addMenuItem ()

{

	var newMenuItem

	var id,parentID=0,url=""

	var label=""

	var normalImage=false

	var hoverImage=false

	var alength = (arguments.length>6)?6:arguments.length

	switch(alength)

	{

		case 6:

			hoverImage = arguments[5]

		case 5:

			normalImage = arguments[4]

		case 4:

			label = arguments[3]

		case 3:

			url = arguments[2]

		case 2:

			parentID = arguments[1]

		case 1:

			id = arguments[0]

	}

	switch(alength)

	{

		case 6:

			newMenuItem = new MenuItem (this, id, parentID, url, label, normalImage, hoverImage)

			break

		case 5:

			newMenuItem = new MenuItem (this, id, parentID, url, label, normalImage)

			break

		case 4:

			newMenuItem = new MenuItem (this, id, parentID, url, label)

			break

		case 3:

			newMenuItem = new MenuItem (this, id, parentID, url)

			break

		case 2:

			newMenuItem = new MenuItem (this, id, parentID)

			break

		case 1:

			newMenuItem = new MenuItem (this, id)

	}

	if (parentID==0) 

	{

		newMenuItem.layerNumber = 0

		newMenuItem.normalClass = this.normalClass

		newMenuItem.hoverClass = this.hoverClass

	}

	else

	{

		var parent = this.menuItem[parentID];

		parent.children[id] = newMenuItem

		newMenuItem.layerNumber = parent.layerNumber + 1

		if (this.numLayers < newMenuItem.layerNumber)

			this.numLayers = newMenuItem.layerNumber

		newMenuItem.normalClass = this.submenuClassNormal

		newMenuItem.hoverClass = this.submenuClassHover

	}	

	this.menuItem[id] = newMenuItem

	return newMenuItem

}

MenuController.prototype.addMenuItem = addMenuItem;



// Once all the menu items are created, generate all the menu HTML and draw the top level in place.

function drawMenu ()

{

	//Create the <div> tag wrapper to hold each menu layer.

	for (var i=0; i<this.numLayers ; i++)

		this._createSubLayer(i)

	//Generate top-level table wrapper

	var sHTML="<table class='"+this.menuTableClass+"' cellspacing=0 cellpadding=0>"

	if(this.isHorizontal) sHTML += "<tr>"

	for (var i in this.menuItem) 

	{

		var menuItem = this.menuItem[i]

		//load HTML for top level menu

		if(menuItem.parentID==0)

			sHTML += menuItem._getMenuItemHtml()

		//save HTML for each submenu

		menuItem.submenuHtml = menuItem._getSubmenuHtml()

	}

	if(this.isHorizontal) sHTML += "</tr>"

	sHTML += "</table>"

	//Write the top level menu to the document.

	document.writeln(sHTML)

}

MenuController.prototype.drawMenu = drawMenu;



function _createSubLayer (layerNumber)

{

	this.layerID[layerNumber]="menu_content_"+this.id+"_"+layerNumber

	//Generate the <div> tag to control the positioning

	var sHTML = "<div ONCLICK='event.cancelBubble=true' id='"+this.layerID[layerNumber]

	sHTML +="' style='z-index:100;position:absolute;'>"

	//Generate a <span> tag to hold the menu layer contents

	sHTML +="<span id='"+this.layerID[layerNumber]+"_content'></span></div>"

	document.write(sHTML)

	// Hide this layer by default

	hideLayer(this.layerID[layerNumber])

}

MenuController.prototype._createSubLayer = _createSubLayer;



//Turn off any items that are showing when the mouse leaves the menu

function _reset()

{

	for (var cnt=this.numLayers-1;cnt>=0; cnt--)

		hideLayer(this.layerID[cnt])

	for (var i in this.menuItem) 

		if(this.menuItem[i].layerNumber==0)

			this.menuItem[i]._killMySpotlight()

}

MenuController.prototype._reset = _reset;





// End of MenuController methods.

//

///////////////////////////////////////////////////////////////////////////////////////////

/// non-object methods



// Mouse over a menu item

function processMenuItemHover(menuID,itemID,trigger)

{

	if(vdsmDebug)confirm("ProcessMenuItemHover "+menuID+" "+itemID)

	clearInterval(vdsmDelayTimer[menuID])

	var menuItem=vdsmMenuArray[menuID].menuItem[itemID]

	menuItem._spotlightMe()

	menuItem._openSubmenu(trigger)

}



// Mouse way from a menu item

function processMenuItemExit(menuID,itemID)

{

	if(vdsmDebug)confirm("ProcessMenuItemExit "+menuID+" "+itemID)

	clearInterval(vdsmDelayTimer[menuID])

	vdsmDelayTimer[menuID]=setTimeout("vdsmMenuArray["+menuID+"]._reset()",vdsmDelayMilliseconds)

}



//Reset the style class for this dom object to change it's display characteristics.

function changeClass(id, newClass)

{

	if(!newClass || newClass=="") return

	var tag = vdsmGetElementbyID(id)

	if(!tag)return

	if(vdsmDebug)confirm("changing "+id+" to class "+newClass+" on object "+tag)

	tag.className = newClass;

}



// use this method for debugging javascript objects

function displayThisObject(obj, obj_name) {

   var result = ""

   for (var i in obj)

      result += obj_name + "." + i + " = " + obj[i] + "  -  "

   confirm(result)

}



// Clicking off the menu will reset it in case of emergency. 

function handleonclick()

{

	for (var i in vdsmMenuArray)

		vdsmMenuArray[i]._reset()	

}

document.onclick = handleonclick



// The <esc> key will reset the menu in case of emergency.

function handlekeypress(e)

{

	if (vdsmNS4)

	{

		var keyCode = e.keyCode?e.keyCode:e.which?e.which:e.charCode;

		if ((keyCode==27)||(keyCode==1))

			handleonclick()

	}

	else if ((event.keyCode==0)||(event.keyCode==27))

		handleonclick()

}

document.onkeypress = handlekeypress