var order_submit_count = 0;
var addtobasket_submit_count = 0;

// 05-13-2003
// used to 'fix' the floating red bar problem. it forces a refresh for IE
if (document.all && window.attachEvent) window.attachEvent("onload", fixWinIE);
function fixWinIE() {
        if (document.body.scrollHeight < document.all.main.offsetheight) {
                document.all.left.style.display = 'block';
	}
}

function EMG_body_onload() { //v1.0
	EMG_preload_nav();
	EMG_show_menu();
}

function EMG_nav_mouseover(item) {
	switch(item) {
		case 'aboutus':
			MM_showHideLayers('lnav-about','','show','lnav-menu','','hide','lnav-parties','','hide');
			break;
		case 'menu':
			MM_showHideLayers('lnav-about','','hide','lnav-menu','','show','lnav-parties','','hide');
			break;
		case 'parties':
			MM_showHideLayers('lnav-about','','hide','lnav-menu','','hide','lnav-parties','','show');
			break;
		case 'orders':
		case 'gallery':
		case 'reservations':
		case 'giftcertificates':
		default:
			MM_showHideLayers('lnav-about','','hide','lnav-menu','','hide','lnav-parties','','hide');
			break;
	}
}

function EMG_preload_nav() { //v1.1
	MM_preloadImages( // Preload gnavb
		'/images/menu/gnavb-customersupport-off.gif',
		'/images/menu/gnavb-customersupport-on.gif',
		'/images/menu/gnavb-myaccount-off.gif',
		'/images/menu/gnavb-myaccount-on.gif',
		'/images/menu/gnavb-shoppingbasket-off.gif',
		'/images/menu/gnavb-shoppingbasket-on.gif',
		'/images/menu/gnavb-vertbar.gif'
		);
	MM_preloadImages( // Preload pgnsa
		'/images/menu/pgnsa_gallery.gif',
		'/images/menu/pgnsa_giftcertificates.gif',
		'/images/menu/pgnsa_menu.gif',
		'/images/menu/pgnsa_onlineorders.gif',
		'/images/menu/pgnsa_parties.gif',
		'/images/menu/pgnsa_reservations.gif',
		'/images/menu/pgnsa_vertbar.gif'
		);
	MM_preloadImages( // Preload sgns
		'/images/menu/sgns_about_chef.gif',
		'/images/menu/sgns_about_contact.gif',
		'/images/menu/sgns_about_news.gif',
		'/images/menu/sgns_about_reviews.gif',
		'/images/menu/sgns_about_thalia.gif',
		'/images/menu/sgns_menu_brunch.gif',
		'/images/menu/sgns_menu_dessert.gif',
		'/images/menu/sgns_menu_dinner.gif',
		'/images/menu/sgns_menu_lounge.gif',
		'/images/menu/sgns_menu_lunch.gif',
		'/images/menu/sgns_menu_rawbar.gif',
		'/images/menu/sgns_parties_horsdoeuvres.gif',
		'/images/menu/sgns_parties_privatediningdinner.gif',
		'/images/menu/sgns_parties_privatedininglunch.gif',
		'/images/menu/sgns_vertbar.gif'
		);
}

function EMG_remove_address() { //v1.0
	var msg = 'Are you sure you want to remove this address from your account? It will be deleted permanently.';
	return EMG_check_confirm(msg);
}

function EMG_remove_creditcard() { //v1.0
	var msg = 'Are you sure you want to remove this credit card from your account? It will be deleted permanently.';
	return EMG_check_confirm(msg);
}

function EMG_remove_employee() { //v1.0
	var msg = 'Are you sure you want to remove this employee from your account? It will be deleted permanently.';
	return EMG_check_confirm(msg);
}

function EMG_order_cancel() { //v1.0
	var msg = 'Are you sure you want to cancel this order? Your shopping basket will be cleared and you will have to start over.';
	return EMG_check_confirm(msg);
}

function EMG_order_signout() { //v1.0
	var msg = 'Are you sure you want to sign out? You have an open order. If you sign out it will be lost and you will have to start over.';
	return EMG_check_confirm(msg);
}

function EMG_check_confirm(msg) { //v1.0
	if(confirm(msg)) {
		return true;
	} else {
		return false;
	}
}

function EMG_addtobasket_submitonce() { //v1.0
	var msg = 'Please submit only once. The item is being added to your basket and may take a few moments to finish.';

	if(addtobasket_submit_count == 0) {
		addtobasket_submit_count++;
		return true;
	} else {
		alert(msg);
		return false;
	}
}

function EMG_order_submitonce() { //v1.0
	var msg = 'Please submit only once. Your order is processing and may take a few moments to finish.';
	
	if(order_submit_count == 0) {
		order_submit_count++;
		return true;
	} else {
		alert(msg);
		return false;
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
