//------------------------------------------------------------------------------
function getCenterPosition(aWidth, aHeight)
{
  var wHeight = aHeight;
  var wWidth  = aWidth;
  var wLeft   = parseInt(parseInt(screen.width/2)  - parseInt(wWidth/2));
  var wTop    = parseInt(parseInt(screen.height/2) - parseInt(wHeight/2));
  return('width='+wWidth+', height='+wHeight+', left='+wLeft+', top='+wTop);
}
//------------------------------------------------------------------------------
function showCartoons()
{
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(680,600);
  window.open('showcartoons.php','cartoons', paramstr);
}
//------------------------------------------------------------------------------
function showLocationMenu(aCurrentLocation)
{
  var fafterRequest = function(){alert('Hall');};
  getDiv('llocation.php','divBodyLeft','showlocationmenu&currentlocation='+aCurrentLocation, null);
}
//------------------------------------------------------------------------------
function showLocationText(aCurrentLocation)
{
  var fafterRequest = function(){showLocationMenu(aCurrentLocation);};
  getDiv('llocation.php','divBodyCenter','showlocationtext&currentlocation='+aCurrentLocation, fafterRequest);
}
//------------------------------------------------------------------------------
function showLocationPicture(aCurrentLocation)
{
  var fafterRequest = function(){showLocationMenu(aCurrentLocation);};
  getDiv('llocation.php','divBodyRight','showlocationpicture&currentlocation='+aCurrentLocation, fafterRequest);
}
//------------------------------------------------------------------------------
function showReservationMenu(aCurrentLocation)
{
  var fafterRequest = function(){alert('Hall');};
  getDiv('lreservation.php','divBodyLeft','showreservationmenu&currentlocation='+aCurrentLocation, null);
}
//------------------------------------------------------------------------------
function showReservationText(aCurrentLocation)
{
  var fafterRequest = function(){showReservationMenu(aCurrentLocation);};
  getDiv('lreservation.php','divBodyCenter','showreservationtext&currentlocation='+aCurrentLocation, fafterRequest);
}
//------------------------------------------------------------------------------
function showMenuMenu(aCurrentMenu)
{
  var fafterRequest = function(){alert('Hall');};
  getDiv('lmenu.php','divBodyLeft','showmenumenu&currentmenu='+aCurrentMenu, null);
}
//------------------------------------------------------------------------------
function showMenuText(aCurrentMenu)
{
  var fafterRequest = function(){showMenuMenu(aCurrentMenu);};
  getDiv('lmenu.php','divBodyCenter','showmenutext&currentmenu='+aCurrentMenu, fafterRequest);
}
//------------------------------------------------------------------------------
function showMenuPicture(aCurrentMenu)
{
  var fafterRequest = function(){showMenuMenu(aCurrentMenu);};
  getDiv('lmenu.php','divBodyRight','showmenupicture&currentmenu='+aCurrentMenu, fafterRequest);
}
//------------------------------------------------------------------------------
function openMenu(aCurrentMenu)
{
  showMenuText(aCurrentMenu);
  showMenuPicture(aCurrentMenu);
}
//------------------------------------------------------------------------------
function showRoyaltyMenu(aCurrentMenuItem)
{
  var fafterRequest = function(){alert('Hall');};
  getDiv('lroyalty.php','divBodyLeft','showroyaltymenu&currentmenuitem='+aCurrentMenuItem, null);
}
//------------------------------------------------------------------------------
function showRoyaltyText(aCurrentMenuItem)
{
  var fafterRequest = function(){showRoyaltyMenu(aCurrentMenuItem);};
  getDiv('lroyalty.php','divBodyCenter','showroyaltytext&currentmenuitem='+aCurrentMenuItem, fafterRequest);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function showShopMenu()
{
  var fafterRequest = function(){alert('Hall');};
  getDiv('lshop.php','divBodyLeft','showshopmenu', null);
}
//------------------------------------------------------------------------------
function showShopText(aCurrentMenuItem)
{
  var fafterRequest = function(){showShopMenu(aCurrentMenuItem);};
  getDiv('lshop.php','divBodyCenter','showshoptext', fafterRequest);
}
//------------------------------------------------------------------------------
function showKidsMenu(aCurrentMenuitem)
{
  var fafterRequest = function(){alert('Hall');};
  getDiv('lkids.php','divBodyLeft','showkidsmenu&currentmenuitem='+aCurrentMenuitem, null);
}
//------------------------------------------------------------------------------
function showKidsText(aCurrentMenuitem)
{
  var fafterRequest = function(){showKidsMenu(aCurrentMenuitem);};
  getDiv('lkids.php','divBodyCenter','showkidstext&currentmenuitem='+aCurrentMenuitem, fafterRequest);
}
//------------------------------------------------------------------------------
function showTeamMenu(aCurrentMenuitem)
{
  var fafterRequest = function(){alert('Hall');};
  getDiv('lteam.php','divBodyLeft','showteammenu&currentmenuitem='+aCurrentMenuitem, null);
}
//------------------------------------------------------------------------------
function showTeamText(aCurrentMenuitem)
{
  var fafterRequest = function(){showTeamMenu(aCurrentMenuitem);};
  getDiv('lteam.php','divBodyCenter','showteamtext&currentmenuitem='+aCurrentMenuitem, fafterRequest);
}
//------------------------------------------------------------------------------
function getProductListDiv(aHierarchy,aStartRow,aOrderby)
{
  var fafterRequest = function(){setDragProducts();};
  getDiv('lshop.php', 'divBodyCenter', 'getcategoryproducts&hierarchy='+aHierarchy+'&startrow='+aStartRow+'&orderby='+aOrderby, null);
  collapseMenu(aHierarchy);
}
//------------------------------------------------------------------------------
function nextPage(aSearchWord)
{
  //alert(aSearchWord);
  var tmp=0;
  tmp = document.all["startrow"].value;
  document.all["startrow"].value = eval(tmp+'+3');
  getProductListDiv(document.all["hierarchy"].value,document.all["startrow"].value,'x');
}

//------------------------------------------------------------------------------
function previousPage(aSearchWord)
{
  if (document.all["startrow"].value > 2 )
  {
     var tmp=0;
     tmp = document.all["startrow"].value;
     document.all["startrow"].value = eval(tmp+'-3');
     getProductListDiv(document.all["hierarchy"].value,document.all["startrow"].value,'x');
  }
}
//------------------------------------------------------------------------------
function checkRegistrationDetails(aForm)
{
   var paramstr = 'saveregistration';
   var thefields= new Array(
   "FirstName",
   "LastName",
   "Mail",
   "PassWord",
   "PassWordRepeat",
   "Mobile",
   "Phone",
   "Fax",
   "Address",
   "City",
   "PostCode",
   "County",
   "Country"
   );
   
   required = new Array();
   required["FirstName"] = 'Please enter your first name.';
   required["LastName"] = 'Please enter your last name.';
   required["Phone"] = 'Please enter your phone number.';
   required["Mail"] = 'An Email address is required to register.';
   required["PassWord"] = 'A password is required to register.';
   required["PassWordRepeat"] = 'Please confirm your password.';
   required["Country"] = 'Please enter your country.';
   required["Address"] = 'Please enter your address.';
   required["City"] = 'Please enter your town/city.';

   if (aForm.PassWord.value != aForm.PassWordRepeat.value)
   {
      alert('Password and repeated password are not the same.');
      return false;
   }

   f = aForm;
   for(i in required)
   {
      if(f[i].value == "")
      {
         alert(required[i]);
         f[i].focus();
         return false;
      }
   }


   if (aForm.Country.value == 'Please select a country')
   {
      alert('Please select a country.');
      return false;
   }
   if (aForm.Mail.value.indexOf('@')==0)
   {
      alert('Your mail address is invalid.');
      return false;
   }

   for(i in thefields)
   {
      if (f[i])
      {
         paramstr += '&'+f[i].name+'='+f[i].value;
      }
   }

   paramstr += '&save=True';
   saveRegistrationDetails(paramstr);
   //getShopHomeDiv();
}
//------------------------------------------------------------------------------
function saveRegistrationDetails(aParamstr)
{
  var fafterRequest =  function(aResult)
                       {
                          alert(aResult);
                       };
  getDiv('lshopregistration.php', 'null', aParamstr, fafterRequest);

}

//------------------------------------------------------------------------------
function doReservation(aForm)
{
   var paramstr = '';

   if (aForm.LastName.value=='')
   {
      alert('Booking requires your last name.');
      return false;
   }

   if (aForm.Mail.value=='')
   {
      alert('Booking requires an eMail address.');
      return false;
   }

   if (aForm.Phone.value == '')
   {
      alert('Please enter a phone number.');
      return false;
   }
   if (aForm.Mail.value.indexOf('@')<1)
   {
      alert('Your mail address is invalid.');
      return false;
   }

   paramstr +='&restaurantid='+aForm.RestaurantId.value;
   paramstr +='&bookingdate='+aForm.Year.value+'-'+aForm.Month.value+'-'+aForm.Day.value;
   paramstr +='&bookingtime='+aForm.Time.value;
   paramstr +='&partysize='+aForm.PartySize.value;
   paramstr +='&bookingfirst='+aForm.FirstName.value;
   paramstr +='&bookinglast='+aForm.LastName.value;
   paramstr +='&bookingmail='+aForm.Mail.value;
   paramstr +='&bookingphone='+aForm.Phone.value;
   paramstr +='&bookingcomments='+aForm.Comments.value;
   if (aForm.SendInfo.checked)
   {
     paramstr +='&sendinfo=True';
   }
   else
   {
     paramstr +='&sendinfo=False';
   }
   getDiv('rd.php', 'divBodyCenter', 'doreservation'+paramstr, null);
}


//------------------------------------------------------------------------------
function addtoCart(aProductId, aQty)
{
  if(!aQty) aQty=1;
  getDiv('shoppingcart.php','divShoppingCartContent','addtocart&productid='+aProductId+'&qty='+aQty, '');
  document.getElementById("divShoppingCart").style.left=7+'px';  
}

//-----------------------------------------------------------------------------
function getShoppingCartDiv()
{
  var fafterRequest = function(){showCart(0,1);};
  getDiv('shoppingcart.php','divShoppingCart','getcartdiv',fafterRequest);
}

//------------------------------------------------------------------------------
function showCart(aLarge, aShowButtons)
{
  //var fafterRequest = function(){setDragShoppingCart();};
  getDiv('shoppingcart.php','divShoppingCartContent','showcart&large='+aLarge+'&showbuttons='+aShowButtons, null);
}
//------------------------------------------------------------------------------
function maximizeCart()
{
  document.getElementById("divShoppingCart").style.width = 300;
  showCart(1,1);
}
//------------------------------------------------------------------------------
function minimizeCart()
{
  document.getElementById("divShoppingCart").style.width = 200;
  showCart(0,1);
}
//------------------------------------------------------------------------------
function getBrowser()
{
  browser = 'IE';
  if(document.getElementById && !document.all)
  {
     browser = 'FireFox';
  }
  if (window.opera)
  {
     browser = 'Opera';
  }
  //alert('Your browser is ' + browser);
}
//------------------------------------------------------------------------------
function toggleBoolean(a)
{
   if (a.value == "True")
   {
      a.value = "False";
   }
   else
   {
      a.value = "True";
   }
}
//------------------------------------------------------------------------------
function getQuantityValueDiv(aProductId, aAccessoryId)
{
  fafterrequest = function(){document.all["quantity"].focus();document.all["quantity"].select();};
  getDiv('shoppingcart.php','divQuantityValue','getquantityvalue&productid='+aProductId+'&accessoryid='+aAccessoryId, fafterrequest);
}

//------------------------------------------------------------------------------
function showShoppingcart()
{
  document.getElementById("divShoppingCart").style.left=7+'px';
}

//------------------------------------------------------------------------------
function hideShoppingcart()
{
  document.getElementById("divShoppingCart").style.left= '-9999px';
}
//------------------------------------------------------------------------------
function removefromCart(aShoppingCartId)
{
  getDiv('shoppingcart.php','divShoppingCartContent','removefromcart&shoppingcartid='+aShoppingCartId, '');
  if (document.all['LastName']) showCheckout();
}
//------------------------------------------------------------------------------
function qtyPlus(aShoppingCartId)
{
  getDiv('shoppingcart.php','divShoppingCartContent','qtyplus&shoppingcartid='+aShoppingCartId, '');
  if (document.all['LastName']) showCheckout();
}
//------------------------------------------------------------------------------
function qtyMinus(aShoppingCartId)
{
  getDiv('shoppingcart.php','divShoppingCartContent','qtyminus&shoppingcartid='+aShoppingCartId, '');
  if (document.all['LastName']) showCheckout();
}
//------------------------------------------------------------------------------
function checkOut(aTotalAmount, aShipAmount)
{
  getDiv('shoppingcart.php','divBodyCenter','checkout&totalamount='+aTotalAmount+'&shipamount='+aShipAmount, '');
}

//------------------------------------------------------------------------------
function checkTC(aForm)
{
  //alert(aForm.AMOUNT.value);
  //alert(aForm.Discount.value);
  //alert(aForm.SMD.value);
  //alert(aForm.MD5HASH.value);
  if(!document.getElementById('tc').checked)
  {
     alert('Please check that you have read the terms and conditions.');
  }
  else
  {
     checkRegistrationDetails(aForm);
	   for (var i=0; i<aForm.length; i++)
     {
  		if (aForm[i].value=='')
        {
           alert('Please fill in your details.');
           aForm[i].focus();
           return false;
        }
     }

     if (confirm('You will now be transferred to the secure payment page of our payment provider "RealEx". When you have entered your details the amount of EUR'+aForm.AMOUNT.value/100+' will be debited to your credit card.'))
     {
        getDiv('shoppingcart.php', 'null', 'updatesales&orderid='+ aForm.ORDER_ID.value+'&amount='+aForm.AMOUNT.value, null);
        aForm.submit();
     }
  }
}
//------------------------------------------------------------------------------
function moreCA()
{
  window.open("moreca.php","_blank","width=600,height=300,left=300,top=200","resizeable=yes,menubar=yes,toolbar=no");
}

//------------------------------------------------------------------------------
function sendMoreCA(fMoreCA)
{
  var paramstr = '';
	for (var i=0; i<fMoreCA.length; i++)
  {
  		paramstr += '&'+fMoreCA[i].name+'='+fMoreCA[i].value;
  }
  getDiv('lroyalty.php', 'null', 'sendmoreca'+paramstr, null);
  alert('Your information request has been sent to Luigi Malones. We will get in contact with you soon.');
  window.close();
}
//------------------------------------------------------------------------------
function login(aForm)
{
  var fafterrequest = function(returnValue){alert(returnValue);window.location.href='index.php';};
  var paramstr      = '&Mail='+aForm.Mail.value+'&PassWord='+aForm.PassWord.value;
  //alert(paramstr);
  getDiv('lshopregistration.php', 'null', 'loginuser'+paramstr, fafterrequest);
}
//------------------------------------------------------------------------------
function setReservationDate()
{
  alert('x');
  getDiv('lreservation.php', 'null', 'setreservationtime&adate=', null);
}
//------------------------------------------------------------------------------
function checkSearchKey(aEvent)
{
  aEvent = aEvent || window.event;
  //alert('Code:'+aEvent.keyCode);
  //alert('Which:'+aEvent.which);
  if((aEvent.keyCode==13) || (aEvent.which == 13))
  {
     //alert(flogin.Mail.value);
     login(document.flogin);
  }
}

//------------------------------------------------------------------------------
function showReportMenu(aCurrentMenuItem)
{
  var fafterRequest = function(){alert('Hall');};
  getDiv('lreport.php','divBodyLeft','showreportmenu&currentmenuitem='+aCurrentMenuItem, null);
}

//------------------------------------------------------------------------------
function showReportText(aCurrentMenuItem)
{
  var fafterRequest = function(){showReportMenu(aCurrentMenuItem);};
  getDiv('lreport.php','divReportCenter','showreporttext&currentmenuitem='+aCurrentMenuItem, fafterRequest);
}

//------------------------------------------------------------------------------
function runReport(aForm)
{
  var fafterRequest = function() {window.open("showexcelreport.php","_blank","width=600,height=300,left=300,top=200","resizeable=yes,menubar=yes,toolbar=no");};

  var paramstr = '';
  for (var i=0; i<aForm.length; i++)
  {
     paramstr+='&'+ aForm[i].name + '=' + aForm[i].value
  }
  //alert(paramstr);
  getDiv('lreport.php','divReportCenter','runreport'+paramstr, null);
}

//------------------------------------------------------------------------------
function checkVoucher(aSender, aKey, aKey2, aDMD10, aDMD15)
{
  if(document.getElementById('VoucherOk').value==0)
  {
     //alert(aKey2);
     if (aSender.value.toLowerCase()==aKey.toLowerCase())
     {
        alert('Your voucher has been accepted. We will deduct 10% of your purchases.');
        //alert(document.getElementById('AMOUNT').value + ' M: '+document.getElementById('MD5HASH').value);
        document.getElementById('VoucherOk').value   = 1;
        document.getElementById('AMOUNT').value      = document.getElementById('AMOUNT').value*0.9;
        document.getElementById('MD5HASH').value     = aDMD10;
        //alert(document.getElementById('AMOUNT').value + ' M: '+document.getElementById('MD5HASH').value);
     }
     if (aSender.value.toLowerCase()==aKey2.toLowerCase())
     {
        alert('Your voucher has been accepted. We will deduct 15% of your purchases.');
        document.getElementById('VoucherOk').value   = 1;
        document.getElementById('AMOUNT').value      = document.getElementById('AMOUNT').value*0.85;
        document.getElementById('MD5HASH').value     = aDMD15;
        //alert(document.getElementById('AMOUNT').value);
     }
  }
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
getBrowser();







