function Load() {
    changeMenus()
}
function changeMenus() {
/*
 * This function is used when either the Branch / Brands are changed
 * It will load the news menus related to the Branch & Brand Combination
 */
   branch = MyForm.Branch.selectedIndex;
   branch = MyForm.Branch.options[branch].text;
   brand  = MyForm.Brand.selectedIndex;
   brand  = MyForm.Brand.options[brand].text;
   getMenus(branch, brand);
}
function getMenus(branch, brand) {
/*
 * Gets the Menus Table
 */
   getMenu = 1;
   if (branch.length==0) {
      getMenu = 0;
   }
   if (brand.length==0) {
      getMenu = 0;
   }

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainMenus").innerHTML=xmlhttp.responseText;
         getSubMenus("New");
      }
   }
   sendString = "ajax_get_data.php?Branch="+branch+"&Brand="+brand+"&Type=MainMenu";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getSubMenus(category) {
/*
 * Gets the Sub Menus Table
 */
   getMenu = 1;
   if (category.length==0) {
      getMenu = 0;
   }

   branch = MyForm.Branch.selectedIndex;
   branch = MyForm.Branch.options[branch].text;
   brand  = MyForm.Brand.selectedIndex;
   brand  = MyForm.Brand.options[brand].text;
   
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("SubMenus").innerHTML=xmlhttp.responseText;
         getBodyCategory(category);
      }
   }
   sendString = "ajax_get_data.php?Category="+category+"&Branch="+branch+"&Brand="+brand+"&Type=SubMenuCategory";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getBodyCategory(category) {
/*
 * Gets the Sub Menus Table
 */
   getMenu = 1;
   if (category.length==0) {
      getMenu = 0;
   }

   branch = MyForm.Branch.selectedIndex;
   branch = MyForm.Branch.options[branch].text;
   brand  = MyForm.Brand.selectedIndex;
   brand  = MyForm.Brand.options[brand].text;

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainBody").innerHTML=xmlhttp.responseText;
         getClientShoppingBasketSide();
      }
   }
   sendString = "ajax_get_data.php?Category="+category+"&Branch="+branch+"&Brand="+brand+"&Type=SubMenuBody";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getSubCategories(category, subcategory) {
/*
 * Gets the Sub Menus Table
 */
   getMenu = 1;
   if (category.length==0) {
      getMenu = 0;
   }
   if (subcategory.length==0) {
      getMenu = 0;
   }

   branch = MyForm.Branch.selectedIndex;
   branch = MyForm.Branch.options[branch].text;
   brand  = MyForm.Brand.selectedIndex;
   brand  = MyForm.Brand.options[brand].text;

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("SubMenus").innerHTML=xmlhttp.responseText;
         getSubCategoriesBody(category, subcategory);
      }
   }
   sendString = "ajax_get_data.php?SubCategory="+subcategory+"&Category="+category+"&Branch="+branch+"&Brand="+brand+"&Type=SubMenuSubCategory";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getSubCategoriesBody(category, subcategory) {
/*
 * Gets the Sub Menus Table
 */
   getMenu = 1;
   if (category.length==0) {
      getMenu = 0;
   }
   if (subcategory.length==0) {
      getMenu = 0;
   }

   branch = MyForm.Branch.selectedIndex;
   branch = MyForm.Branch.options[branch].text;
   brand  = MyForm.Brand.selectedIndex;
   brand  = MyForm.Brand.options[brand].text;

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainBody").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_get_data.php?SubCategory="+subcategory+"&Category="+category+"&Branch="+branch+"&Brand="+brand+"&Type=SubMenuBodyCategory";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getEquipmentBody(equipment) {
/*
 * Gets the Sub Menus Table
 */
   getMenu = 1;
   if (equipment.length==0) {
      getMenu = 0;
   }

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainBody").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_get_data.php?Equipment="+equipment+"&Type=BodyEquipment";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getEquipmentBody2(category,subcategory,equipment) {
/*
 * Gets the Sub Menus Table
 */
   getMenu = 1;
   if (category.length==0) {
      getMenu = 0;
   }
   if (subcategory.length==0) {
      getMenu = 0;
   }
   if (equipment.length==0) {
      getMenu = 0;
   }

   branch = MyForm.Branch.selectedIndex;
   branch = MyForm.Branch.options[branch].text;
   brand  = MyForm.Brand.selectedIndex;
   brand  = MyForm.Brand.options[brand].text;

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("SubMenus").innerHTML=xmlhttp.responseText;
         getEquipmentBody(equipment);
      }
   }
   sendString = "ajax_get_data.php?SubCategory="+subcategory+"&Category="+category+"&Branch="+branch+"&Brand="+brand+"&Type=SubMenuSubCategory";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function showLogin() {
   
   if (parseInt(navigator.appVersion)>3) {
      if (navigator.appName=="Netscape") {
         winW = window.innerWidth;
         winH = window.innerHeight;
      }
      if (navigator.appName.indexOf("Microsoft")!=-1) {
         winW = document.body.offsetWidth;
         winH = document.body.offsetHeight;
      }
   }

   document.getElementById("TransparentDiv").style.left   = 0;
   document.getElementById("TransparentDiv").style.top    = 0;
   document.getElementById("TransparentDiv").style.width  = winW -10;
   document.getElementById("TransparentDiv").style.height = winH -10;
   document.getElementById("LoginDiv").style.left   = 0;
   document.getElementById("LoginDiv").style.top    = 0;
   document.getElementById("LoginDiv").style.width  = winW -10;
   document.getElementById("LoginDiv").style.height = winH -10;


   getMenu = 1;
   if (getMenu == 0) {
      document.getElementById("LoginDiv").innerHTML="<font style='color : #888888'>... Invalid Selection ...</font>";
      return;
   } else {
       document.getElementById("LoginDiv").innerHTML="<font style='color : #888888'>... Retreiving Data ...</font>";
   }
   branch = MyForm.Branch.selectedIndex;
   branch = MyForm.Branch.options[branch].text;
   brand  = MyForm.Brand.selectedIndex;
   brand  = MyForm.Brand.options[brand].text;

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("LoginDiv").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_get_data.php?&Type=GetLogin";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function forgotPassword() {
   ClientUserCode = document.getElementById("Login").value;
   if (parseInt(navigator.appVersion)>3) {
      if (navigator.appName=="Netscape") {
         winW = window.innerWidth;
         winH = window.innerHeight;
      }
      if (navigator.appName.indexOf("Microsoft")!=-1) {
         winW = document.body.offsetWidth;
         winH = document.body.offsetHeight;
      }
   }

   document.getElementById("TransparentDiv").style.left   = 0;
   document.getElementById("TransparentDiv").style.top    = 0;
   document.getElementById("TransparentDiv").style.width  = winW -10;
   document.getElementById("TransparentDiv").style.height = winH -10;
   document.getElementById("LoginDiv").style.left   = 0;
   document.getElementById("LoginDiv").style.top    = 0;
   document.getElementById("LoginDiv").style.width  = winW -10;
   document.getElementById("LoginDiv").style.height = winH -10;

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("LoginDiv").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_get_data.php?Type=ForgotPassword&Login=" + ClientUserCode;
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function resetPassword() {
   ClientUserCode = document.getElementById("Login").value;
   if (parseInt(navigator.appVersion)>3) {
      if (navigator.appName=="Netscape") {
         winW = window.innerWidth;
         winH = window.innerHeight;
      }
      if (navigator.appName.indexOf("Microsoft")!=-1) {
         winW = document.body.offsetWidth;
         winH = document.body.offsetHeight;
      }
   }

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         var response    = xmlhttp.responseText;
         var responseArr = response.split("~");
         var responseErr = responseArr[0];
         var responseMsg = responseArr[1];
         var responsePrc = responseArr[2];

         if (responseErr > 0) {
            alert(responseMsg);
         } else {
            showLogin();
         }
      }
   }
   sendString = "ajax_get_data.php?Type=ResetPassword&Login=" + ClientUserCode;
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function resetPasswordClient() {
   Password = document.getElementById("NewPassword").value;
   if (Password == "") {
       alert("No Password Entered");
       return;
   }
   document.getElementById("ResetButton").innerHTML = "<font style='color : #FF5555'>... Please Wait Updating Password ...</font>";

   if (parseInt(navigator.appVersion)>3) {
      if (navigator.appName=="Netscape") {
         winW = window.innerWidth;
         winH = window.innerHeight;
      }
      if (navigator.appName.indexOf("Microsoft")!=-1) {
         winW = document.body.offsetWidth;
         winH = document.body.offsetHeight;
      }
   }

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         var response    = xmlhttp.responseText;
         var responseArr = response.split("~");
         var responseErr = responseArr[0];
         var responseMsg = responseArr[1];
         var responsePrc = responseArr[2];

         if (responseErr > 0) {
            alert(responseMsg);
         } else {
            getClientBody();
         }
      }
   }
   sendString = "ajax_get_data.php?Type=ResetPasswordClient&Password=" + Password;
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function showPasswordScreen() {
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainBody").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_get_data.php?Type=ShowPasswordScreen";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function hideLogin() {
   document.getElementById("TransparentDiv").style.left   = -10000;
   document.getElementById("TransparentDiv").style.top    = 0;
   document.getElementById("TransparentDiv").style.width  = 5;
   document.getElementById("TransparentDiv").style.height = 5;
   document.getElementById("LoginDiv").style.left   = -10000;
   document.getElementById("LoginDiv").style.top    = 0;
   document.getElementById("LoginDiv").style.width  = 5;
   document.getElementById("LoginDiv").style.height = 5;
   return
}
function clientLogin() {
   ClientUserCode = document.getElementById("Login").value;
   ClientPassword = document.getElementById("Password").value;

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         var response    = xmlhttp.responseText;
         var responseArr = response.split("~");
         var responseErr = responseArr[0];
         var responseMsg = responseArr[1];
         var responseUsr = responseArr[2];

         switch (responseErr) {
            case "0":
               document.getElementById("welcome").innerHTML = "Welcome<br>" + responseUsr + "<br><br> <a href='#' onclick='clientLogout()' class='white'>Click here to logout</a>"
               hideLogin();
               break;
             case "1":
               alert(responseMsg);
               break;
          }
      }
   }
   sendString = "ajax_get_data.php?Type=Login&Client=" + ClientUserCode + "&Password=" + ClientPassword;
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function bookMe() {
   checkBooking();
   if (IcalendarDate == "Select") {        
      document.getElementById("Error").innerHTML = "<font style='color : #FF4444'><strong>You Need To Select A Collection Date</strong></font><br>";
      return;
   }
   Error         = document.getElementById("Error").innerHTML;
   if (Error != "") { return;}
   if (IcalendarDate == "Select") { return; }
   EquipmentKey  = document.getElementById("ItemKey").innerHTML;
   IcalendarDate = document.getElementById("IPickUpDate").innerHTML;
   NoBookingDays = document.getElementById("BookingDays").value;
// Execute Booking Script
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         var response    = xmlhttp.responseText;
         var responseArr = response.split("~");
         var responseErr = responseArr[0];
         var responseMsg = responseArr[1];
         document.getElementById("Error").innerHTML = "<font style='color : #33FF33'><strong>" + responseMsg + "</strong></font><br>";
         getClientShoppingBasketSide();
      }
   }
   sendString = "ajax_orders.php?Type=BookEquipment&EquipmentKey="+EquipmentKey+"&BookingDate="+IcalendarDate+"&NoBookingDays="+NoBookingDays;
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function bookDate(IcalendarDate, calendarDate) {
   document.getElementById("PickUpDate").innerHTML = calendarDate;
   document.getElementById("IPickUpDate").innerHTML = IcalendarDate;
   checkBooking();
}
function bookDays() {
   checkBooking();
}
function checkBooking() {
   document.getElementById("Error").innerHTML = "";
   EquipmentKey  = document.getElementById("ItemKey").innerHTML;
   IcalendarDate = document.getElementById("IPickUpDate").innerHTML;
   if (IcalendarDate == "Select") { return; }
   NoBookingDays = document.getElementById("BookingDays").value;
   if (NoBookingDays < 1) {
      document.getElementById("Error").innerHTML = "<font style='color : #FF4444'><strong>You Need To Book For At Least 1 Day</strong></font><br>";
      document.getElementById("BookingDays").value     = "1";
      return;
   }

// Execute Booking Script
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         var response    = xmlhttp.responseText;
         var responseArr = response.split("~");
         var responseErr = responseArr[0];
         var responseMsg = responseArr[1];
         
         if (responseErr > 0) {
            document.getElementById("Error").innerHTML = "<font style='color : #FF4444'><strong>" + responseMsg + "</strong></font><br>";
            document.getElementById("IPickUpDate").innerHTML = "Select";
            document.getElementById("PickUpDate").innerHTML = "Select";
            updateCalendar(EquipmentKey,"0","0");
         } else {
            updateCalendar(EquipmentKey,IcalendarDate,NoBookingDays);
         }

      }
   }
   sendString = "ajax_orders.php?Type=CheckAvailability&EquipmentKey="+EquipmentKey+"&BookingDate="+IcalendarDate+"&NoBookingDays="+NoBookingDays;
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function updateCalendar(EquipmentKey,DateFrom,NoDays) {
// Execute Booking Script
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         var response    = xmlhttp.responseText;
         var responseArr = response.split("~");
         var responseErr = responseArr[0];
         var responseMsg = responseArr[1];
         var responsePrc = responseArr[2];

         if (responseErr > 0) {
            document.getElementById("Error").innerHTML = "<font style='color : #FF4444'><strong>" + responseMsg + "</strong></font><br>";
         } else {
            document.getElementById("calendar").innerHTML = responseMsg;
            document.getElementById("cost").innerHTML = responsePrc;
         }

      }
   }
   sendString = "ajax_orders.php?Type=UpdateCalendar&EquipmentKey="+EquipmentKey+"&BookingDate="+DateFrom+"&NoBookingDays="+NoDays;
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function setDateType(dateType,Equipment) {
   dateTypeId = "DateType" + Equipment;
   document.getElementById(dateTypeId).value = dateType;
}
function showRegistration() {

   if (parseInt(navigator.appVersion)>3) {
      if (navigator.appName=="Netscape") {
         winW = window.innerWidth;
         winH = window.innerHeight;
      }
      if (navigator.appName.indexOf("Microsoft")!=-1) {
         winW = document.body.offsetWidth;
         winH = document.body.offsetHeight;
      }
   }

   document.getElementById("TransparentDiv").style.left   = 0;
   document.getElementById("TransparentDiv").style.top    = 0;
   document.getElementById("TransparentDiv").style.width  = winW -10;
   document.getElementById("TransparentDiv").style.height = 1000;
   document.getElementById("LoginDiv").style.left   = 0;
   document.getElementById("LoginDiv").style.top    = 0;
   document.getElementById("LoginDiv").style.width  = winW -10;
   document.getElementById("LoginDiv").style.height = winH -10;


   getMenu = 1;
   branch = MyForm.Branch.selectedIndex;
   branch = MyForm.Branch.options[branch].text;
   brand  = MyForm.Brand.selectedIndex;
   brand  = MyForm.Brand.options[brand].text;

   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("LoginDiv").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_get_data.php?Type=GetRegistration";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function clientRegister() {
   BusinessName = document.getElementById("BusinessName").value;
   BusinessVatNumber = document.getElementById("BusinessVatNumber").value;
   BusinessRegistrationNumber = document.getElementById("BusinessRegistrationNumber").value;

   PersonTitle = document.getElementById("PersonTitle").value;
   PersonName = document.getElementById("PersonName").value;
   PersonSurname = document.getElementById("PersonSurname").value;
   PersonID = document.getElementById("PersonID").value;
   PersonBirthDate = document.getElementById("PersonBirthDate").value;

   ContactNumberWork = document.getElementById("ContactNumberWork").value;
   ContactNumberHome = document.getElementById("ContactNumberHome").value;
   ContactNumberFax = document.getElementById("ContactNumberFax").value;
   ContactNumberMobile = document.getElementById("ContactNumberMobile").value;
   ContactEmail = document.getElementById("ContactEmail").value;
   ContactEmailAlt = document.getElementById("ContactEmailAlt").value;

   ContactPhyAddr1 = document.getElementById("ContactPhyAddr1").value;
   ContactPhyAddr2 = document.getElementById("ContactPhyAddr2").value;
   ContactPhyAddr3 = document.getElementById("ContactPhyAddr3").value;
   ContactPhyAddr4 = document.getElementById("ContactPhyAddr4").value;

   ContactPostAddr1 = document.getElementById("ContactPostAddr1").value;
   ContactPostAddr2 = document.getElementById("ContactPostAddr2").value;
   ContactPostAddr3 = document.getElementById("ContactPostAddr3").value;
   ContactPostAddr4 = document.getElementById("ContactPostAddr4").value;

   AgreeTerms        = document.getElementById("AgreeTerms").checked;
   SecurityReference = document.getElementById("SecurityReference").value;
   SecurityCode      = document.getElementById("SecurityCode").value;

// Check Data

   var poststr = "BusinessName="  + encodeURI( BusinessName ) +
                 "&BusinessVatNumber=" +  encodeURI( BusinessVatNumber ) +
                 "&BusinessRegistrationNumber=" + encodeURI( BusinessRegistrationNumber )+

                 "&PersonTitle=" + encodeURI( PersonTitle )+
                 "&PersonName=" + encodeURI( PersonName )+
                 "&PersonSurname=" + encodeURI( PersonSurname )+
                 "&PersonID=" + encodeURI( PersonID )+
                 "&PersonBirthDate=" + encodeURI( PersonBirthDate )+

                 "&ContactNumberWork=" + encodeURI( ContactNumberWork )+
                 "&ContactNumberHome=" + encodeURI( ContactNumberHome )+
                 "&ContactNumberFax=" + encodeURI( ContactNumberFax )+
                 "&ContactNumberMobile=" + encodeURI( ContactNumberMobile )+
                 "&ContactEmail=" + encodeURI( ContactEmail )+
                 "&ContactEmailAlt=" + encodeURI( ContactEmailAlt )+

                 "&ContactPhyAddr1=" + encodeURI( ContactPhyAddr1 )+
                 "&ContactPhyAddr2=" + encodeURI( ContactPhyAddr2 )+
                 "&ContactPhyAddr3=" + encodeURI( ContactPhyAddr3 )+
                 "&ContactPhyAddr4=" + encodeURI( ContactPhyAddr4 )+

                 "&ContactPostAddr1=" + encodeURI( ContactPostAddr1 )+
                 "&ContactPostAddr2=" + encodeURI( ContactPostAddr2 )+
                 "&ContactPostAddr3=" + encodeURI( ContactPostAddr3 )+
                 "&ContactPostAddr4=" + encodeURI( ContactPostAddr4 )+

                 "&AgreeTerms=" + encodeURI( AgreeTerms )+
                 "&SecurityReference=" + encodeURI( SecurityReference )+
                 "&SecurityCode=" + encodeURI( SecurityCode );
   
   makePOSTRequest("ajax_get_data.php?Type=Registration", poststr);
}
function makePOSTRequest(url, parameters) {
      document.getElementById("SubmitButton").innerHTML = "<font style='color : #FF5555'>... Busy Submitting ...</font>";
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

      http_request.onreadystatechange = function() {
         if (http_request.readyState==4 && http_request.status==200) {
            var response    = http_request.responseText;
            var responseArr = response.split("~");
            var responseErr = responseArr[0];
            var responseMsg = responseArr[1];
            var responseUsr = responseArr[2];
            switch (responseErr) {
              case "0":
                 document.getElementById("welcome").innerHTML = "Welcome " + responseUsr + "<br> <a href='#' onclick='clientLogout()' class='white'>click here to logout</a>"
                 alert(responseMsg);
                 hideLogin();
                 break;
               case "1":
                  document.getElementById("SubmitButton").innerHTML = "<font style='color : #FF5555'><b>Error Encountered:</b> " + responseMsg + "</font>" +
                                                                      "<table width='600' padding='0' spacing='0' class='equipment' bgColor='#444444'>" +
                                                                      "   <tr height='20' valign='middle'>" +
                                                                      "      <td width='290' class='black' align='right'><input type='submit' Value='Register' class='black_input_100'></td>" +
                                                                      "      <td width='20' class='black' align='right'></td>" +
                                                                      "      <td width='290' class='black' align='left'><input type='reset' Value='Exit' class='black_input_100' onclick='hideLogin()'></td>" +
                                                                      "   </tr>" +
                                                                      "</table>";
                  document.getElementById("SecurityDiv").innerHTML    = responseUsr;
                  break;
               case "2":
                  document.getElementById("SubmitButton").innerHTML = "<font style='color : #FF5555'><b>Error Encountered:</b> " + responseMsg + "</font>" +
                                                                      "<table width='600' padding='0' spacing='0' class='equipment' bgColor='#444444'>" +
                                                                      "   <tr height='20' valign='middle'>" +
                                                                      "      <td width='290' class='black' align='right'><input type='submit' Value='Register' class='black_input_100'></td>" +
                                                                      "      <td width='20' class='black' align='right'></td>" +
                                                                      "      <td width='290' class='black' align='left'><input type='reset' Value='Exit' class='black_input_100' onclick='hideLogin()'></td>" +
                                                                      "   </tr>" +
                                                                      "</table>";
                  break;
               default:
                  alert(responseErr);
            }
         }
      }
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
}
function clientLogout() {
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         location.reload(true);
      }
   }
   sendString = "ajax_get_data.php?Type=Logout";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getClientMenus() {
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainMenus").innerHTML=xmlhttp.responseText;
         getClientSubMenus();
      }
   }
   sendString = "ajax_get_data.php?Type=ClientMainMenu";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getClientSubMenus() {
/*
 * Gets the Sub Menus Table
 */
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("SubMenus").innerHTML=xmlhttp.responseText;
         getClientBody();
      }
   }
   sendString = "ajax_get_data.php?Type=ClientSubMenu";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getClientBody() {
/*
 * Gets the Sub Menus Table
 */
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainBody").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_get_data.php?Type=ClientBody";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getClientShoppingBasket() {
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainMenus").innerHTML=xmlhttp.responseText;
         getClientSubMenusOrders();
      }
   }
   sendString = "ajax_get_data.php?Type=ClientMainMenu";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getClientShoppingBasketSide() {
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("RentalMenu").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_orders.php?Type=ShowBasketSide";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getClientSubMenusOrders() {
/*
 * Gets the Sub Menus Table
 */
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("SubMenus").innerHTML=xmlhttp.responseText;
         getClientOrderBody();
      }
   }
   sendString = "ajax_get_data.php?Type=ClientSubMenuOrders";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getClientOrderBody() {
/*
 * Gets the Sub Menus Table
 */
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainBody").innerHTML=xmlhttp.responseText;
      }
   }
   sendString = "ajax_orders.php?Type=ShowBasket";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function getShoppingBasket() {
/*
 * Gets the Sub Menus Table
 */
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("MainBody").innerHTML=xmlhttp.responseText;
         getClientShoppingBasketSide();
      }
   }
   sendString = "ajax_orders.php?Type=ShowBasket";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function deleteTempItem(RentalKey) {
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         getShoppingBasket();
      }
   }
   sendString = "ajax_orders.php?Type=DeleteTempItem&RentalKey=" + RentalKey;
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
function placeOrder() {
   document.getElementById("OrderButton").innerHTML = "<font style='color : #FF5555'>... Please Wait Placing Order(s) ...</font>";
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   } else {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {
         document.getElementById("OrderButton").innerHTML = "<font style='color : #55FF55'>... Order(s) Placed ...</font>";
         setTimeout(getShoppingBasket(),"4000");
      }
   }
   sendString = "ajax_orders.php?Type=PlaceOrder";
   xmlhttp.open("GET",sendString,true);
   xmlhttp.send();
}
