/**
 * mm_menu 20MAR2002 Version 6.0
 * Andy Finnell, March 2002
 * Copyright (c) 2000-2002 Macromedia, Inc.
 *
 * based on menu.js
 * by gary smith, July 1997
 * Copyright (c) 1997-1999 Netscape Communications Corp.
 *
 * Netscape grants you a royalty free license to use or modify this
 * software provided that this copyright notice appears on all copies.
 * This software is provided "AS IS," without a warranty of any kind.
 */
 
function getGUID() { return (new Date()).valueOf(); }

function mmLoadMenus() {
	if (window.mm_menu_0517130627_0) return;
	window.mm_menu_0517130627_0 = new Menu("root",127,26,"Verdana, Arial, Helvetica, sans-serif",10,"#ffffff","#ffffff","#669900","#99cc00","left","middle",8,0,1000,0,0,true,false,true,5,true,true);
	mm_menu_0517130627_0.addMenuItem("USER&nbsp;ACCOUNTS", "window.location.href = 'rest_user_list.aspx';");
	mm_menu_0517130627_0.addMenuItem("ACCOUNTING", "window.location.href = 'rest_accounting.aspx';");
	mm_menu_0517130627_0.addMenuItem("BILLING&nbsp;HISTORY", "window.location.href = 'rest_history.aspx';");
	mm_menu_0517130627_0.fontWeight="bold";
	mm_menu_0517130627_0.hideOnMouseOut=true;
	mm_menu_0517130627_0.menuBorder=0;
	mm_menu_0517130627_0.menuLiteBgColor='#000000';
	mm_menu_0517130627_0.menuBorderBgColor='#cccccc';
	mm_menu_0517130627_0.bgColor='#cccccc';
	window.mm_menu_0517130754_1 = new Menu("root",119,26,"Verdana, Arial, Helvetica, sans-serif",10,"#ffffff","#ffffff","#669900","#99cc00","left","middle",8,0,1000,0,0,true,false,true,5,true,true);
	mm_menu_0517130754_1.addMenuItem("ADD&nbsp;FOOD&nbsp;ITEM", "alert('Add Food Items');");
	mm_menu_0517130754_1.addMenuItem("MENU&nbsp;HELP", "alert('Menu Help');");
	mm_menu_0517130754_1.fontWeight="bold";
	mm_menu_0517130754_1.hideOnMouseOut=true;
	mm_menu_0517130754_1.menuBorder=0;
	mm_menu_0517130754_1.menuLiteBgColor='#000000';
	mm_menu_0517130754_1.menuBorderBgColor='#cccccc';
	mm_menu_0517130754_1.bgColor='#cccccc';
	window.mm_menu_0517130832_2 = new Menu("root",184,26,"Verdana, Arial, Helvetica, sans-serif",10,"#ffffff","#ffffff","#669900","#99cc00","left","middle",8,0,1000,0,0,true,false,true,5,true,true);
	mm_menu_0517130832_2.addMenuItem("RESTAURANT&nbsp;DESCRIPTION", "window.location.href = 'rest_descr.aspx';");
	mm_menu_0517130832_2.addMenuItem("RESTAURANT&nbsp;EVENTS", "window.location.href = 'rest_event_list.aspx';");
	mm_menu_0517130832_2.addMenuItem("PHOTO&nbsp;GALLERY", "window.location.href = 'rest_gallery_list.aspx';");
	mm_menu_0517130832_2.addMenuItem("DELIVERY/PICKUP&nbsp;TIMES", "window.location.href = 'rest_dp.aspx';");
	mm_menu_0517130832_2.fontWeight="bold";
	mm_menu_0517130832_2.hideOnMouseOut=true;
	mm_menu_0517130832_2.menuBorder=0;
	mm_menu_0517130832_2.menuLiteBgColor='#000000';
	mm_menu_0517130832_2.menuBorderBgColor='#cccccc';
	mm_menu_0517130832_2.bgColor='#cccccc';
	window.mm_menu_0517130926_3 = new Menu("root",180,26,"Verdana, Arial, Helvetica, sans-serif",10,"#ffffff","#ffffff","#669900","#99cc00","left","middle",8,0,1000,0,0,true,false,true,5,true,true);
	mm_menu_0517130926_3.addMenuItem("KNOWLEDGE&nbsp;BASE", "alert('Knowledge Base');");
	mm_menu_0517130926_3.addMenuItem("CONTACT&nbsp;INFORMATION", "alert('Contact Information');");
	mm_menu_0517130926_3.addMenuItem("SUBMIT&nbsp;A&nbsp;SUPPORT&nbsp;TICKET", "alert('Submit A Support Ticket');");
	mm_menu_0517130926_3.addMenuItem("VIEW&nbsp;SUPPORT&nbsp;TICKETS", "alert('View Support Ticket');");
	mm_menu_0517130926_3.fontWeight="bold";
	mm_menu_0517130926_3.hideOnMouseOut=true;
	mm_menu_0517130926_3.menuBorder=0;
	mm_menu_0517130926_3.menuLiteBgColor='#000000';
	mm_menu_0517130926_3.menuBorderBgColor='#cccccc';
	mm_menu_0517130926_3.bgColor='#cccccc';

	mm_menu_0517130926_3.writeMenus();
} // mmLoadMenus()
 
 
 
 
function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh, halgn, valgn, pad, space, to, sx, sy, srel, opq, vert, idt, aw, ah) 
{
	this.version = "020320 [Menu; mm_menu.js]";
	this.type = "Menu";
	this.menuWidth = mw;
	this.menuItemHeight = mh;
	this.fontSize = fs;
	this.fontWeight = "plain";
	this.fontFamily = fnt;
	this.fontColor = fclr;
	this.fontColorHilite = fhclr;
	this.bgColor = "#555555";
	this.menuBorder = 1;
	this.menuBgOpaque=opq;
	this.menuItemBorder = 1;
	this.menuItemIndent = idt;
	this.menuItemBgColor = bg;
	this.menuItemVAlign = valgn;
	this.menuItemHAlign = halgn;
	this.menuItemPadding = pad;
	this.menuItemSpacing = space;
	this.menuLiteBgColor = "#ffffff";
	this.menuBorderBgColor = "#777777";
	this.menuHiliteBgColor = bgh;
	this.menuContainerBgColor = "#cccccc";
	this.childMenuIcon = "arrows.gif";
	this.submenuXOffset = sx;
	this.submenuYOffset = sy;
	this.submenuRelativeToItem = srel;
	this.vertical = vert;
	this.items = new Array();
	this.actions = new Array();
	this.childMenus = new Array();
	this.hideOnMouseOut = true;
	this.hideTimeout = to;
	this.addMenuItem = addMenuItem;
	this.writeMenus = writeMenus;
	this.MM_showMenu = MM_showMenu;
	this.onMenuItemOver = onMenuItemOver;
	this.onMenuItemAction = onMenuItemAction;
	this.hideMenu = hideMenu;
	this.hideChildMenu = hideChildMenu;
	if (!window.menus) window.menus = new Array();
	this.label = " " + label;
	window.menus[this.label] = this;
	window.menus[window.menus.length] = this;
	if (!window.activeMenus) window.activeMenus = new Array();
}

function addMenuItem(label, action) {
	this.items[this.items.length] = label;
	this.actions[this.actions.length] = action;
}

function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function writeMenus(container) {
	if (window.triedToWriteMenus) return;
	var agt = navigator.userAgent.toLowerCase();
	window.mmIsOpera = agt.indexOf("opera") != -1;
	if (!container && document.layers) {
		window.delayWriteMenus = this.writeMenus;
		var timer = setTimeout('delayWriteMenus()', 500);
		container = new Layer(100);
		clearTimeout(timer);
	} else if (document.all || document.hasChildNodes || window.mmIsOpera) {
		document.writeln('<span id="menuContainer"></span>');
		container = FIND("menuContainer");
	}

	window.mmHideMenuTimer = null;
	if (!container) return;	
	window.triedToWriteMenus = true; 
	container.isContainer = true;
	container.menus = new Array();
	for (var i=0; i<window.menus.length; i++) 
		container.menus[i] = window.menus[i];
	window.menus.length = 0;
	var countMenus = 0;
	var countItems = 0;
	var top = 0;
	var content = '';
	var lrs = false;
	var theStat = "";
	var tsc = 0;
	if (document.layers) lrs = true;
	for (var i=0; i<container.menus.length; i++, countMenus++) {
		var menu = container.menus[i];
		if (menu.bgImageUp || !menu.menuBgOpaque) {
			menu.menuBorder = 0;
			menu.menuItemBorder = 0;
		}
		if (lrs) {
			var menuLayer = new Layer(100, container);
			var lite = new Layer(100, menuLayer);
			lite.top = menu.menuBorder;
			lite.left = menu.menuBorder;
			var body = new Layer(100, lite);
			body.top = menu.menuBorder;
			body.left = menu.menuBorder;
		} else {
			content += ''+
			'<div id="menuLayer'+ countMenus +'" style="position:absolute;z-index:1;left:10px;top:'+ (i * 100) +'px;visibility:hidden;color:' +  menu.menuBorderBgColor + ';">\n'+
			'  <div id="menuLite'+ countMenus +'" style="position:absolute;z-index:1;left:'+ menu.menuBorder +'px;top:'+ menu.menuBorder +'px;visibility:hide;" onmouseout="mouseoutMenu();">\n'+
			'	 <div id="menuFg'+ countMenus +'" style="position:absolute;left:'+ menu.menuBorder +'px;top:'+ menu.menuBorder +'px;visibility:hide;">\n'+
			'';
		}
		var x=i;
		for (var i=0; i<menu.items.length; i++) {
			var item = menu.items[i];
			var childMenu = false;
			var defaultHeight = menu.fontSize+2*menu.menuItemPadding;
			if (item.label) {
				item = item.label;
				childMenu = true;
			}
			menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
			var itemProps = '';
			if( menu.fontFamily != '' ) itemProps += 'font-family:' + menu.fontFamily +';';
			itemProps += 'font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + 'px;';
			if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
			if (document.all || window.mmIsOpera) 
				itemProps += 'font-size:' + menu.fontSize + 'px;" onmouseover="onMenuItemOver(null,this);" onclick="onMenuItemAction(null,this);';
			else if (!document.layers) {
				itemProps += 'font-size:' + menu.fontSize + 'px;';
			}
			var l;
			if (lrs) {
				var lw = menu.menuWidth;
				if( menu.menuItemHAlign == 'right' ) lw -= menu.menuItemPadding;
				l = new Layer(lw,body);
			}
			var itemLeft = 0;
			var itemTop = i*menu.menuItemHeight;
			if( !menu.vertical ) {
				itemLeft = i*menu.menuWidth;
				itemTop = 0;
			}
			var dTag = '<div id="menuItem'+ countItems +'" style="position:absolute;left:' + itemLeft + 'px;top:'+ itemTop +'px;'+ itemProps +'">';
			var dClose = '</div>'
			if (menu.bgImageUp) dTag = '<div id="menuItem'+ countItems +'" style="background:url('+menu.bgImageUp+');position:absolute;left:' + itemLeft + 'px;top:'+ itemTop +'px;'+ itemProps +'">';

			var left = 0, top = 0, right = 0, bottom = 0;
			left = 1 + menu.menuItemPadding + menu.menuItemIndent;
			right = left + menu.menuWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
			if( menu.menuItemVAlign == 'top' ) top = menu.menuItemPadding;
			if( menu.menuItemVAlign == 'bottom' ) top = menu.menuItemHeight-menu.fontSize-1-menu.menuItemPadding;
			if( menu.menuItemVAlign == 'middle' ) top = ((menu.menuItemHeight/2)-(menu.fontSize/2)-1);
			bottom = menu.menuItemHeight - 2*menu.menuItemPadding;
			var textProps = 'position:absolute;left:' + left + 'px;top:' + top + 'px;';
			if (lrs) {
				textProps +=itemProps + 'right:' + right + ';bottom:' + bottom + ';';
				dTag = "";
				dClose = "";
			}
			
			if(document.all && !window.mmIsOpera) {
				item = '<div align="' + menu.menuItemHAlign + '">' + item + '</div>';
			} else if (lrs) {
				item = '<div style="text-align:' + menu.menuItemHAlign + ';">' + item + '</div>';
			} else {
				var hitem = null;
				if( menu.menuItemHAlign != 'left' ) {
					if(window.mmIsOpera) {
						var operaWidth = menu.menuItemHAlign == 'center' ? -(menu.menuWidth-2*menu.menuItemPadding) : (menu.menuWidth-6*menu.menuItemPadding);
						hitem = '<div id="menuItemHilite' + countItems + 'Shim" style="position:absolute;top:1px;left:' + menu.menuItemPadding + 'px;width:' + operaWidth + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
						item = '<div id="menuItemText' + countItems + 'Shim" style="position:absolute;top:1px;left:' + menu.menuItemPadding + 'px;width:' + operaWidth + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
					} else {
						hitem = '<div id="menuItemHilite' + countItems + 'Shim" style="position:absolute;top:1px;left:1px;right:-' + (left+menu.menuWidth-3*menu.menuItemPadding) + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
						item = '<div id="menuItemText' + countItems + 'Shim" style="position:absolute;top:1px;left:1px;right:-' + (left+menu.menuWidth-3*menu.menuItemPadding) + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
					}
				} else hitem = null;
			}
			if(document.all && !window.mmIsOpera) item = '<div id="menuItemShim' + countItems + '" style="position:absolute;left:0px;top:0px;">' + item + '</div>';
			var dText	= '<div id="menuItemText'+ countItems +'" style="' + textProps + 'color:'+ menu.fontColor +';">'+ item +'&nbsp</div>\n'
						+ '<div id="menuItemHilite'+ countItems +'" style="' + textProps + 'color:'+ menu.fontColorHilite +';visibility:hidden;">' 
						+ (hitem||item) +'&nbsp</div>';
			if (childMenu) content += ( dTag + dText + '<div id="childMenu'+ countItems +'" style="position:absolute;left:0px;top:3px;"><img src="'+ menu.childMenuIcon +'"></div>\n' + dClose);
			else content += ( dTag + dText + dClose);
			if (lrs) {
				l.document.open("text/html");
				l.document.writeln(content);
				l.document.close();	
				content = '';
				theStat += "-";
				tsc++;
				if (tsc > 50) {
					tsc = 0;
					theStat = "";
				}
				status = theStat;
			}
			countItems++;  
		}
		if (lrs) {
			var focusItem = new Layer(100, body);
			focusItem.visiblity="hidden";
			focusItem.document.open("text/html");
			focusItem.document.writeln("&nbsp;");
			focusItem.document.close();	
		} else {
		  content += '	  <div id="focusItem'+ countMenus +'" style="position:absolute;left:0px;top:0px;visibility:hide;" onclick="onMenuItemAction(null,this);">&nbsp;</div>\n';
		  content += '   </div>\n  </div>\n</div>\n';
		}
		i=x;
	}
	if (document.layers) {		
		container.clip.width = window.innerWidth;
		container.clip.height = window.innerHeight;
		container.onmouseout = mouseoutMenu;
		container.menuContainerBgColor = this.menuContainerBgColor;
		for (var i=0; i<container.document.layers.length; i++) {
			proto = container.menus[i];
			var menu = container.document.layers[i];
			container.menus[i].menuLayer = menu;
			container.menus[i].menuLayer.Menu = container.menus[i];
			container.menus[i].menuLayer.Menu.container = container;
			var body = menu.document.layers[0].document.layers[0];
			body.clip.width = proto.menuWidth || body.clip.width;
			body.clip.height = proto.menuHeight || body.clip.height;
			for (var n=0; n<body.document.layers.length-1; n++) {
				var l = body.document.layers[n];
				l.Menu = container.menus[i];
				l.menuHiliteBgColor = proto.menuHiliteBgColor;
				l.document.bgColor = proto.menuItemBgColor;
				l.saveColor = proto.menuItemBgColor;
				l.onmouseover = proto.onMenuItemOver;
				l.onclick = proto.onMenuItemAction;
				l.mmaction = container.menus[i].actions[n];
				l.focusItem = body.document.layers[body.document.layers.length-1];
				l.clip.width = proto.menuWidth || body.clip.width;
				l.clip.height = proto.menuItemHeight || l.clip.height;
				if (n>0) {
					if( l.Menu.vertical ) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder + proto.menuItemSpacing;
					else l.left = body.document.layers[n-1].left + body.document.layers[n-1].clip.width + proto.menuItemBorder + proto.menuItemSpacing;
				}
				l.hilite = l.document.layers[1];
				if (proto.bgImageUp) l.background.src = proto.bgImageUp;
				l.document.layers[1].isHilite = true;
				if (l.document.layers.length > 2) {
					l.childMenu = container.menus[i].items[n].menuLayer;
					l.document.layers[2].left = l.clip.width -13;
					l.document.layers[2].top = (l.clip.height / 2) -4;
					l.document.layers[2].clip.left += 3;
					l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
				}
			}
			if( proto.menuBgOpaque ) body.document.bgColor = proto.bgColor;
			if( proto.vertical ) {
				body.clip.width  = l.clip.width +proto.menuBorder;
				body.clip.height = l.top + l.clip.height +proto.menuBorder;
			} else {
				body.clip.height  = l.clip.height +proto.menuBorder;
				body.clip.width = l.left + l.clip.width  +proto.menuBorder;
				if( body.clip.width > window.innerWidth ) body.clip.width = window.innerWidth;
			}
			var focusItem = body.document.layers[n];
			focusItem.clip.width = body.clip.width;
			focusItem.Menu = l.Menu;
			focusItem.top = -30;
            focusItem.captureEvents(Event.MOUSEDOWN);
            focusItem.onmousedown = onMenuItemDown;
			if( proto.menuBgOpaque ) menu.document.bgColor = proto.menuBorderBgColor;
			var lite = menu.document.layers[0];
			if( proto.menuBgOpaque ) lite.document.bgColor = proto.menuLiteBgColor;
			lite.clip.width = body.clip.width +1;
			lite.clip.height = body.clip.height +1;
			menu.clip.width = body.clip.width + (proto.menuBorder * 3) ;
			menu.clip.height = body.clip.height + (proto.menuBorder * 3);
		}
	} else {
		if ((!document.all) && (container.hasChildNodes) && !window.mmIsOpera) {
			container.innerHTML=content;
		} else {
			container.document.open("text/html");
			container.document.writeln(content);
			container.document.close();	
		}
		if (!FIND("menuLayer0")) return;
		var menuCount = 0;
		for (var x=0; x<container.menus.length; x++) {
			var menuLayer = FIND("menuLayer" + x);
			container.menus[x].menuLayer = "menuLayer" + x;
			menuLayer.Menu = container.menus[x];
			menuLayer.Menu.container = "menuLayer" + x;
			menuLayer.style.zindex = 1;
		    var s = menuLayer.style;
			s.pixeltop = -300;
			s.pixelleft = -300;
			s.top = '-300px';
			s.left = '-300px';

			var menu = container.menus[x];
			menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
			if( menu.menuBgOpaque ) menuLayer.style.backgroundColor = menu.menuBorderBgColor;
			var top = 0;
			var left = 0;
			menu.menuItemLayers = new Array();
			for (var i=0; i<container.menus[x].items.length; i++) {
				var l = FIND("menuItem" + menuCount);
				l.Menu = container.menus[x];
				l.Menu.menuItemLayers[l.Menu.menuItemLayers.length] = l;
				if (l.addEventListener || window.mmIsOpera) {
					l.style.width = menu.menuItemWidth + 'px';
					l.style.height = menu.menuItemHeight + 'px';
					l.style.pixelWidth = menu.menuItemWidth;
					l.style.pixelHeight = menu.menuItemHeight;
					l.style.top = top + 'px';
					l.style.left = left + 'px';
					if(l.addEventListener) {
						l.addEventListener("mouseover", onMenuItemOver, false);
						l.addEventListener("click", onMenuItemAction, false);
						l.addEventListener("mouseout", mouseoutMenu, false);
					}
					if( menu.menuItemHAlign != 'left' ) {
						l.hiliteShim = FIND("menuItemHilite" + menuCount + "Shim");
						l.hiliteShim.style.visibility = "inherit";
						l.textShim = FIND("menuItemText" + menuCount + "Shim");
						l.hiliteShim.style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						l.hiliteShim.style.width = l.hiliteShim.style.pixelWidth;
						l.textShim.style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						l.textShim.style.width = l.textShim.style.pixelWidth;	
					}
				} else {
					l.style.pixelWidth = menu.menuItemWidth;
					l.style.pixelHeight = menu.menuItemHeight;
					l.style.pixelTop = top;
					l.style.pixelLeft = left;
					if( menu.menuItemHAlign != 'left' ) {
						var shim = FIND("menuItemShim" + menuCount);
						shim[0].style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						shim[1].style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						shim[0].style.width = shim[0].style.pixelWidth + 'px';
						shim[1].style.width = shim[1].style.pixelWidth + 'px';
					}
				}
				if( menu.vertical ) top = top + menu.menuItemHeight+menu.menuItemBorder+menu.menuItemSpacing;
				else left = left + menu.menuItemWidth+menu.menuItemBorder+menu.menuItemSpacing;
				l.style.fontSize = menu.fontSize + 'px';
				l.style.backgroundColor = menu.menuItemBgColor;
				l.style.visibility = "inherit";
				l.saveColor = menu.menuItemBgColor;
				l.menuHiliteBgColor = menu.menuHiliteBgColor;
				l.mmaction = container.menus[x].actions[i];
				l.hilite = FIND("menuItemHilite" + menuCount);
				l.focusItem = FIND("focusItem" + x);
				l.focusItem.style.pixelTop = -30;
				l.focusItem.style.top = '-30px';
				var childItem = FIND("childMenu" + menuCount);
				if (childItem) {
					l.childMenu = container.menus[x].items[i].menuLayer;
					childItem.style.pixelLeft = menu.menuItemWidth -11;
					childItem.style.left = childItem.style.pixelLeft + 'px';
					childItem.style.pixelTop = (menu.menuItemHeight /2) -4;
					childItem.style.top = childItem.style.pixelTop + 'px';
					l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
				}
				l.style.cursor = "hand";
				menuCount++;
			}
			if( menu.vertical ) {
				menu.menuHeight = top-1-menu.menuItemSpacing;
				menu.menuWidth = menu.menuItemWidth;
			} else {
				menu.menuHeight = menu.menuItemHeight;
				menu.menuWidth = left-1-menu.menuItemSpacing;
			}

			var lite = FIND("menuLite" + x);
			var s = lite.style;
			s.pixelHeight = menu.menuHeight +(menu.menuBorder * 2);
			s.height = s.pixelHeight + 'px';
			s.pixelWidth = menu.menuWidth + (menu.menuBorder * 2);
			s.width = s.pixelWidth + 'px';
			if( menu.menuBgOpaque ) s.backgroundColor = menu.menuLiteBgColor;

			var body = FIND("menuFg" + x);
			s = body.style;
			s.pixelHeight = menu.menuHeight + menu.menuBorder;
			s.height = s.pixelHeight + 'px';
			s.pixelWidth = menu.menuWidth + menu.menuBorder;
			s.width = s.pixelWidth + 'px';
			if( menu.menuBgOpaque ) s.backgroundColor = menu.bgColor;

			s = menuLayer.style;
			s.pixelWidth  = menu.menuWidth + (menu.menuBorder * 4);
			s.width = s.pixelWidth + 'px';
			s.pixelHeight  = menu.menuHeight+(menu.menuBorder*4);
			s.height = s.pixelHeight + 'px';
		}
	}
	if (document.captureEvents) document.captureEvents(Event.MOUSEUP);
	if (document.addEventListener) document.addEventListener("mouseup", onMenuItemOver, false);
	if (document.layers && window.innerWidth) {
		window.onresize = NS4resize;
		window.NS4sIW = window.innerWidth;
		window.NS4sIH = window.innerHeight;
		setTimeout("NS4resize()",500);
	}
	document.onmouseup = mouseupMenu;
	window.mmWroteMenu = true;
	status = "";
}

function NS4resize() {
	if (NS4sIW != window.innerWidth || NS4sIH != window.innerHeight) window.location.reload();
}

function onMenuItemOver(e, l) {
	MM_clearTimeout();
	l = l || this;
	var a = window.ActiveMenuItem;
	if (document.layers) {
		if (a) {
			a.document.bgColor = a.saveColor;
			if (a.hilite) a.hilite.visibility = "hidden";
			if (a.Menu.bgImageOver) a.background.src = a.Menu.bgImageUp;
			a.focusItem.top = -100;
			a.clicked = false;
		}
		if (l.hilite) {
			l.document.bgColor = l.menuHiliteBgColor;
			l.zIndex = 1;
			l.hilite.visibility = "inherit";
			l.hilite.zIndex = 2;
			l.document.layers[1].zIndex = 1;
			l.focusItem.zIndex = this.zIndex +2;
		}
		if (l.Menu.bgImageOver) l.background.src = l.Menu.bgImageOver;
		l.focusItem.top = this.top;
		l.focusItem.left = this.left;
		l.focusItem.clip.width = l.clip.width;
		l.focusItem.clip.height = l.clip.height;
		l.Menu.hideChildMenu(l);
	} else if (l.style && l.Menu) {
		if (a) {
			a.style.backgroundColor = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.hiliteShim) a.hiliteShim.style.visibility = "inherit";
			if (a.Menu.bgImageUp) a.style.background = "url(" + a.Menu.bgImageUp +")";;
		} 
		l.style.backgroundColor = l.menuHiliteBgColor;
		l.zIndex = 1;
		if (l.Menu.bgImageOver) l.style.background = "url(" + l.Menu.bgImageOver +")";
		if (l.hilite) {
			l.hilite.style.visibility = "inherit";
			if( l.hiliteShim ) l.hiliteShim.style.visibility = "visible";
		}
		l.focusItem.style.pixelTop = l.style.pixelTop;
		l.focusItem.style.top = l.focusItem.style.pixelTop + 'px';
		l.focusItem.style.pixelLeft = l.style.pixelLeft;
		l.focusItem.style.left = l.focusItem.style.pixelLeft + 'px';
		l.focusItem.style.zIndex = l.zIndex +1;
		l.Menu.hideChildMenu(l);
	} else return;
	window.ActiveMenuItem = l;
}

function onMenuItemAction(e, l) {
	l = window.ActiveMenuItem;
	if (!l) return;
	hideActiveMenus();
	if (l.mmaction) eval("" + l.mmaction);
	window.ActiveMenuItem = 0;
}

function MM_clearTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
	mmDHFlag = false;
}

function MM_startTimeout() {
	if( window.ActiveMenu ) {
		mmStart = new Date();
		mmDHFlag = true;
		mmHideMenuTimer = setTimeout("mmDoHide()", window.ActiveMenu.Menu.hideTimeout);
	}
}

function mmDoHide() {
	if (!mmDHFlag || !window.ActiveMenu) return;
	var elapsed = new Date() - mmStart;
	var timeout = window.ActiveMenu.Menu.hideTimeout;
	if (elapsed < timeout) {
		mmHideMenuTimer = setTimeout("mmDoHide()", timeout+100-elapsed);
		return;
	}
	mmDHFlag = false;
	hideActiveMenus();
	window.ActiveMenuItem = 0;
}

function MM_showMenu(menu, x, y, child, imgname) {
	if (!window.mmWroteMenu) return;
	MM_clearTimeout();
	if (menu) {
		var obj = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];
		x = moveXbySlicePos (x, obj);
		y = moveYbySlicePos (y, obj);
	}
	if (document.layers) {
		if (menu) {
			var l = menu.menuLayer || menu;
			l.top = l.left = 1;
			hideActiveMenus();
			if (this.visibility) l = this;
			window.ActiveMenu = l;
		} else {
			var l = child;
		}
		if (!l) return;
		for (var i=0; i<l.layers.length; i++) { 			   
			if (!l.layers[i].isHilite) l.layers[i].visibility = "inherit";
			if (l.layers[i].document.layers.length > 0) MM_showMenu(null, "relative", "relative", l.layers[i]);
		}
		if (l.parentLayer) {
			if (x != "relative") l.parentLayer.left = x || window.pageX || 0;
			if (l.parentLayer.left + l.clip.width > window.innerWidth) l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
			if (y != "relative") l.parentLayer.top = y || window.pageY || 0;
			if (l.parentLayer.isContainer) {
				l.Menu.xOffset = window.pageXOffset;
				l.Menu.yOffset = window.pageYOffset;
				l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
				l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
				if (l.parentLayer.menuContainerBgColor && l.Menu.menuBgOpaque ) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
			}
		}
		l.visibility = "inherit";
		if (l.Menu) l.Menu.container.visibility = "inherit";
	} else if (FIND("menuItem0")) {
		var l = menu.menuLayer || menu;	
		hideActiveMenus();
		if (typeof(l) == "string") l = FIND(l);
		window.ActiveMenu = l;
		var s = l.style;
		s.visibility = "inherit";
		if (x != "relative") {
			s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
			s.left = s.pixelLeft + 'px';
		}
		if (y != "relative") {
			s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
			s.top = s.pixelTop + 'px';
		}
		l.Menu.xOffset = document.body.scrollLeft;
		l.Menu.yOffset = document.body.scrollTop;
	}
	if (menu) window.activeMenus[window.activeMenus.length] = l;
	MM_clearTimeout();
}

function onMenuItemDown(e, l) {
	var a = window.ActiveMenuItem;
	if (document.layers && a) {
		a.eX = e.pageX;
		a.eY = e.pageY;
		a.clicked = true;
    }
}

function mouseupMenu(e) {
	hideMenu(true, e);
	hideActiveMenus();
	return true;
}

function getExplorerVersion() {
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;
	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) {
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}

function mouseoutMenu() {
	if ((navigator.appName == "Microsoft Internet Explorer") && (getExplorerVersion() < 4.5))
		return true;
	hideMenu(false, false);
	return true;
}

function hideMenu(mouseup, e) {
	var a = window.ActiveMenuItem;
	if (a && document.layers) {
		a.document.bgColor = a.saveColor;
		a.focusItem.top = -30;
		if (a.hilite) a.hilite.visibility = "hidden";
		if (mouseup && a.mmaction && a.clicked && window.ActiveMenu) {
 			if (a.eX <= e.pageX+15 && a.eX >= e.pageX-15 && a.eY <= e.pageY+10 && a.eY >= e.pageY-10) {
				setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 500);
			}
		}
		a.clicked = false;
		if (a.Menu.bgImageOver) a.background.src = a.Menu.bgImageUp;
	} else if (window.ActiveMenu && FIND("menuItem0")) {
		if (a) {
			a.style.backgroundColor = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.hiliteShim) a.hiliteShim.style.visibility = "inherit";
			if (a.Menu.bgImageUp) a.style.background = "url(" + a.Menu.bgImageUp +")";
		}
	}
	if (!mouseup && window.ActiveMenu) {
		if (window.ActiveMenu.Menu) {
			if (window.ActiveMenu.Menu.hideOnMouseOut) MM_startTimeout();
			return(true);
		}
	}
	return(true);
}

function hideChildMenu(hcmLayer) {
	MM_clearTimeout();
	var l = hcmLayer;
	for (var i=0; i < l.Menu.childMenus.length; i++) {
		var theLayer = l.Menu.childMenus[i];
		if (document.layers) theLayer.visibility = "hidden";
		else {
			theLayer = FIND(theLayer);
			theLayer.style.visibility = "hidden";
			if( theLayer.Menu.menuItemHAlign != 'left' ) {
				for(var j = 0; j < theLayer.Menu.menuItemLayers.length; j++) {
					var itemLayer = theLayer.Menu.menuItemLayers[j];
					if(itemLayer.textShim) itemLayer.textShim.style.visibility = "inherit";
				}
			}
		}
		theLayer.Menu.hideChildMenu(theLayer);
	}
	if (l.childMenu) {
		var childMenu = l.childMenu;
		if (document.layers) {
			l.Menu.MM_showMenu(null,null,null,childMenu.layers[0]);
			childMenu.zIndex = l.parentLayer.zIndex +1;
			childMenu.top = l.Menu.menuLayer.top + l.Menu.submenuYOffset;
			if( l.Menu.vertical ) {
				if( l.Menu.submenuRelativeToItem ) childMenu.top += l.top + l.parentLayer.top;
				childMenu.left = l.parentLayer.left + l.parentLayer.clip.width - (2*l.Menu.menuBorder) + l.Menu.menuLayer.left + l.Menu.submenuXOffset;
			} else {
				childMenu.top += l.top + l.parentLayer.top;	
				if( l.Menu.submenuRelativeToItem ) childMenu.left = l.Menu.menuLayer.left + l.left + l.clip.width + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
				else childMenu.left = l.parentLayer.left + l.parentLayer.clip.width - (2*l.Menu.menuBorder) + l.Menu.menuLayer.left + l.Menu.submenuXOffset;
			}
			if( childMenu.left < l.Menu.container.clip.left ) l.Menu.container.clip.left = childMenu.left;
			var w = childMenu.clip.width+childMenu.left-l.Menu.container.clip.left;
			if (w > l.Menu.container.clip.width)  l.Menu.container.clip.width = w;
			var h = childMenu.clip.height+childMenu.top-l.Menu.container.clip.top;
			if (h > l.Menu.container.clip.height) l.Menu.container.clip.height = h;
			l.document.layers[1].zIndex = 0;
			childMenu.visibility = "inherit";
		} else if (FIND("menuItem0")) {
			childMenu = FIND(l.childMenu);
			var menuLayer = FIND(l.Menu.menuLayer);
			var s = childMenu.style;
			s.zIndex = menuLayer.style.zIndex+1;
			if (document.all || window.mmIsOpera) {
				s.pixelTop = menuLayer.style.pixelTop + l.Menu.submenuYOffset;
				if( l.Menu.vertical ) {
					if( l.Menu.submenuRelativeToItem ) s.pixelTop += l.style.pixelTop;
					s.pixelLeft = l.style.pixelWidth + menuLayer.style.pixelLeft + l.Menu.submenuXOffset;
					s.left = s.pixelLeft + 'px';
				} else {
					s.pixelTop += l.style.pixelTop;
					if( l.Menu.submenuRelativeToItem ) s.pixelLeft = menuLayer.style.pixelLeft + l.style.pixelLeft + l.style.pixelWidth + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
					else s.pixelLeft = (menuLayer.style.pixelWidth-4*l.Menu.menuBorder) + menuLayer.style.pixelLeft + l.Menu.submenuXOffset;
					s.left = s.pixelLeft + 'px';
				}
			} else {
				var top = parseInt(menuLayer.style.top) + l.Menu.submenuYOffset;
				var left = 0;
				if( l.Menu.vertical ) {
					if( l.Menu.submenuRelativeToItem ) top += parseInt(l.style.top);
					left = (parseInt(menuLayer.style.width)-4*l.Menu.menuBorder) + parseInt(menuLayer.style.left) + l.Menu.submenuXOffset;
				} else {
					top += parseInt(l.style.top);
					if( l.Menu.submenuRelativeToItem ) left = parseInt(menuLayer.style.left) + parseInt(l.style.left) + parseInt(l.style.width) + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
					else left = (parseInt(menuLayer.style.width)-4*l.Menu.menuBorder) + parseInt(menuLayer.style.left) + l.Menu.submenuXOffset;
				}
				s.top = top + 'px';
				s.left = left + 'px';
			}
			childMenu.style.visibility = "inherit";
		} else return;
		window.activeMenus[window.activeMenus.length] = childMenu;
	}
}

function hideActiveMenus() {
	if (!window.activeMenus) return;
	for (var i=0; i < window.activeMenus.length; i++) {
		if (!activeMenus[i]) continue;
		if (activeMenus[i].visibility && activeMenus[i].Menu && !window.mmIsOpera) {
			activeMenus[i].visibility = "hidden";
			activeMenus[i].Menu.container.visibility = "hidden";
			activeMenus[i].Menu.container.clip.left = 0;
		} else if (activeMenus[i].style) {
			var s = activeMenus[i].style;
			s.visibility = "hidden";
			s.left = '-200px';
			s.top = '-200px';
		}
	}
	if (window.ActiveMenuItem) hideMenu(false, false);
	window.activeMenus.length = 0;
}

function moveXbySlicePos (x, img) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) x += img.x;
	return x;
}

function moveYbySlicePos (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}


// SUPPLEMENTARY

g_el = function(el) { return document.getElementById(el); };

function supressEnter(ev){
	if(!ev) var ev = window.event;
	if(ev && ev.keyCode == 13){
		return false;
	}
	return true;
}

function textAreaEnterHandler(ev){
	ev = (ev) ? ev : window.event;
	ev.cancelBubble = true;
	return true;
}

// MINUTES FUNCTIONALITY

var hRef = null;

function resetMinutes(h, m){
	var m = g_el(m);
	hRef = h;
	m.selectedIndex = 0;
	var v = h.value;
	var vM = v.split(':');
	for(var i = 0; i < 4; i++){
		o = m.options[i];
		if(o.value == vM[1])
			m.selectedIndex = i;
	}
}


function setMinutes(m){
	if(hRef == null || hRef.selectedIndex < 1) return;
	var v = m.value;
	var hT = hRef[hRef.selectedIndex].text;
	var hV = hRef[hRef.selectedIndex].value;
	hT = hT.split(':')[0] + ':' + v + ' ' + hT.split(':')[1].split(' ')[1];
	hV = hV.split(':')[0] + ':' + v;
	hRef[hRef.selectedIndex].text = hT;
	hRef[hRef.selectedIndex].value = hV;
}


var wdays = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];

function doSameHour(el, pos){
	var index = getWDIndex(el.id, pos);

	var ddlBeg = (pos == 3) ? 'ddl' : 'ddl2';
	var cbBeg = (pos == 3) ? 'cb_' : 'cb2_';
	
	var hourFrom1 = g_el(ddlBeg + wdays[index - 1] + 'From');
	var hourTo1 = g_el(ddlBeg + wdays[index - 1] + 'To');
	
	var hourFrom2 = g_el(ddlBeg + wdays[index] + 'From');
	var hourTo2 = g_el(ddlBeg + wdays[index] + 'To');
	
	if(el.checked){
		if(index >= 1 && index <= 6){
			//== adjust valued (hour:minute) ==//
			hourFrom2[hourFrom1.selectedIndex].value = hourFrom1[hourFrom1.selectedIndex].value;
			hourFrom2[hourFrom1.selectedIndex].text = hourFrom1[hourFrom1.selectedIndex].text;
			hourTo2[hourTo1.selectedIndex].value = hourTo1[hourTo1.selectedIndex].value;
			hourTo2[hourTo1.selectedIndex].text = hourTo1[hourTo1.selectedIndex].text;
			
			//==========
			hourTo2.selectedIndex = hourTo1.selectedIndex;
			hourFrom2.selectedIndex = hourFrom1.selectedIndex;
			hourTo2.disabled = true;
			hourFrom2.disabled = true;
		}
	}
	else{
		if(index >= 1 && index <= 6){
			hourTo2.disabled = false;
			hourFrom2.disabled = false;
		}
	}
}

function doSameHours(el, pos, mName){		// position determines the position of the character in an element id 
	var index = getWDIndex(el.id, pos);
	var ddlBeg = (pos == 3) ? 'ddl' : 'ddl2';
	var cbBeg = (pos == 3) ? 'cb_' : 'cb2_';
	
	var _from = g_el(ddlBeg + wdays[index] + 'From');
	var _to = g_el(ddlBeg + wdays[index] + 'To');
	
	if(el.selectedIndex == 0){
		_from.selectedIndex = 0;
		_to.selectedIndex = 0;
	}
	
	for(var i = index + 1; i < wdays.length; i++){
		var fromName = ddlBeg + wdays[i] + 'From';
		var toName = ddlBeg + wdays[i] + 'To';
		var cbName = cbBeg + wdays[i];
		if(g_el(cbName).checked){
			g_el(fromName).selectedIndex = _from.selectedIndex;
			g_el(toName).selectedIndex = _to.selectedIndex;
		}
		else{
			break;
		}
	}
	// RESET MINUTES
	if(mName)
		resetMinutes(el, mName);
}

function clearSameHours(){
	for(var i = 0; i < wdays.length; i++){
		var el = g_el('ddl' + wdays[i] + 'From');
		if(el)
			el.disabled = false;
		el = g_el('ddl' + wdays[i] + 'To');
		if(el)
			el.disabled = false;
	}
	return true;
}


function enableTimes(v)
{
	v = (v) ? false : true;
	for(var i = 0; i < wdays.length; i++){
		var el = g_el('ddl' + wdays[i] + 'From');
		if(el)
			el.disabled = v;
		el = g_el('ddl' + wdays[i] + 'To');
		if(el)
			el.disabled = v;
		el = g_el('cb_' + wdays[i]);
		if(el)
			el.disabled = v;
	}
	var el = g_el('hoursCnt');
	if(el)
		el.style.display = (v) ? 'none' : 'block';
	return;
}


function checkInfo(amount){
	for(var i = 0; i < wdays.length; i++){
		if(amount == 2){
			g_el('ddl' + wdays[i] + 'From').disabled = false;
			g_el('ddl' + wdays[i] + 'To').disabled = false;
		}
		g_el('ddl2' + wdays[i] + 'From').disabled = false;
		g_el('ddl2' + wdays[i] + 'To').disabled = false;
	}
	
	var res = true;
	if(amount == 2){
		var el1 = g_el('tbDeliveryMinOrder');
		var el2 = g_el('tbDeliveryCharge');
		var el3 = g_el('tbDeliveryMaxDistance');
		res = true;
	}
	return res;
}

function getWDIndex(name, pos){
	var wd = name.substr(pos, 2);		// 3 or 4
	var index = -1;
	for(var i = 0; i < wdays.length; i++){
		if(wdays[i] == wd)
			index = i;
	}
	return index;
}

function doPswCheckOnEdit(){
	var _psw = g_el('tbPsw');
	var _rpsw = g_el('tbRepPsw');
	if(_psw && _rpsw){
		if(_psw.value.length > 0){
			if(_psw.value == _rpsw.value)
				return true;
			else {
				var _err = g_el('cvPsw');
				if(_err)
					_err.style.visibility = 'visible';
				return false;
			}
		}
	}
}

function preview(what){
	var p = document.getElementById('imgPhoto');
	if(p){
		if(what.value.length > 0){
			p.src = what.value;
		}
		else {
			p.src='images/no_picture.gif';
		}
	}
}

// USER EDIT 

var chbs = ['cbMenuFood', 'cbStatement', 'cbEvent', 'cbPhoto'];

function fuChecked(el){
	for(var i = 0; i < chbs.length; i++){
		g_el(chbs[i]).disabled = el.checked;
	}
}

function fillIfPriceEmpty(elID){
	var el = g_el(elID);
	if(el && TrimString(el.value) == 0)
		el.value = '0.00';
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function IsPrice(text){
	var res = /^\d+(\.\d{2})?$/.test(text);
	return res;
}

function isValidDGPrice(el){
	if(!IsPrice(el.value)){
		alert('Please enter Price');
		el.focus();
	}
}


// ICON FUNCTIONALITY

//var icons = ['icon1', 'icon2', 'icon3', 'icon4', 'icon5', 'icon6', 'icon7', 'icon8'];
//var iconSelID = 'icon1';
//g_el = function (el) { return document.getElementById(el); };
var valihIcons='ihIcons';
function iconAction(iconID, act){
	switch(act){
		case 'over':
			for(var i = 0; i< icons.length; i++){
				var el = g_el(icons[i]);
				if(el)
					el.className = el.className.replace('over', 'out');
				if(icons[i] == iconID)
					el.className = el.className.replace('out', 'over');
			}
			break;
		case 'out':
			for(var i = 0; i< icons.length; i++){
				var el = g_el(icons[i]);
				if(el)
					el.className = el.className.replace('over', 'out');
			}
			break;
		case 'click':
			for(var i = 0; i < icons.length; i++){
				var el = g_el(icons[i]);
				if(el)
					el.className = 'icon_normal_out';
			}
			var el = g_el(iconID);
			if(el){
				iconSelID = iconID;
				el.className = 'icon_selected_over';
			}
			el = g_el(valihIcons);
			if(el)
				el.value = iconID.split('_')[1];
			break;
	}
}

// PHONE NUMBER FUNCTIONALITY
var rules = [3, 3, 4];
var phoneIDs = ['tbPhone1', 'tbPhone2', 'tbPhone3'];
var phoneTOutRef = null;

function handlePhone(el, pos, elID2){
	if(phoneTOutRef != null){
		clearTimeout(phoneTOutRef);
		phoneTOutRef = null;
	}
	var f = 'phoneHandler("' + el.id + '", ' + pos + ', "' + elID2 + '")';
	setTimeout(f, 5);
}

function phoneHandler(el, pos, elID2){		// el, rules[position], id of the next el
	el = g_el(el);
	var v = el.value.toString();
	var v2 = '';
	for(var i = 0; i < v.length; i++){
		v3 = v.substr(i, 1);
		v3 = parseInt(v3);
		if(!isNaN(v3))
			v2 += v3;
	}
	el.value = v2;
	
	if(v2.length >= rules[pos]){
		if(v2.length > rules[pos]){
			el.value = v2.substring(0, rules[pos]);
		}
		var el2 = g_el(elID2);
		if(el2)
			el2.focus();
	}
}

function checkPhone(baseName){
	var res = true;
	for(var i = 0; i < phoneIDs.length; i++){
		var el = g_el(baseName + '_' + phoneIDs[i]);
		if(el && isIntegerN(el.id, rules[i])){
			res = true;
			if(g_el(baseName + '_' + 'phoneError'))
				g_el(baseName + '_' + 'phoneError').className = 'noerrorStar';
		}
		else { 
			if(g_el(baseName + '_' + 'phoneError'))
				g_el(baseName + '_' + 'phoneError').className = 'errorStar';
			
			return false;
		}
		
	}
	return res;
}

// ==================================

// ============= VALIDATION ACTIVITY ========== //

function isEmpty(elID){
	var res = true;
	var el = g_el(elID);
	if(el && el.value != null && el.value.length > 0)
		res = false;
	return res;
}

function isEmail(elID){
	var res = false;
	var el = g_el(elID);
	if(el){
		var re = /^(?:[a-zA-Z0-9_'^&/+-])+(?:\.(?:[a-zA-Z0-9_'^&/+-])+)*@(?:(?:\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)|(?:[a-zA-Z0-9-]+\.)+(?:[a-zA-Z]){2,}\.?)$/;
		if(el.value.match(re))
			res = true;
	}
	return res;
}

function isUrl(elID){
	var res = false;
	var el = g_el(elID);
	if(el){
		var re = new RegExp("^http://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$");
		var v = 'http://' + el.value;
		if(v.match(re))
			res = true;
	}
	return res;
}

function isInteger(elID){		// integer
	var res = false;
	var el = g_el(elID);
	if(el){
		var re = /^[0-9]*[0-9]+$|^[0-9]+[0-9]*$/;
    if (el.value.match(re)){
	    var num = parseInt(el.value, 10);
		  res = (isNaN(num) ? false : true);
		}
	}
	return res;
}

function isIntegerN(elID, n){		// interger ( n digits )
	var res = false;
	var el = g_el(elID);
	if(el && isInteger(elID) && (el.value.length == n)){
		res = true;
	}
	return res;
}

// ============================================ //

// ========= SUB TABLE FUNCTIONALITY ========== //
var baseImgs = './images/';
var baseDetails = 'details_';

function showSubTable(elImg, dgName){
    
	var id = elImg.id.toString().split('_');
	var state = (elImg.src.indexOf('plus') > -1) ? false : true;
	var el = g_el(baseDetails + id[1]);

	if(el){
		el.style.display = state ? 'none' : 'block';
		elImg.src = elImg.src.replace( (state ? 'minus' : 'plus'), (state ? 'plus' : 'minus'));
	}
}



// ============================================ //


// script from Sasha

function setFocusOnFirstInput() {
  var bFound = false;
  // for each form
  for (f=0; f < document.forms.length; f++) {
    // for each element in each form
    for(i=0; i < document.forms[f].length; i++) {
      // if it's not a hidden element
      if (document.forms[f][i].type != "hidden") {
		// if it's a Input element
		if (document.forms[f][i].type == "text") {
			// and it's not disabled
			if (document.forms[f][i].disabled != true) {
				// set the focus to it
				document.forms[f][i].focus();
				var bFound = true;
			}
        }
      }
      // if found in this element, stop looking
      if (bFound == true)
        break;
    }
    // if found in this form, stop looking
    if (bFound == true)
      break;
  }
}









// ============================================ //
//								AMERICAN TIME									//
// ============================================ //

function SetSameAsAbove(el, cntName){
	var pos = -1;
	var posAbove = -1;
	for(var i = 0; i < cntName.length; i++){
		if(cntName[i].isSameEl == el.id){
			pos = cntName[i].position;
			break;
		}
	}
	if(pos == -1 || cntName[pos].isFirst) return;
	
	posAbove = pos - 1;

	
	if(el.checked){
		g_el(cntName[pos].hourFrom).selectedIndex = g_el(cntName[posAbove].hourFrom).selectedIndex;
		g_el(cntName[pos].minuteFrom).selectedIndex = g_el(cntName[posAbove].minuteFrom).selectedIndex;
		g_el(cntName[pos].partFrom).selectedIndex = g_el(cntName[posAbove].partFrom).selectedIndex;
		g_el(cntName[pos].hourTo).selectedIndex = g_el(cntName[posAbove].hourTo).selectedIndex;
		g_el(cntName[pos].minuteTo).selectedIndex = g_el(cntName[posAbove].minuteTo).selectedIndex;
		g_el(cntName[pos].partTo).selectedIndex = g_el(cntName[posAbove].partTo).selectedIndex;
		g_el(cntName[pos].isClosedEl).checked = g_el(cntName[posAbove].isClosedEl).checked;
	}
	
	g_el(cntName[pos].isClosedEl).disabled = el.checked;
	if(!cntName[pos].isClosed){
		g_el(cntName[pos].hourFrom).disabled = el.checked;
		g_el(cntName[pos].minuteFrom).disabled = el.checked;
		g_el(cntName[pos].partFrom).disabled = el.checked;
		g_el(cntName[pos].hourTo).disabled = el.checked;
		g_el(cntName[pos].minuteTo).disabled = el.checked;
		g_el(cntName[pos].partTo).disabled = el.checked;
	}

}

function SetTimeClosed(el, cntName){
	var pos = -1;
	for(var i = 0; i < cntName.length; i++){
		if(cntName[i].isClosedEl == el.id){
			pos = cntName[i].position;
			break;
		}
	}
	if(pos == -1) return;
	
	cntName[pos].isClosed = el.checked;
	g_el(cntName[pos].hourFrom).disabled = el.checked;
	g_el(cntName[pos].minuteFrom).disabled = el.checked;
	g_el(cntName[pos].partFrom).disabled = el.checked;
	g_el(cntName[pos].hourTo).disabled = el.checked;
	g_el(cntName[pos].minuteTo).disabled = el.checked;
	g_el(cntName[pos].partTo).disabled = el.checked;
	
}

function UpdateSameTime(el, propName, cntName){
	var pos = 0;
	for(var i = 0; i < cntName.length; i++){
		if(cntName[i][propName] == el.id){
			pos = i;
			break;
		}
	}
	
	for(var i = pos + 1; i < cntName.length; i++){
		if(!g_el(cntName[i].isSameEl).checked) break;
		
		SetDDLToValue(g_el(cntName[i][propName]), el.value);
	}
}

function EnableAmericanTimeOnSubmition(cntName){
	for(var i = 0; i < cntName.length; i++){
		g_el(cntName[i].isClosedEl).disabled = false;
		g_el(cntName[i].hourFrom).disabled = false;
		g_el(cntName[i].minuteFrom).disabled = false;
		g_el(cntName[i].partFrom).disabled = false;
		g_el(cntName[i].hourTo).disabled = false;
		g_el(cntName[i].minuteTo).disabled = false;
		g_el(cntName[i].partTo).disabled = false;
	}
	return true;
}


function SetTimeToOperationHours(cbSame, ops, hs){
	if(cbSame.checked){
		for(var i = 0; i < ops.length; i++){
			SetDDLToValue(g_el(hs[i].hourFrom), ops[i].hourFrom);
			SetDDLToValue(g_el(hs[i].minuteFrom), ops[i].minuteFrom);
			SetDDLToValue(g_el(hs[i].partFrom), ops[i].partFrom);
			SetDDLToValue(g_el(hs[i].hourTo), ops[i].hourTo);
			SetDDLToValue(g_el(hs[i].minuteTo), ops[i].minuteTo);
			SetDDLToValue(g_el(hs[i].partTo), ops[i].partTo);
			g_el(hs[i].isClosedEl).checked = ops[i].isClosed;
			if(g_el(hs[i].isSameEl)) g_el(hs[i].isSameEl).checked = false;
			hs[i].isClosed = ops[i].isClosed;
		}
		SwitchEnableAll(hs, cbSame.checked);
	}
	else{
		SwitchEnableAll(hs, cbSame.checked);
		for(var i = 0; i < ops.length; i++){
			g_el(hs[i].hourFrom).disabled = hs[i].isClosed;
			g_el(hs[i].minuteFrom).disabled = hs[i].isClosed;
			g_el(hs[i].partFrom).disabled = hs[i].isClosed;
			g_el(hs[i].hourTo).disabled = hs[i].isClosed;
			g_el(hs[i].minuteTo).disabled = hs[i].isClosed;
			g_el(hs[i].partTo).disabled = hs[i].isClosed;
		}

	}
}

function SwitchEnableAll(hs, isDisabled){
	for(var i = 0; i < hs.length; i++){
		g_el(hs[i].hourFrom).disabled = isDisabled;
		g_el(hs[i].minuteFrom).disabled = isDisabled;
		g_el(hs[i].partFrom).disabled = isDisabled;
		g_el(hs[i].hourTo).disabled = isDisabled;
		g_el(hs[i].minuteTo).disabled = isDisabled;
		g_el(hs[i].partTo).disabled = isDisabled;
		g_el(hs[i].isClosedEl).disabled = isDisabled;
		if(g_el(hs[i].isSameEl)) g_el(hs[i].isSameEl).disabled = isDisabled;
	}
}

function SetDDLToValue(el, v){
	for(var i = 0; i < el.options.length; i++){
		if(el.options[i].value == v){
			el.options[i].selected = true;
		}
	}
}
var valstar_tbDeliveryMinOrder='star_tbDeliveryMinOrder';
var valstar_tbDeliveryCharge='star_tbDeliveryCharge';
var valstar_tbDeliveryMaxDistance='star_tbDeliveryMaxDistance';
var valtbDeliveryMinOrder='tbDeliveryMinOrder';
var valtbDeliveryCharge='tbDeliveryCharge';

function CheckDPInfo(hs1, hs2, isDelivery){	// hs1 - delivery
	
	var isValid = true;
	if(isDelivery){
		g_el(valstar_tbDeliveryMinOrder).className = 'star_hid';
		g_el(valstar_tbDeliveryCharge).className = 'star_hid';
		g_el(valstar_tbDeliveryMaxDistance).className = 'star_hid';
		
		if(!IsDecimal(g_el(valtbDeliveryMinOrder))) {
			isValid = false;
			g_el(valstar_tbDeliveryMinOrder).className = 'star_vis';
		}
		if(!IsDecimal(g_el(valtbDeliveryCharge))) {
			isValid = false;
			g_el(valstar_tbDeliveryCharge).className = 'star_vis';
		}
		if(!isValid) return false;
		
		SwitchEnableAll(hs1, false);
	}
	
	SwitchEnableAll(hs2, false);
	return true;
}


// MENU TIMES

function SetMenuTimesAsOperationHours(cntName, isDisabled){
	if(isDisabled) SwitchEnableAll(cntName, isDisabled);
	else{
		SwitchEnableAll(cntName, isDisabled);
		for(var i = 0; i < cntName.length; i++){
			SetTimeClosed(g_el(cntName[i].isClosedEl), cntName);
		}
	}
}

// FOOD ITEM TIMES

function SetFoodItemTimeToOperationHours(cbSame, ops, hs){
	var cnt = g_el('hoursCnt');
	if(cbSame.checked){
		SetTimeToOperationHours(cbSame, ops, hs);
		cnt.style.display = 'none';
	}
	else{
		SwitchEnableAll(hs, cbSame.checked);
		for(var i = 0; i < hs.length; i++){
			SetTimeClosed(g_el(hs[i].isClosedEl), hs);
		}
		cnt.style.display = 'block';
	}
}





// Serving Time

var ST = {

	containerIDs: [],
	containers: [],
	operItems: [],
	
	init: function()
	{
		for(var i = 0; i < ST.containerIDs.length; i++)
		{
			ST.containers[ST.containers.length] = g_el(ST.containerIDs[i]);
		}
		
		for(var i = 0; i < ST.containers.length; i++)
		{
			ST.initContainer(ST.containers[i]);
		}
		
		document.forms[0].onsubmit = ST.enableAll;
		//events.add(document.forms[0], 'submit', ST.enableAll);
		ST.update();
	},
	
	initContainer: function(cnt)
	{
		cnt.sameAsRef = null;
		cnt.items = [];
		cnt.update = ST.updateContainer;
		
		var els = cnt.getElementsByTagName('input');
		for(var i = 0; i < els.length; i++)
		{
			if(els[i].id.indexOf('cbSameAsOper') > -1)
			{
				cnt.sameAsRef = els[i];
				cnt.sameAsRef.parentContainer = cnt;
				events.add(cnt.sameAsRef, 'click', ST.setAsOperationHours);
			}
		}
		
		var dayRows = cnt.getElementsByTagName('div');
		
		for(var i = 0; i < dayRows.length; i++)
		{
			if(dayRows[i].className.indexOf('servingTimeRow') == -1) continue;
			
			var dayRow = dayRows[i];
			var dayItem = {closedRef:null, hFromRef:null, mFromRef:null, pFromRef:null, hToRef:null, mToRef:null, pToRef:null, sameAsAboveRef:null};
				
			dayItem.update = ST.updateDayRow;
			dayItem.parentContainer = cnt;
			cnt.items[cnt.items.length] = dayItem;
			
			if(cnt.items.length > 1)
				dayItem.aboveRow = cnt.items[cnt.items.length - 2];
				
			if(cnt.items.length > 1)
				cnt.items[cnt.items.length - 2].belowRow = cnt.items[cnt.items.length - 1];
		
			var cbEls = dayRow.getElementsByTagName('input');
			for(var k = 0; k < cbEls.length; k++)
			{
				if(cbEls[k].id.indexOf('cbIsClosed') > -1)
				{
					dayItem.closedRef = cbEls[k];
					dayItem.closedRef.parentRow = dayItem;
					events.add(dayItem.closedRef, 'click', ST.setClosed);
				}
				
				if(cbEls[k].id.indexOf('cbSameAsAbove') > -1)
				{
					dayItem.sameAsAboveRef = cbEls[k];
					dayItem.sameAsAboveRef.parentRow = dayItem;
					events.add(dayItem.sameAsAboveRef, 'click', ST.setAsAbove);
				}
			}
			
			var selEls = dayRow.getElementsByTagName('select');
			for(var k = 0; k < selEls.length; k++)
			{
				if(selEls[k].id.indexOf('ddlHoursFrom') > -1)		dayItem.hFromRef = selEls[k];
				if(selEls[k].id.indexOf('ddlMinutesFrom') > -1) dayItem.mFromRef = selEls[k];
				if(selEls[k].id.indexOf('ddlDayPartFrom') > -1) dayItem.pFromRef = selEls[k];
				if(selEls[k].id.indexOf('ddlHoursTo') > -1)			dayItem.hToRef = selEls[k];
				if(selEls[k].id.indexOf('ddlMinutesTo') > -1)		dayItem.mToRef = selEls[k];
				if(selEls[k].id.indexOf('ddlDayPartTo') > -1)		dayItem.pToRef = selEls[k];
				
				selEls[k].parentRow = dayItem;
				events.add(selEls[k], 'change', ST.setBelow);
			}
			
		}
		
	},
	
	update: function()
	{
		for(var i = 0; i < ST.containers.length; i++)
		{
			ST.containers[i].update();
		}
	},
	
	updateContainer: function()
	{
		for(var i = 0; i < this.items.length; i++)
		{
			this.items[i].update(this.sameAsRef.checked);
		}
	},
	
	updateDayRow: function(isDisabled)
	{
		var isSameAsAboveChecked = this.sameAsAboveRef ? this.sameAsAboveRef.checked : false;
		var isRowDisabled = (isDisabled || this.closedRef.checked || isSameAsAboveChecked) ? true : false;
		
		this.closedRef.disabled = (isDisabled || isSameAsAboveChecked);
		this.hFromRef.disabled = isRowDisabled;
		this.mFromRef.disabled = isRowDisabled;
		this.pFromRef.disabled = isRowDisabled;
		this.hToRef.disabled = isRowDisabled;
		this.mToRef.disabled = isRowDisabled;
		this.pToRef.disabled = isRowDisabled;
		if(this.sameAsAboveRef) this.sameAsAboveRef.disabled = isDisabled;
	},
	
	setAsOperationHours: function()
	{
		if(this.checked)
		{
			var cnt = this.parentContainer;
			for(var i = 0; i < ST.operItems.length; i++)
			{
				cnt.items[i].closedRef.checked = ST.operItems[i].closed;
				cnt.items[i].hFromRef.value = ST.operItems[i].hFrom;
				cnt.items[i].mFromRef.value = ST.operItems[i].mFrom;
				cnt.items[i].pFromRef.value = ST.operItems[i].pFrom;
				cnt.items[i].hToRef.value = ST.operItems[i].hTo;
				cnt.items[i].mToRef.value = ST.operItems[i].mTo;
				cnt.items[i].pToRef.value = ST.operItems[i].pTo;
			}
		}
		
		this.parentContainer.update();
	},
	
	setClosed: function()
	{
		this.parentRow.update();
	},
	
	setAsAbove: function()
	{
		var r1 = this.parentRow;
		var r2 = this.parentRow.aboveRow;
		
		r1.closedRef.checked = r2.closedRef.checked;
		r1.hFromRef.value = r2.hFromRef.value;
		r1.mFromRef.value = r2.mFromRef.value;
		r1.pFromRef.value = r2.pFromRef.value;
		r1.hToRef.value = r2.hToRef.value;
		r1.mToRef.value = r2.mToRef.value;
		r1.pToRef.value = r2.pToRef.value;
		
		r1.update();
	},
	
	setBelow: function()
	{
		var r1 = this.parentRow;
		var r2 = r1.belowRow;
		while(r2 && r2.sameAsAboveRef && r2.sameAsAboveRef.checked){
			
			r2.closedRef.checked = r1.closedRef.checked;
			r2.hFromRef.value = r1.hFromRef.value;
			r2.mFromRef.value = r1.mFromRef.value;
			r2.pFromRef.value = r1.pFromRef.value;
			r2.hToRef.value = r1.hToRef.value;
			r2.mToRef.value = r1.mToRef.value;
			r2.pToRef.value = r1.pToRef.value;
			r2.update();
			
			r2 = r2.belowRow;
		}
	},
	
	enableAll: function()
	{
		for(var i = 0; i < ST.containers.length; i++)
		{
			var cnt = ST.containers[i];
			cnt.sameAsRef.disabled = false;
			
			for(var k = 0; k < cnt.items.length; k++)
			{
				var row = cnt.items[k];
				row.closedRef.disabled = false;
				row.hFromRef.disabled = false;
				row.mFromRef.disabled = false;
				row.pFromRef.disabled = false;
				row.hToRef.disabled = false;
				row.mToRef.disabled = false;
				row.pToRef.disabled = false;
				if(row.sameAsAboveRef) row.sameAsAboveRef.disabled = false;
			}
		}
	},
	
	showST: function()
	{
		var pr = '';
		for(var i = 0; i < ST.containers.length; i++)
		{
			pr += 'container:' + ST.containers[i].id + '\n\r';
			pr += '-----------------------------------\n\r';
			pr += 'same as operations:' + ST.containers[i].sameAsRef.id + '\n\r';
			
			for(var k = 0; k < ST.containers[i].items.length; k ++){
				var item = ST.containers[i].items[k];
				pr += 'closed:' + item.closedRef.id	+ ';\n\r';
				pr += 'hFrom:'	+ item.hFromRef.id	+ ';\n\r';
				pr += 'mFrom:'	+ item.mFromRef.id	+ ';\n\r';
				pr += 'pFrom:'	+ item.pFromRef.id	+ ';\n\r';
				pr += 'hTo:'		+ item.hToRef.id		+ ';\n\r';
				pr += 'mTo:'		+ item.mToRef.id		+ ';\n\r';
				pr += 'pTo:'		+ item.pToRef.id		+ ';\n\r';
				if(k > 0)	pr += 'above:'	+ item.updateDayRow.id	+ ';\n\r';
			}
		}
		
		alert(pr);
	}

}

// Serving Time end


/* WAITING MANAGER */

var WM = {

	toutRef: null,
	url: 'lotg_waiting.ashx',
	cntId: 'cntWaiting',
	
	init: function()
	{
		$('form').submit(function(){ 
			$('#' + WM.cntId).show();
			WM.toutRef = setInterval(WM.check, 2000); 
		});
	},
	
	check: function()
	{
		$.get(WM.url, null, function(data){ 
			if(data == '0') 
			{
				clearInterval(WM.toutRef);
				WM.toutRef = null;
				$('#' + WM.cntId).hide();
			}  
		});
	}

}

/* WAITING MANAGER END */


/* OPTIONS DETERMINE PRICE */

var ODP = {

	maxOptions: 12,	// max allowed options
	itemsDelimiter: '__items__',
	partsDelimiter: '__parts__', 
	cnt: 'cntOptions',
	cntOut: 'cntOptionsOut',
	cntPrice: 'cntPrice',	// food item price container
	options: [],
	hfOut: '',	// hidden field used for keeping resulted set
	cb: '',
	
	init: function()
	{
		for(var i = 0; i < ODP.options.length; i++)
		{
			ODP.add(ODP.options[i].name, ODP.options[i].price, ODP.options[i].isUnavailable);
		}
		
		ODP.show();
	},
	
	show: function()
	{
		if($('#' + ODP.cb).get(0).checked) 
		{
			$('#' + ODP.cnt).show();
			$('#' + ODP.cntPrice).css('visibility', 'hidden');
			if($('#' + ODP.cntOut + ' div.odp').length == 0) ODP.add();
			if($('#' + ODP.cntOut + ' div.odp').length == 1) ODP.add();
			
			$('#' + ODP.cntOut + ' div.odp input.pos2').get(0).focus();
		}
		else 
		{
			$('#' + ODP.cnt).hide();
			$('#' + ODP.cntPrice).css('visibility', 'visible').find('input').get(0).focus();
		}
	},
	
	add: function(name, price, isUnavailable)
	{
		var pos = $('#' + ODP.cntOut + ' div.odp').length + 1;
		if(pos > 12) return;
		
		name = name || '';
		price = price || '0.00';
		isUnavailable = isUnavailable || false;
		
		var data = '<div class="odp">';
		data += '<span class="pos1">' + pos + '</span>';
		data += '<input type="text" class="pos2 form_text" style="width:330px;" />';
		data += '<span class="pos3">$<input type="text" class="form_text" style="width:50px" value="' + price + '" /></span>';
		if(pos > 2) data += '<a href="javascript:;" onclick="ODP.remove(this);" class="pos4">delete</a>';
		if(pos > 1) data += '<input type="checkbox" class="pos5 form_tex" ' + (isUnavailable ? 'checked="checked"' : '') + ' />';
		data += '</div>';
		
		$(data).addClass(pos % 2 ? 'listRowLght' : 'listRowDark').appendTo($('#' + ODP.cntOut)).find('input.pos2').val(name);
	},
	
	remove: function(el)
	{
		$(el).parent().remove();
		$('#' + ODP.cntOut + ' div.odp').each(function(i){
			$(this).find('.pos1').html(i + 1);
			$(this).removeClass('listRowDark listRowLght').addClass(i % 2 ? 'listRowDark' : 'listRowLght');
		});
	},
	
	hasError: function()
	{
		if(!$('#' + ODP.cb).get(0).checked) return false;
		
		var res = '';
		var counter = 0;
		
		$('#' + ODP.cntOut + ' div.odp').each(function(i){
			var name  = $.trim($(this).find('input.pos2').val());
			var price = $.trim($(this).find('.pos3 input').val());
			var isUnavailable = false;
			var $cb = $(this).find('input.pos5');
			if($cb.length > 0) isUnavailable = $cb.get(0).checked;
			
			if(name.length > 0 && !isNaN(parseFloat(price)))
			{
				res += (res.length > 0 ? ODP.itemsDelimiter : '') + name + ODP.partsDelimiter + price + ODP.partsDelimiter + (isUnavailable ? '1' : '0');
				counter ++;
			}
		});
		
		if(counter < 2) 
		{
			alert('You must specify at least 2 options.');
			return true;
		}
		
		$('#' + ODP.hfOut).val(res);
		
		return (res.length == 0);
	}

}


/* OPTIONS DETERMINE PRICE end */


/* sales tax exempt */
var STE = {
	cbId: '',
	cntId: 'steCnt',
	errors: ['Tax ID# is required.', 'Organization Name is required.' ],
	
	toggle: function()
	{
		if(STE.isChecked()) 
		{
			$('#' + STE.cntId).show();
			try { $('#' + STE.cntId + ' input').get(0).focus(); }
			catch(ex) {}
		}
		else
		{
			$('#' + STE.cntId).hide();
			STE.clear();
		}
	},
	
	isChecked: function()
	{
		return $('#' + STE.cbId).get(0).checked;
	},
	
	isValid: function()
	{
		if(!STE.isChecked()) return true;
		
		var $inps = $('#' + STE.cntId + ' input');
		if($.trim($inps.get(0).value).length == 0) 
		{
			STE.setError(0);
			return false;
		}
		
		if($.trim($inps.get(1).value).length == 0)
		{
			STE.setError(1);
			return false;
		}
		
		return true;
	},
	
	setError: function(ind)
	{
		alert(STE.errors[ind]);
		try { $inps.get(ind).focus(); }
		catch(ex) {}
	},
	
	clear: function()
	{
		$('#' + STE.cntId).find('input').val('');
	}
}

/* sales tax exempt end */

