﻿document.write('<table id="vista-buttons.com:idf6rwd" width=0 cellpadding=0 cellspacing=0 border=0><tr><td style="padding-right:0px" title =""><a href="http://www.bellemontumc.org/" onmouseover=\'xpe("f6rwdo");\' onmouseout=\'xpe("f6rwdn");\'><img id="xpi_f6rwd" src="'+vbImgPath+'/btf6rwd_0.gif" name="vbf6rwd" width="132" height="36" border="0" alt=""/></a></td><td style="padding-right:0px" title ="Home"><a href="http://www.bellemontumc.org/SummerCamp.htm" onmouseover=\'xpe("n6rwdo");\' onmouseout=\'xpe("n6rwdn");\'><img id="xpi_n6rwd" src="'+vbImgPath+'/btn6rwd_0.gif" name="vbn6rwd" width="75" height="36" border="0" alt="Home"/></a></td><td style="padding-right:0px" title ="Forms & Registration"><a onmouseover=\'xpe("h6rwdo");xpshow("h6rwd",0,this);xpsmover(this);\' onmouseout=\'xpsmout(this);\'><img id="xpi_h6rwd" src="'+vbImgPath+'/bth6rwd_0.gif" name="vbh6rwd" width="153" height="36" border="0" alt="Forms & Registration"/></a></td><td style="padding-right:0px" title ="About Us"><a href="http://www.bellemontumc.org/CampAboutUs.htm" target="_parent" onmouseover=\'xpe("j6rwdo");xpshow("j6rwd",0,this);xpsmover(this);\' onmouseout=\'xpsmout(this);\'><img id="xpi_j6rwd" src="'+vbImgPath+'/btj6rwd_0.gif" name="vbj6rwd" width="97" height="36" border="0" alt="About Us"/></a></td><td style="padding-right:0px" title ="Calendar"><a href="http://www.bellemontumc.org/CampCalendar.htm" target="_top" onmouseover=\'xpe("k6rwdo");xpshow("k6rwd",0,this);xpsmover(this);\' onmouseout=\'xpsmout(this);\'><img id="xpi_k6rwd" src="'+vbImgPath+'/btk6rwd_0.gif" name="vbk6rwd" width="96" height="36" border="0" alt="Calendar"/></a></td><td style="padding-right:0px" title ="Inclement Weather"><a href="http://www.bellemontumc.org/CampWeather.htm" target="_top" onmouseover=\'xpe("g6rwdo");\' onmouseout=\'xpe("g6rwdn");\'><img id="xpi_g6rwd" src="'+vbImgPath+'/btg6rwd_0.gif" name="vbg6rwd" width="132" height="36" border="0" alt="Inclement Weather"/></a></td><td style="padding-right:0px" title ="Policies"><a onmouseover=\'xpe("i2rwdo");xpshow("i2rwd",0,this);xpsmover(this);\' onmouseout=\'xpsmout(this);\'><img id="xpi_i2rwd" src="'+vbImgPath+'/bti2rwd_0.gif" name="vbi2rwd" width="87" height="36" border="0" alt="Policies"/></a></td><td style="padding-right:0px" title ="Tuition and Fees"><a href="http://www.bellemontumc.org/CampTuition.htm" target="_top" onmouseover=\'xpe("12rwdo");\' onmouseout=\'xpe("12rwdn");\'><img id="xpi_12rwd" src="'+vbImgPath+'/bt12rwd_0.gif" name="vb12rwd" width="119" height="36" border="0" alt="Tuition and Fees"/></a></td><td style="padding-right:0px" title ="Directions"><a href="http://www.bellemontumc.org/CampDirections.html" target="_top" onmouseover=\'xpe("c2rwdo");\' onmouseout=\'xpe("c2rwdn");\'><img id="xpi_c2rwd" src="'+vbImgPath+'/btc2rwd_0.gif" name="vbc2rwd" width="87" height="36" border="0" alt="Directions"/></a></td></tr></table>');
document.write('<ul id="vbUL_h6rwd" class="vbULf6rwd" style="visibility:hidden;"><li><img src="'+vbImgPath+'/smd2rwd.gif"/><a href="https://app.formassembly.com/forms/view/87829" title="Secure Online Registration" target="_top">Secure&nbsp;Online&nbsp;Registration</a></li><li><img src="'+vbImgPath+'/smq2rwd.gif"/><a href="http://www.bellemontumc.org/PDFs/Info_Packet.pdf" title="Parent Info Packet" target="_top">Parent&nbsp;Info&nbsp;Packet</a></li><li><img src="'+vbImgPath+'/smq2rwd.gif"/><a href="http://www.bellemontumc.org/PDFs/2010RegistrationForm.pdf" title="2010 Registration Forms" target="_top">2010&nbsp;Registration&nbsp;Forms</a></li><li><img src="'+vbImgPath+'/smq2rwd.gif"/><a href="http://www.bellemontumc.org/PDFs/Camp_Medical_Forms.pdf" title="Camp Medical Forms" target="_top">Camp&nbsp;Medical&nbsp;Forms</a></li><li><img src="'+vbImgPath+'/smq2rwd.gif"/><a href="http://www.bellemontumc.org/PDFs/WhatEveryCamperNeeds.pdf" title="What Every Camper Needs" target="_parent">What&nbsp;Every&nbsp;Camper&nbsp;Needs</a></li><li><a href="http://www.bellemontumc.org/CLWPermission.html" title="Trip Permission Forms" target="_top">Trip&nbsp;Permission&nbsp;Forms</a></li></ul><ul id="vbUL_j6rwd" class="vbULf6rwd" style="visibility:hidden;"><li><a href="http://www.bellemontumc.org/CampAboutUs.htm" title="What is Camp Living Water?" target="_parent">What&nbsp;is&nbsp;Camp&nbsp;Living&nbsp;Water?</a></li><li><a href="http://www.bellemontumc.org/CampStaff.htm" title="Camp Staff" target="_parent">Camp&nbsp;Staff</a></li><li><a href="http://www.bellemontumc.org/CampOverview.htm" title="Overview of Program" target="_parent">Overview&nbsp;of&nbsp;Program</a></li></ul><ul id="vbUL_k6rwd" class="vbULf6rwd" style="visibility:hidden;"><li><a href="file://localhost/C:/Users/Kindom Quest/Documents/Excel After-School/Summer Day Camp/2010/Web Pages/CampSchedule.htm" title="Sample Daily Schedule" target="_top">Sample&nbsp;Daily&nbsp;Schedule</a></li><li><a href="http://www.bellemontumc.org/CampGlance.htm" title="Summer Calendar at a Glance" target="_top">Summer&nbsp;Calendar&nbsp;at&nbsp;a&nbsp;Glance</a></li><li><a href="http://www.bellemontumc.org/CampTrips.htm" title="Trip Dates" target="_top">Trip&nbsp;Dates</a></li><li><a href="http://www.bellemontumc.org/CampCalendar.htm" title="Trip Permission Forms" target="_top">Trip&nbsp;Permission&nbsp;Forms</a></li></ul><ul id="vbUL_i2rwd" class="vbULf6rwd" style="visibility:hidden;"><li><a href="http://www.bellemontumc.org/CampHours.htm" title="Hours of Operation" target="_top">Hours&nbsp;of&nbsp;Operation</a></li><li><a href="http://www.bellemontumc.org/CampAbsences.htm" title="Absences" target="_top">Absences</a></li><li><a href="http://www.bellemontumc.org/CampDrop-off.htm" title="Drop-off/Pick-up Procedures" target="_top">Drop-off/Pick-up&nbsp;Procedures</a></li><li><a href="http://www.bellemontumc.org/CampConduct.htm" title="Code of Conduct" target="_top">Code&nbsp;of&nbsp;Conduct</a></li></ul>');
vbf6rwdn=xppr('f6rwd_0.gif');vbf6rwdo=xppr('f6rwd_1.gif');vbn6rwdn=xppr('n6rwd_0.gif');vbn6rwdo=xppr('n6rwd_1.gif');vbh6rwdn=xppr('h6rwd_0.gif');vbh6rwdo=xppr('h6rwd_1.gif');vbj6rwdn=xppr('j6rwd_0.gif');vbj6rwdo=xppr('j6rwd_1.gif');vbk6rwdn=xppr('k6rwd_0.gif');vbk6rwdo=xppr('k6rwd_1.gif');vbg6rwdn=xppr('g6rwd_0.gif');vbg6rwdo=xppr('g6rwd_1.gif');vbi2rwdn=xppr('i2rwd_0.gif');vbi2rwdo=xppr('i2rwd_1.gif');vb12rwdn=xppr('12rwd_0.gif');vb12rwdo=xppr('12rwd_1.gif');vbc2rwdn=xppr('c2rwd_0.gif');vbc2rwdo=xppr('c2rwd_1.gif');var arrowChar='&raquo;';var btIdPref='vb';

function xppr(im) {
	var i=new Image();
	i.src=vbImgPath+'bt'+im;
	return i;
};

function xpe(id) {
	x=id.substring(0,id.length-1);
	if(document[btIdPref+x])document[btIdPref+x].src=eval(btIdPref+id+'.src');
};

/*
 *==============================================================================
 *
 *     Copyright (c) 2007, by Vista-buttons.com
 *     Version 0.1
 *     http://vista-buttons.com
 *
 *==============================================================================
 * Legend:
 * [!] Important
 * [+] New features 
 * [-] Fix error
 * [*] changes
 * ----------------------------------
 * In new realises next changes:
 * ------------ 0.2 ----------------
 * [+]	my set individual class-style for item
 * [+]	posibility to create separator. for it define item with blank content: "<li class = ""></li>"
 * [+]	posibility to make several icon image and arrow image for normal and mouse over state. In html code over image placed after normal image.
 * [-]  unnecessary space before main menu and submenu
 * [-]  in ie don't show char arrow
 * [+ 9:41 21.11.2007]  if user click to some item point then this equalent to click on label of item
 * [- 15:34 25.04.2008] twice open link when user click to item
 */
 
var hideTimeout = 300;
var menuContId = 'xpMenuCont';
var ulIdPref='vbUL_';
var imgIdPref='xpi_';
	
function xpinit()
{	
	//Detect browser
	isDOM=document.getElementById; //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
	isOp=isO5=window.opera && isDOM; //Opera 5+
//	isOp6=isOp && window.print; //Opera 6+
	isOp7=isOp && document.readyState; //Opera 7+
	isIE=document.all && document.all.item && !isOp; //Microsoft Internet Explorer 4+
//	isIE5=isDOM && isIE; //MSIE 5+
	isNS4=document.layers; //Netscape 4.*
	isMz=isDOM && navigator.appName=="Netscape"; //Mozilla or Netscape 6.*

	document.write('<div id="' + menuContId + '" ></div>');
	var ULs = document.getElementsByTagName('UL');
	for (var i=0, cnt=ULs.length; i<cnt; i++)
		if (ULs[i].id
		&& (ULs[i].id.substring(0, ulIdPref.length)==ulIdPref) // if is xp UL
		&& !(
			(ULs[i].parentNode)
			&& (ULs[i].parentNode.parentNode)
			&& (ULs[i].parentNode.parentNode.id.substring(0, ulIdPref.length)==ulIdPref)
			)
		)
		{
			// hide vista-buttons link
			var A=document.getElementById(ULs[i].id+'a');
			if (A) A.style.display='none';
		
			xpCreateMenu(ULs[i], 0, 0);
		};

}
xpinit();

function xpObjectSize(o)
{
	var w = (isOp&&!isOp7) ? o.style.pixelWidth  : isNS4 ? o.clip.width  : o.offsetWidth;
	var h = (isOp&&!isOp7) ? o.style.pixelHeight : isNS4 ? o.clip.height : o.offsetHeight;
	return {x:w, y:h};
}

function xpClientSize()
{
	var x=0,y=0,w=0,h=0,doc=document,win=window;

	var cond = (!doc.compatMode || doc.compatMode == 'CSS1Compat') /*&& !win.opera */&& doc.documentElement;
	// height
	if(cond && doc.documentElement.clientHeight) h=doc.documentElement.clientHeight;
	else if(doc.body && doc.body.clientHeight) h=doc.body.clientHeight;
	else if(xpDef(win.innerWidth,win.innerHeight,doc.width)) {
		h=win.innerHeight;
		if(doc.width>win.innerWidth) h-=16;
	};
	//width
	if(cond && doc.documentElement.clientWidth) w=doc.documentElement.clientWidth;
	else if(doc.body && doc.body.clientWidth) w=doc.body.clientWidth;
	else if(xDef(win.innerWidth,win.innerHeight,doc.height)) {
		w=win.innerWidth;
		if(doc.height>win.innerHeight) w-=16;
	}

    if(win.document.documentElement && win.document.documentElement.scrollLeft) x=win.document.documentElement.scrollLeft;
    else if(win.document.body && xpDef(win.document.body.scrollLeft)) x=win.document.body.scrollLeft;

    if(win.document.documentElement && win.document.documentElement.scrollTop) y=win.document.documentElement.scrollTop;
    else if(win.document.body && xpDef(win.document.body.scrollTop)) y=win.document.body.scrollTop;
	
	return {x:x,y:y,w:w,h:h};
}
function xpDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

/*
 * calc absolute coordinates of specified object
 */	
function xppos(obj)
{
	var l=0, t=0;
	while (obj) //  && obj.tagName!='BODY'
	{
		l += obj.offsetLeft;
		t += obj.offsetTop;
		
		// some browser not right set offsetParent
//		if (obj.style && obj.style.position=='absolute') break;// this is a fix but not constant
		
		obj = obj.offsetParent;
	};	

	// fix special for opera
	if (document.body) with (document){
		if (body.leftMargin) l -= body.leftMargin;
		if (body.topMargin) t -= body.topMargin
	}

	return {x: l, y: t};
}


/**
 * create menu
 * structure:	<div - menu >
 *			<table>
 *				<tr - item>
 *					<td - for icon><img></td>
 *					<td - for label><a></a></td>
 *					<td - for arrow><img></td>
 *				</tr>
 *			</table>
 *		</div>
 * @ulParent - main parent of menu UL
 * @iParent - parent item
 * @level - level
 */
function xpCreateMenu(ulParent, iParent, level)
{
	// create menu obj
	var menuCont = document.getElementById(menuContId);
	
	var oMenu = document.createElement('div');
	menuCont.appendChild(oMenu);
	var oTable = document.createElement('table');
	oMenu.appendChild(oTable);

	oMenu.id = ulParent.id + 'tbl';
	oMenu.className = ulParent.className; // inherite style from menu definition with ul
	//oTable.style.visibility = 'hidden';
	oMenu.style.position = 'absolute'; // set here without fail
	oMenu.iParent = iParent;
	
	oMenu.level = level;
	oMenu.style.zIndex = 9 + oMenu.level;
	oTable.cellSpacing = 0;

	// set menu events and metods
	oMenu.onmouseover = function (){xpsmover(this)};
	oMenu.onmouseout = function (){xpsmout(this)};
	oMenu.ClearMenuMark = function(){
		for (var j = 0; j < this.childNodes[0].rows.length; j++){
			p = this.childNodes[0].rows[j];
			if (p.tagName == 'TR') {
				p.className = p.className.replace('over','');
				if (p.className.indexOf('popup')<0)	p.clrOverImg();
			}
		};
	};
	
	oMenu.smShown = 0;
	
	for (var i=0, cntLI=ulParent.childNodes.length; i<cntLI; i++){ // organizing circle for LI
		var oLI = ulParent.childNodes[i];
		if (oLI.tagName == 'LI'){
			var oItem = oTable.insertRow(-1);
			oItem.menu = oMenu;
			oItem.setPopup = function(){this.className +=  ' popup';};
			oItem.clrPopup = function(){
				this.className = this.className.replace('popup','');
				if (this.className.indexOf('over')<0) this.clrOverImg();
				};
			oItem.clrOverImg = function(){
				if (this.Img) this.Img.style.display = 'inline';
				if (this.ImgOver) this.ImgOver.style.display = 'none';
				if (this.ImgArrow) this.ImgArrow.style.display = 'inline';
				if (this.ImgArrowOver) this.ImgArrowOver.style.display = 'none'};
			
			oItem.className = oLI.className;

			var InnerAnchor = 0;
			oItem.Img = null;
			oItem.ImgOver = null;
			var InnerUl = 0;
			oItem.ImgArrow = null;
			oItem.ImgArrowOver = null;

			// parse LI content
			for (var j=0; j < oLI.childNodes.length; j++)
				if (oLI.childNodes[j].tagName == 'A') InnerAnchor = oLI.childNodes[j];
				else if (oLI.childNodes[j].tagName == 'IMG'){
					if (!InnerAnchor){
						if (!oItem.Img) oItem.Img = oLI.childNodes[j];
						else oItem.ImgOver = oLI.childNodes[j]}
					else {
						if(!oItem.ImgArrow) oItem.ImgArrow = oLI.childNodes[j];
						else oItem.ImgArrowOver = oLI.childNodes[j]	}
				}
				else if (oLI.childNodes[j].tagName == 'UL') InnerUl = oLI.childNodes[j];

			if (InnerAnchor || InnerUl || oItem.ImgArrow){ // it is not a separator
				var oTDIMG = oItem.insertCell(-1);
				var oTDLabel = oItem.insertCell(-1);
				var oTDArrow = oItem.insertCell(-1);

				oTDIMG.style.borderRightWidth = '0px';
				oTDLabel.style.borderRightWidth = '0px';
				oTDLabel.style.borderLeftWidth = '0px';
				oTDArrow.style.borderLeftWidth = '0px';
				oTDIMG.style.paddingRight = '4px';
				oTDLabel.style.paddingRight = '4px';
				oTDLabel.style.paddingLeft = '4px';
				oTDArrow.style.paddingLeft = '4px';

				if (oItem.Img) oTDIMG.appendChild(oItem.Img);
				else oTDIMG.innerHTML = '&nbsp;';
				if (oItem.ImgOver) {
					oItem.ImgOver.style.display = 'none';
					oTDIMG.appendChild(oItem.ImgOver);
					}

				// create anchor with link execution
				if (InnerAnchor){
					oTDLabel.appendChild(InnerAnchor);
					oItem.ItemLink = InnerAnchor;
					// off standart click 
					InnerAnchor.onclick = function(){
						return false;
					};
					//define my click handle event
					oItem.onclick = function(){
						if (this.ItemLink.href)
						open(this.ItemLink.href, (this.ItemLink.target? this.ItemLink.target :"_self"));
						return true;
						}
					}
				else oTDLabel.innerHTML = '&nbsp;';

				// set item events
				oItem.onmouseover = function (){
					// clear other mark
					this.menu.ClearMenuMark();
					this.className += ' over';// mark this item
					if (this.ImgOver){
						this.Img.style.display = 'none';
						this.ImgOver.style.display = 'inline'}
					if (this.ImgArrowOver){
						this.ImgArrow.style.display = 'none';
						this.ImgArrowOver.style.display = 'inline'}

					if (this.smPopupId) xpshowmenu(this.smPopupId, 1, this); // show new menu
					else if (this.menu.smShown) xpStartTimeOut(this.menu.smShown); // hide bug
				};
				oItem.onmouseout = function (){
					this.menu.ClearMenuMark();
				};

				// define submenu
				if (InnerUl){
					// set event for over
					oTDArrow.className = 'arrow';
					if (oItem.ImgArrow){ oTDArrow.appendChild(oItem.ImgArrow);
						if (oItem.ImgArrowOver){
							oItem.ImgArrowOver.style.display = 'none';
							oTDArrow.appendChild(oItem.ImgArrowOver)
						}}
					else {
						if (typeof(arrowChar)!='undefined' && arrowChar){
							oTDArrow.appendChild(document.createElement('a'));
							oTDArrow.lastChild.innerHTML = arrowChar;
						}
						else oTDArrow.innerHTML = '&nbsp;';
					}

						oItem.smPopupId = xpCreateMenu(InnerUl, oItem, level + 1);
				}
				else oTDArrow.innerHTML = '&nbsp;';
			}
			else{ // add a separator
				var oTD = oItem.insertCell(-1);
				oTD.colSpan = 3;
				oTD.innerHTML = '<div></div>';//+ (isIE ? ' style="margin-bottom:-2px;"' : '')
			}

		}
	}
//	oMenu.OrigWidth = oMenu.offsetWidth;
	//alert(oTable.OrigWidth);

	return oMenu.id;
}

/* show menu item
 * ind - part of object identifier
 * isVertical - previous menu is vertical
 * iParent - object created events identifier - this is about a anchor or previous menu item
 */
function xpshow(ind, isVertical, iParent){
	xpshowmenu(ulIdPref+ind+'tbl', isVertical, iParent);
}

function xpshowmenu(menuID, isVertical, iParent)
{
	var menu = document.getElementById(menuID);
	if (!menu) return;
	
	// already showing?
	if (menu.style.visibility == 'visible'){
		xpStopTimeOut(menu);
		return;
	}
	
	// hide previous menu in this level
	if (iParent && iParent.menu && iParent.menu.smShown)
		xphide(iParent.menu.smShown.id);
	if (!menu.level && (ShownMenu != menu))
		xphide(ShownMenu.id);

	// it saves button main menu
	if (!menu.level) xobtn = menuID.replace(ulIdPref,'').replace('tbl','');

	var parentObj; // Parent - parent menu item
	if (iParent.tagName == 'A'){
		// find img
		//parentObj = document.getElementById(imgIdPref+menuID.replace(ulIdPref,'').replace('tbl','')); // this is the image of button
		parentObj = iParent.parentNode;
	}
	else parentObj = iParent;

	var pos = xppos(parentObj); // parent coordinate
	var size = xpObjectSize(parentObj);
/*	if (iParent.tagName == 'TR'){ // correct coordinate parent item for menu
		pos.x = xppos(parentObj.menu).x;
		size.x = xpObjectSize(parentObj.menu).x;
	}*/

	menu.goMenuX = 1; // menu open direction
	menu.goMenuDx = 1; // menu open  offset
	if (menu.level > 0){
		// inherit direction from previous level
		menu.goMenuX = menu.iParent.menu.goMenuX;
		menu.goMenuDx = menu.iParent.menu.goMenuDx;
	};
	
	// initialize property
	menu.style.overflow = 'visible';
	menu.style.height = 'auto';
	menu.style.width = 'auto';

	// fix bug position for some document structure
	menu.style.left = '0px';
	menu.style.top = '0px';
	var parentAbs = xppos(menu);

	// detect window size
	var WinSize = xpClientSize();
	var menuSize = xpObjectSize(menu);

	// calc and init Y coordinate
	var CalcedPos = xp_CalcMenuPos(WinSize.y, WinSize.h, pos.y, size.y, menuSize.y, menu.goMenuDx, isVertical);

	menu.goMenuDx = CalcedPos.align;

	// fix scrollbar bug for opera
	if (isOp && !menu.OrigWidth) menu.OrigWidth = menu.clientWidth;//menu.clientWidth;


	// size was changed - resize height, open scroll, correct width for scrollbar
	if (CalcedPos.size < menuSize.y){
		//xpsm.style.overflowY = 'auto';
		menu.style.overflow = 'auto';
		//menu.style.overflow = 'visible';
		if (isIE) menu.style.overflowX = 'visible';
		if (isIE) menu.style.width = menu.offsetWidth + 17 + 'px';
		else if (isMz) menu.style.magrinRight = 20;

		menu.style.height = CalcedPos.size + 'px';
		menu.scrollTop  = 0;
		menu.scrollLeft = 0;

		// fix scrollbar bug for opera
		if (isOp) menu.style.width = menu.OrigWidth + 'px';
	}
	else {
		
	}

	menu.style.top = CalcedPos.xy - parentAbs.y + 'px';

	// calc and init X coorinate
	menuSize = xpObjectSize(menu);
	CalcedPos = xp_CalcMenuPos(WinSize.x, WinSize.w, pos.x, size.x, menuSize.x, menu.goMenuX, !isVertical);
	menu.goMenuX = CalcedPos.align;
	if (CalcedPos.size < menuSize.x)// size was changed
		if (menu.goMenuX > 0)
			CalcedPos.xy -= (menuSize.x - CalcedPos.size); // covered
	menu.style.left = CalcedPos.xy - parentAbs.x + 'px';

	menu.style.visibility = 'visible';

	if (!menu.level) ShownMenu = menu;
	else {
		iParent.menu.smShown = menu;
		iParent.setPopup();
	}
}


function xp_CalcMenuPos(screenXY, screenSize, parentXY, parentSize, size, align, oHoriz)
// calc menu pos for one coordinate 
// use size of menu, parent object and screen, menu direction and parent menu orientation
// screenSize - size of screen
// parentXY, parentSize - position and size of parent menu
// size - size of selected menu
// align = +1(right, bottom), 0(center), -1(left, top)  - direction of menu
// oHoriz  = 0(vertical), 1(horizontal) - orientation of parent menu
{
	var xy = parentXY;
	var newSize = size;
	var newAlign = align;
	var space = 5; // space to document borders
	
	if ((align == 0) && (!oHoriz)) align = 1; //center may be only for horizontal orientation
	
	if (!oHoriz) {// VERTICAL
		// |------<--------->)<---parent--->(<---------->---------|
		// check the place for the future menu and correct orientation
		if	(((newAlign >= 0) && (parentXY + parentSize + size > screenSize + screenXY - space)) // don't go in screen from the algin
							|| ((newAlign < 0) && (parentXY - size < space))){
			// correct direction about most of place
			if (parentXY - screenXY > screenSize + screenXY - (parentXY + parentSize)) newAlign = -1; else newAlign = 1;
		};
		// set coordinate and size
		if (newAlign >= 0){
			xy = parentXY + parentSize;
			if (screenSize + screenXY - space - xy < newSize) newSize = screenSize + screenXY  - space - xy;
		}
		else {
			xy = parentXY - newSize;
			if (xy - screenXY < space){
				xy = space + screenXY;
				newSize = parentXY - space - screenXY;
			}
		}
		
	}
	else {
		// --------------- <---parent---> -------------------
		//                      (<------------------------>--------|
		//   |-----<--------------------->)
		// if menu not go in screen
		if (newSize > screenSize - 2*space) {
			xy = space + screenXY;
			newSize = screenSize - 2*space;
		}
		else{
			// calc
			xy = parentXY + parentSize/2 - newSize/2 + newAlign * (newSize/2 - parentSize/2);

			// correct
			if (xy < space + screenXY){
				newAlign = 1;
				xy = space + screenXY;
			}
			if (xy + size > screenSize  + screenXY - space){
				newAlign = -1;
				xy -= xy + newSize - (screenSize  + screenXY - space);
			}
		}
	};

	return {xy: xy, size: newSize, align: newAlign};
}


/*
 * hide submenu
 * @menu
 */
function xphide(menuId)
{
	var menu = document.getElementById(menuId);
	if (!menu) return;
	if ( menu.style.visibility == 'visible' ){
		// hide child
		if (menu.smShown)
			xphide(menu.smShown.id);
		
		// off cursor selection
		menu.ClearMenuMark();

		// hide the menu
		menu.style.visibility = 'hidden';

		// if all submenu close, then change button icon
		if (menu.level == 0){
			xpe(xobtn + 'n');//???????????
		}

		menu.smShown = 0;
		if (menu.iParent) menu.iParent.clrPopup();

		// clear to hide timeout
		if (menu.hideTimer){
			clearTimeout(menu.hideTimer);
			menu.hideTimer = null;
		}
		
	}
  }

// on mouse out from menu
function xpsmout(sender)
{
	if (!sender) return;
	// set time out
	xpStartTimeOut(ShownMenu)
}

// on mouse over menu
function xpsmover(menu)
{
	if (!menu) return;
	xpStopTimeOut(menu);
}


// clear Time out for all parent and this menu
function xpStopTimeOut(menu)
{
	for( var o = menu; o; o = o.iParent? o.iParent.menu: 0)
		if (o.hideTimer)
			o.hideTimer = clearTimeout(o.hideTimer);
}

function xpStartTimeOut(menu)
{
	for(var o = menu; o ; o = o.smShown){
			var code = 'xphide("' + o.id + '");';
			if (!o.hideTimer && o.id) o.hideTimer = setTimeout(code , hideTimeout);
		}
}



// init global vars
var ShownMenu = 0; // curent open menu tread
var xobtn = null; // curent element text identifier curent
/*
 bugs:
* for style when select item font size is big, the menu safe previous open width - only in opera, not constant bug
* for opera scrollbar if overflow not open
* for NS6 not find document.getElementById(menuContId)
* for safari not right calc window size;
* function xppos not right work for absolute positioning element
* Popup menu not hide, when after popup the pointer go to previous item (offen in Opera)
* delete from html second-level menu id
*/
