var ResourceDB     = new Array( ); 
var TotalOrder     = 0; 
var AllOrders      = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var DownLoads      = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var NumItems       = 12;
var ExchangeRate   = 1.65; 
var ShopCartSelect = true;
var FormObject;

function SetOrderString(Value)
            {
              var Str = "&cart_order_id=10373901";
              var OrderTotal = "&total=" + fixFloat(Value, 2);
              document.writeln('<a  href=https://www.2checkout.com/cgi-bin/sbuyers/cartpurchase.2c?sid=103739' + OrderTotal  + Str + '>' + 'Purchase online</a>'); 
             }
			 
function SetOrderStringPurchase(Value)
            {
			// alert("Process purchase function is called at this point");
              var Str = "&cart_order_id=10373901";
              var OrderTotal = "&total=" + fixFloat(Value, 2);
			  //window.location = "https://www.2checkout.com/cgi-bin/sbuyers/cartpurchase.2c?sid=103739" + OrderTotal  + Str;
              //document.writeln('<a               href=https://www.2checkout.com/cgi-bin/sbuyers/cartpurchase.2c?sid=103739' + OrderTotal  + Str + '>' + 'Click HERE to purchase</a>'); 
             }  
			 
function LogicCoderResources(Title, Code, Price, Quantity, ChkOutCode)
          {
           this.Title      = Title; 
           this.Code       = Code; 
           this.Price      = Price; 
           this.Quantity   = Quantity;
           this.ChkOutCode = ChkOutCode; 
           }

function CreateResourceDB()
         {  
          var StoredOrder = GetCookieValue("TotalOrders");

//SetOrderArray(StoredOrder, 1, NumItems);//Place them back in the order array 
          if(StoredOrder != null)
            {
             SetOrderArray(StoredOrder, 1, NumItems);
             for(n = 0; n < NumItems; n++)
               TotalOrder += AllOrders[n];    
             }
			 
ResourceDB[0] = new LogicCoderResources("Structured Programming with BASIC Volume 1", "SBP01", 25.00, AllOrders[0], 1); 
ResourceDB[1] = new LogicCoderResources("Structured Programming with BASIC Volume 2", "SBP02", 15.00, AllOrders[1], 2); 
ResourceDB[2] = new LogicCoderResources("Structured Programming with ANSI C", "SCP01", 25, AllOrders[2], 3); 
ResourceDB[3] = new LogicCoderResources("Object Oriented Programming with ANSI C++", "OCP01", 32.00, AllOrders[3], 4); 
ResourceDB[4] = new LogicCoderResources("Tutorial version of LogicCoder for ANSI C, OS Ms Window. Includes Tutorial manual", "LACWIN01", 55.00, AllOrders[4], 5); 
ResourceDB[5] = new LogicCoderResources("Tutorial version of LogicCoder for ANSI C, OS DOS.  Includes Tutorial manual", "LACDOS02", 25.00, AllOrders[5], 6); 
ResourceDB[6] = new LogicCoderResources("Tutorial version of LogicCoder for BASIC, OS Ms Window. Includes Tutorial manual", "LGBWIN03", 22.00, AllOrders[6], 7); 
ResourceDB[7] = new LogicCoderResources("Tutorial version of LogicCoder for BASIC, OS DOS. Includes Tutorial manual", "LGBDOS04", 22.00, AllOrders[7], 8); 
ResourceDB[8] = new LogicCoderResources("Tutorial version of LogicCoder for ANSI C++, OS Ms Window. Include Tutorial manual", "LCPWIN05", 88.00, AllOrders[8], 9); 
ResourceDB[9] = new LogicCoderResources("Tutorial version of LogicCoder for ANSI C++, OS DOS. Includes Tutorial manual", "LCPDOS06", 38.00, AllOrders[9], 10);
ResourceDB[10] = new LogicCoderResources("Tutorial version of LogicCoder for Visual Basic, OS Ms Window. Includes Tutorial manual", "LVBWIN07", 123.00, AllOrders[10], 11);
ResourceDB[11] = new LogicCoderResources("Tutorial version of LogicCoder for Visual Basic, OS DOS. Includes Tutorial manual", "LVBDOS10", 38.00, AllOrders[11], 12);

//ResourceDB[12] = new LogicCoderResources("Tutorial version of LogicCoder for Pascal, OS Ms //Window. Includes Tutorial manual", "LPSWIN07", 70.00, AllOrders[12]);
//ResourceDB[13] = new LogicCoderResources("Tutorial version of LogicCoder for Pascal, OS DOS. //Includes Tutorial manual", "LPSDOS08", 38.00, AllOrders[13]);
//ResourceDB[14] = new LogicCoderResources("Tutorial version of LogicCoder for Java, OS Ms Window. //Includes Tutorial manual", "LJVWIN09", 75.00, AllOrders[14]);
//ResourceDB[15] = new LogicCoderResources("Tutorial version of LogicCoder for Java, OS DOS. //Includes Tutorial manual", "LJVDOS10", 40.00, AllOrders[15]);
          }

function CheckQuantity( ) 
         { 
          var OrderCookie = FindOrder("Orders");
		  
          if(OrderCookie) 
            { 
             var UserOrders = OrderCookie.split("+"); 
             for(var n = 0; n < UserOrders.length; n++)
                { 
                 var OrderNum = UserOrders[n]; 
                 ResourceDB[n].Quantity = OrderNum; 
                 if(OrderNum.Quantity > 0) 
                   { 
                    TotalOrder++; 
                    }
                 }
             }
           return;
          }

function SetCookie(CookieName, CookieValue, ExpiryDate) 
          { 
           CookieValue = escape(CookieValue); 
           
           if(ExpiryDate == "")
             {
              var NowDate = new Date( );
              NowDate.setMonth(NowDate.getMonth( ) + 2); 
              ExpiryDate = NowDate.toGMTString( );
              }
            document.cookie = CookieName + "=" + CookieValue + ";expires=" + ExpiryDate;
           }

function GetCookieValue(CookieName)
          { 
           var CookieValue = document.cookie; 
           var CookieStartPoint = CookieValue.indexOf(" "+ CookieName + "="); 
       
           if(CookieStartPoint == -1) 
             CookieStartPoint = CookieValue.indexOf(CookieName + "="); 
           if(CookieStartPoint == -1)
             { 
              CookieValue = null; 
              TotalOrder = 0;
              }
           else
             { 
              CookieStartPoint = CookieValue.indexOf("=", CookieStartPoint) + 1; 
              var CookieEndPoint = CookieValue.indexOf(";", CookieStartPoint); 
              if(CookieEndPoint = -1)
                CookieEndPoint = CookieValue.length;
              CookieValue = unescape(CookieValue.substring(CookieStartPoint, CookieEndPoint));
              }
            return CookieValue;
           }

function FindOrder(FindName)
         { 
          var EntireCookie, CookieName, CookieValue; 
          var CookieArray = document.cookie.split("; ");

          for(var n = 0; n < CookieArray.length; n++)
             { 
              EntireCookie = CookieArray[n].split("=");
              CookieName   = EntireCookie[0]; 
              CookieValue  = EntireCookie[1]; 
              if(CookieName == FindName)
                return unescape(CookieValue);
              }
          return null;
          }

function fixFloat(NumValue, BaseTen) 
         { 
          var RoundVal     = Math.round(NumValue*Math.pow(10, BaseTen)); 
          var ConvertedVal = RoundVal/Math.pow(10, BaseTen); 
          var StringVal    = ConvertedVal.toString( ); 
          var DecimalLoc   = StringVal.indexOf(".");

          if(DecimalLoc == .1) 
            { 
             NumDecimals = 2; 
             StringVal +="."; 
             }
          else
            NumDecimals = StringVal.length - DecimalLoc - 1; 
          var PadAmount = BaseTen - NumDecimals; 
          if(PadAmount > 0)
            for(var n = 1; n <= PadAmount; n++) 
               StringVal += "0";
          return StringVal;
          }
		  
function SetUnsetCheckBoxes(TheForm, ControlChkBx)
         {
          var NumElement = 0;
         // alert("The set all values function is called");

          while(NumElement < TheForm.length)
              {
               if((TheForm.elements[NumElement].type == "checkbox")&&(TheForm.elements[NumElement] != ControlChkBx))
                 {
                  if(ControlChkBx.checked)
                    {
                     TheForm.elements[NumElement].checked = true;
                     }
                  else
                   {
                    TheForm.elements[NumElement].checked = false;
                    }
                  }
               NumElement++;
               }
          }
		  
function CheckFormFields1(TheForm, ConctPrompt)
         {  
          var OKFlag      = true; var Type = 1;
          var NumElement  = 0, NextPrompt  = 0; 
          var StartPrompt = "Please enter a value for your ";  
 
          while((NumElement < TheForm.length) && OKFlag)
               {
                if((TheForm.elements[NumElement].type == "password")&& (TheForm.elements[NumElement+1].type == "password"))
                  if(TheForm.elements[NumElement].value != TheForm.elements[NumElement+1].value)
                    {
                     alert("Both password values must match\n Please reenter password values");
                     TheForm.elements[NumElement].focus();
                     OKFlag = false;
                     }
                if(TheForm.elements[NumElement].type == "text"|| TheForm.elements[NumElement].type == "Menu/List")
                  { 
                   if(TheForm.elements[NumElement].value == "")
                     {
                      var PromptMsg = StartPrompt + ConctPrompt[NextPrompt];
                      alert(PromptMsg); 
                      TheForm.elements[NumElement].focus(); 
                      OKFlag = false;
                      }
                   NextPrompt++; 
                   }
                else if(TheForm.elements[NumElement].name == "Countries"|| TheForm.elements[NumElement].name == "Title")
                       if(TheForm.elements[NumElement].value == "0")
                         {
                          alert("Pleae select a values from the list");
                          TheForm.elements[NumElement].focus();
                          OKFlag = false;
                          }
                NumElement++; 
                }
           if(OKFlag)
             {
              h = TheForm.length;
              OKFlag = CheckEmailText(TheForm.elements[6].value);
              if(!OKFlag)
                {
                 alert("There is an error in the format of your email\nPlease reenter value");
                 TheForm.elements[6].focus();
                 }
              else
                {
                window.location = "index.html";
                }
              }
          return OKFlag;  
          }

function CheckFormFields(TheForm, ConctPrompt)
         {  
          var OKFlag      = true; var Type = 1;
          var NumElement  = 0, NextPrompt  = 0; 
          var StartPrompt = "Please enter a value for your ";  
 
          while((NumElement < TheForm.length) && OKFlag)
               { 
                if(TheForm.elements[NumElement].type == "text")
                  { 
                   if(TheForm.elements[NumElement].value == "")
                     {
                      var PromptMsg = StartPrompt + ConctPrompt[NextPrompt];
                      alert(PromptMsg); 
                      TheForm.elements[NumElement].focus(); 
                      OKFlag = false;
                      }
                   NextPrompt++; 
                   }
                else if(TheForm.elements[NumElement].type == "hidden")
                        if(TheForm.elements[NumElement].value == "Order")
                          Type = 2; 
                        else if(TheForm.elements[NumElement].value == "OnlinePurchase")
                               Type = 3;
                NumElement++; 
                }
           if(OKFlag)
             { 
              alert("Click the folowing link to comptlete transaction and payment process at 2CheckOut!");
              }
          return OKFlag;  
          }

function CheckEmailText(EmailVal)
         {
          var i = 0, j, OKFlag = true; 
          
          while((i < EmailVal.length)&&(EmailVal.charAt(i) != '@'))     
               i++;
          if(EmailVal.charAt(i) == '@')
            {
             j = EmailVal.length-1;
             while((j > i)&&(EmailVal.charAt(j) != '.'))     
               j--;
             if((EmailVal.length - j) != 4)
               OKFlag = false;
             }
          return(OKFlag);
          }

function CreateURL_OrderString( )
         {
          var NetSale, n, N;
          var OrderIds, ResourcePrice, ResourceTotal, OrderTotal = 0, ResourceNum;
          var HREFStr = "?sid=103739";

          for(n = 0; n < NumItems; n++)
             { 
              ResourceNum = AllOrders[n]; 
              if(ResourceNum > 0)
                { 
                 ResourceNum = AllOrders[n];
                 N = n + 1;
                 HREFStr += "&product_id="+N;
                 NumOrdered = ResourceDB[n].Quantity; 
                 HREFStr += "&quantity=" + NumOrdered;
                 ResourcePrice = ResourceDB[n].Price;
                 ResourceTotal = ResourceNum*ResourcePrice;
                 OrderTotal += parseFloat(ResourceTotal);
                 }
              } 
             HREFStr; 
/* var CheckOutStr = "https://www.2checkout.com/cgi-bin/ccbuyers/purchase.2c?sid=103739&product_id=1&quantity=1&merchant_order_id=test1&demo=Y" */
           LocationStr = HREFStr;
           }  
		   
function mailOrder( )
         { 
          var who = "calbertmcdonald@hotmail.com; //denham@logiccoder.com"; document.order.Email.value; 
          var what = "Customer order"
          var Mess = ""; 

          for(var n = 0; n < ResourceDB.length; n++) 
             { 
              ResourceNum = ResourceDB[n].Quantity; 
              if(ResourceNum > 0)
                { 
                 Mess += "Product Code: " + ResourceDB[n].Code + "  " + "\n"; 
                 Mess += "Description: " + ResourceDB[n].Title + "  " + "\n"; 
                 Mess += "Quantity Ordered: " + ResourceDB[n].Quantity + "  " + "\n"; 
                 Mess += "Price: " + ResourceDB[n].Price + "   " + "\n";
                 Mess += " ********** **********  ********** ********** ********** **********";
                 }  
               }
              Mess += "Customer Name: "          + document.order.FirstName.value        + "  " + document.order.LastName.value +"\n   ";  
              Mess += "Work EMail: "             + document.order.WorkEMail.value        + "   ";  
              Mess += "Location Address: "       + document.order.Address.value          + "   ";  
              Mess += "State/Province Address: " + document.order.Province.value         + "   ";  
              Mess += "City Address: "           + document.order.City.value             + "   ";  
              Mess += "Post Code: "              + document.order.PostCode.value         + "   ";  
              Mess += "Country Address: "        + document.order.selectCountry.value    + "   ";  
              Mess += "Home Telephone Number: "  + document.order.ContactTelephone.value + "   ";  
              Mess += "Personal EMail: "         + document.order.PersonalEMail.value    + "   ";  
              Mess += "Method of Payment: "      + document.order.PaymentMethod.value    + "   ";  

              parent.location.href='mailto: '+who+'?subject='+what+'&body='+Mess;
              window.location = "ShopCart.htm"
              }

function GetDownLoads(TheForm)
         {
          var i =  0, j, OKFlag = 1;

          while(i < TheForm.length)
               {
                 if(TheForm.elements[i].type == "checkbox")
                  if(TheForm.elements[i].checked == true)
                    DownLoads[i] = 1; //Do some thing to select the corresponding download file
                  else
                    DownLoads[i] = 0;
                i++;
               }
          for(j = 0; j < DownLoads.length; j++)
             {
              if(DownLoads[j] == 1)
                {
                 switch(j)
                       {
                        case 0:
                        alert("Download not available as yet\nCheck back within a few days time");
                        //window.location = "..Downloads\DownLoads.zip";   //LogicCoder for ANSI C under DOS
                        break;
                        case 1:
                        window.location = "..Downloads\DownLoads.zip";      //LogicCoder for BASIC under DOS
                        break;
                        case 2:
                        alert("Download not available as yet\nCheck back within a few days time");
                        //window.location = "..Downloads\DownLoads.zip";     //LogicCoder for VB under DOS
                        break;
                        case 3:
                        window.location = "..Downloads\LogicCoderTutorialDOSVer00.zip"; //Tutorial for BASIC under DOS
                        break;
                        case 4:
                        window.location = "..Downloads\SortMergeDownloads.zip"; //Kronrod's Sort/merge algorithms
                        break;
                        case 5:
                        alert("Download not available as yet\nCheck back within a few days time");
                        //window.location = "..Downloads\.htm";                //LogicCoder for C under Ms Win
                        break;
                        case 6:
                        alert("Download not available as yet\nCheck back within a few days time");
                        //window.location = "..Downloads\.htm";                  //Sample flowcharts
                        break;
                        case 7:
                        window.location = "..Downloads\LogicCoderMenusforDOS.zip"; //LogicCoder User Reference manual
                        break;
                        case 8:
                        window.location = "..Downloads\TechnicalInfo.zip";         //LogicCoder Technical Reference manual
                        break;
                        }
                 }
              }
          }

function addResource(ResourceCode) 
          {
           for(var n = 0; n < ResourceDB.length; n++)
              { 
               if(ResourceDB[n].Code == ResourceCode)
                 { 
                  var NumOrdered = ResourceDB[n].Quantity; 
                  NumOrdered++;
                  ResourceDB[n].Quantity = NumOrdered; 
                  break;
                  }
               } 
           var Ordered = " "; 
           for(var n = 0; n < ResourceDB.length; n++) 
              { 
               Ordered += ResourceDB[n].Quantity;
               if(n < ResourceDB.length - 1)
                 Ordered += "+";
               }
           var OrderCookie = "Orders = " + Ordered;
           document.cookie = OrderCookie;
           window.location = "ShopCart.htm";
           }

function GetNumberAt(Start, SourcePtr)
         { 
	      var i = 0, j = Start, L = SourcePtr.length;
          var NumStr       = new Array(10);
          var SourceString = new String(SourcePtr);
          var CharPtr      = new String(", ");

	  while((SourceString.charAt(j) != CharPtr.charAt(0)) && (j < L))
	       { 
            NumStr[i] = SourceString.charAt(j);
            j++; i++;
            }
	  return parseInt(NumStr);
      }

function FindCharacter(WhatChar, Start, SourcePtr)
	 {
	  var j = Start, L = SourcePtr.length;
          var SourceStr = new String(SourcePtr);
          var CharPtr   = new String(WhatChar);

	  while((SourceStr.charAt(j) != CharPtr.charAt(0)) && (j < L))
                 j++;
	  return j;
	  }  

function SetOrderArray(OrderStr, Code, Length)
         { 
          var i, j = 0, n, N = 0, FindChar = ",,"; 

          for(n = 0; n < Length; n++)
             { 
              if(Code > 0)
                {
                 i = FindCharacter(FindChar, j, OrderStr) + 1;
                 N = GetNumberAt(i, OrderStr); 
                 if(isNaN(N))
                   AllOrders[n] = 0;
                 else
                   AllOrders[n] = N;
                 j = i;
                 }
               else
                 AllOrders[n]   = 0;
              }
          }

function AddItemToShopCart(ItemCode, Num, View) 
          { 
           var n = 0; 
           var StoredOrder = GetCookieValue("TotalOrders"); 

          if(StoredOrder != null)
            SetOrderArray(StoredOrder, 1, ResourceDB.length); 
          while((n < ResourceDB.length)&&(ItemCode != ResourceDB[n].Code))
               n++;              
          if(ItemCode == ResourceDB[n].Code)
            {
             ResourceDB[n].Quantity += Num; 
             AllOrders[n] += Num;
             }
          for(n = 0; n < ResourceDB.length; n++)
             TotalOrder += AllOrders[n];
          var Ordered = ",";

          for(n = 0; n < ResourceDB.length; n++)
             {
              if(AllOrders[n] > 0)
                Ordered += AllOrders[n] + ",";
              else
                Ordered += "0" + ",";
              }
          SetCookie("TotalOrders", Ordered, "");
          if(View == false) 
            window.location = "ShopCart.htm";
          }

function SetOrderTable(Value, DocFieldName, DocFieldChkBx, n)
         { 
          var UserValue = Value; 
          var i;
          var ItemCode  = ResourceDB[n].Code;                

          if(isNaN(Value))
            {
             alert("Retype quantity value.\nThis must be a number between 1 and 99"); 
             DocFieldName.value = 1;
             DocFieldName.focus();
             }
          else if(!ShopCartSelect)
                 {
                  if(UserValue > 0) 
                    {
                     for(i = 0; i < UserValue; i++)
                        AddItemToShopCart(ItemCode, 1, false); 
                     DocFieldChkBx.checked = true;
                     }
                  else
                    {
                     DocFieldName.value    = 0;
                     DocFieldChkBx.checked = false;
                     }
                  }
               else if(UserValue > 0)
                      { 
                       //alert("Value been added to shop cart");
                       for(i = 0; i < UserValue; i++)
                          AddItemToShopCart(ItemCode, 1, true); 
                       DocFieldChkBx.checked = true;
                       }
          }

function SetOrderValue(DocFieldName1, DocFieldName2, n)
         {
          var ItemCode = ResourceDB[n].Code;                

          if(!ShopCartSelect)
            {
             if(DocFieldName2.checked == true)
               {
                DocFieldName1.value   = 1;
                AddItemToShopCart(ItemCode, 1, false); 
                }
             else 
               {
                DocFieldName1.value = 0;
                deleteOrder(ItemCode, false);
                }
             }
           else if(DocFieldName2.checked == true)
                  {
                   DocFieldName1.value   = 1;
                   AddItemToShopCart(ItemCode, 1, true);
                   }
                else
                  {
                   DocFieldName1.value   = 0;
                   deleteOrder(ItemCode, true);
                   }
          }

function ViewShoppingCartSummary(TheForm)
         {
          var i, j, Value, ItemCode; 

          deleteAll( ); //Delete all existing orders
          for(i = 0; i < NumItems; i++)
             {
              //alert("Number of items in shop cart = " + NumItems);
              ItemCode = ResourceDB[i].Code;
              if(TheForm[i].type == "text")
                {
                 Value = TheForm[i].value;
                 if(Value > 0)
                   for(j = 0; j < Value; j++)
                      AddItemToShopCart(ItemCode, 1, true); 
                 }
              }
          window.location = "ShopCart.htm";
          }

function deleteOrder(ResourceID, View) 
          { 
           TotalOrder = 0; 
           var n;

           if((ResourceID >= 0)&&(ResourceID <= ResourceDB.length-1))
             { 
              var StoredOrder = GetCookieValue("TotalOrders");  

              if(StoredOrder != null)
                {
                 SetOrderArray(StoredOrder, 1, ResourceDB.length); 
                 TotalOrder -= AllOrders[ResourceID];
                 AllOrders[ResourceID] = 0;  
                 ResourceDB[ResourceID].Quantity = 0; 
                 }
              } 
           var Ordered = ",";
           for(n = 0; n < ResourceDB.length; n++) 
              {
               if(AllOrders[n] > 0)
                 Ordered = Ordered + AllOrders[n] + ",";  
               else
                 Ordered = Ordered + "0" + ","; 
               }
           SetCookie("TotalOrders", Ordered, ""); 
           if(View == false)
             window.location = "ShopCart.htm";
           }
		   
function deleteOrder(ResourceID, View) 
          { 
           TotalOrder = 0; 
           var n;

           if((ResourceID >= 0)&&(ResourceID <= ResourceDB.length-1))
             { 
              var StoredOrder = GetCookieValue("TotalOrders");  

              if(StoredOrder != null)
                {
                 SetOrderArray(StoredOrder, 1, ResourceDB.length); 
                 TotalOrder -= AllOrders[ResourceID];
                 AllOrders[ResourceID] = 0;  
                 ResourceDB[ResourceID].Quantity = 0; 
                 }
              } 
           var Ordered = ",";
           for(n = 0; n < ResourceDB.length; n++) 
              {
               if(AllOrders[n] > 0)
                 Ordered = Ordered + AllOrders[n] + ",";  
               else
                 Ordered = Ordered + "0" + ","; 
               }
           SetCookie("TotalOrders", Ordered, ""); 
           if(View == false)
             window.location = "ShopCart.htm";
           }
		   

function deleteAll( ) 
          { 
           for(var n = 0; n < ResourceDB.length; n++) 
              { 
               AllOrders[n] = 0;  
               ResourceDB[n].Quantity = 0; 
               }

           var Ordered = ",";
           for(n = 0; n < ResourceDB.length; n++) 
              {
               if(AllOrders[n] > 0)
                 Ordered = Ordered + AllOrders[n] + ",";  
               else
                 Ordered = Ordered + "0" + ","; 
               }
           SetCookie("TotalOrders", Ordered, ""); 
           location.reload( );
           } 

//1st Menu
var AboutLogiccoderMenuItems = new Array();

AboutLogiccoderMenuItems[0]     = new Array();
AboutLogiccoderMenuItems[0][0] = "AboutLogiccoder";
AboutLogiccoderMenuItems[0][1] = "AboutLogicCoder.htm";
AboutLogiccoderMenuItems[0][2] = "About LogicCoder";

AboutLogiccoderMenuItems[1]     = new Array();
AboutLogiccoderMenuItems[1][0] = "WhatLogiccoderDo";
AboutLogiccoderMenuItems[1][1] = "WhatLogicCoderDoes.htm";
AboutLogiccoderMenuItems[1][2] = "What LogicCoder does?";

AboutLogiccoderMenuItems[2]     = new Array();
AboutLogiccoderMenuItems[2][0] = "Background";
AboutLogiccoderMenuItems[2][1] = "BackGrndInformation.htm";
AboutLogiccoderMenuItems[2][2] = "Background to LogicCoder";

AboutLogiccoderMenuItems[3]     = new Array();
AboutLogiccoderMenuItems[3][0] = "SystemRequirements";
AboutLogiccoderMenuItems[3][1] = "FlowchartSyst.html";
AboutLogiccoderMenuItems[3][2] = "System Requirement";

AboutLogiccoderMenuItems[4]     = new Array();
AboutLogiccoderMenuItems[4][0] = "SampleScreens";
AboutLogiccoderMenuItems[4][1] = "ScreenShots.htm";
AboutLogiccoderMenuItems[4][2] = "Sample screen-shots";

AboutLogiccoderMenuItems[5]     = new Array();
AboutLogiccoderMenuItems[5][0] = ">OnlineLearn";
AboutLogiccoderMenuItems[5][1] = "LogicCoderTutorial.htm";
AboutLogiccoderMenuItems[5][2] = ">> Online tutorials";

AboutLogiccoderMenuItems[6]     = new Array();
AboutLogiccoderMenuItems[6][0] = "SamplePrograms";
AboutLogiccoderMenuItems[6][1] = "SampleProgramProblems.htm";
AboutLogiccoderMenuItems[6][2] = "Computer program problems";

AboutLogiccoderMenuItems[7]     = new Array();
AboutLogiccoderMenuItems[7][0] = "ProgramFlowcharts";
AboutLogiccoderMenuItems[7][1] = "AboutFlowcharting.htm";
AboutLogiccoderMenuItems[7][2] = "About program flowcharts";

AboutLogiccoderMenuItems[8]     = new Array();
AboutLogiccoderMenuItems[8][0] = "AboutLogicExtractor";
AboutLogiccoderMenuItems[8][1] = "AboutLogicExtractor.htm";
AboutLogiccoderMenuItems[8][2] = "About LogicExtractor";

AboutLogiccoderMenuItems[9]     = new Array();
AboutLogiccoderMenuItems[9][0] = "CodeFromFlowchart";
AboutLogiccoderMenuItems[9][1] = "SampleExcelFlowcharts.htm";
AboutLogiccoderMenuItems[9][2] = "Code from flowchart";


// Second menu
var LogicExtractMenuItems = new Array();

LogicExtractMenuItems[0]     = new Array();
LogicExtractMenuItems[0][0] = "AboutLogicExtractor";
LogicExtractMenuItems[0][1] = "AboutLogicExtractor.htm";
LogicExtractMenuItems[0][2] = "What is LogicExtractor?";

LogicExtractMenuItems[1]     = new Array();
LogicExtractMenuItems[1][0] = "CodeQuality";
LogicExtractMenuItems[1][1] = "QualityAssurane.htm";
LogicExtractMenuItems[1][2] = "Code Quality Assurance";

LogicExtractMenuItems[2]     = new Array();
LogicExtractMenuItems[2][0] = "CodeLanguageTranslate";
LogicExtractMenuItems[2][1] = "CodeLanguageTranslation.htm";
LogicExtractMenuItems[2][2] = "Code language translation";

LogicExtractMenuItems[3]     = new Array();
LogicExtractMenuItems[3][0] = "CodeReverseEngineer";
LogicExtractMenuItems[3][1] = "ReverseEngineering.htm"; 
LogicExtractMenuItems[3][2] = "Code reverse engineering";

LogicExtractMenuItems[4]     = new Array();
LogicExtractMenuItems[4][0] = "FlowchartAndCode";
LogicExtractMenuItems[4][1] = "SampleExcelFlowcharts.htm";
LogicExtractMenuItems[4][2] = "Flowcharts and source code";

LogicExtractMenuItems[5]     = new Array();
LogicExtractMenuItems[5][0] = "SampleFlowcharts";
LogicExtractMenuItems[5][1] = "SampleFlowcharts.htm"; 
LogicExtractMenuItems[5][2] = "Sample flowcharts";

LogicExtractMenuItems[6]     = new Array();
LogicExtractMenuItems[6][0] = "FlowchartFromCode";
LogicExtractMenuItems[6][1] = "SampleExcelFlowcharts.htm"; 
LogicExtractMenuItems[6][2] = "Flowchart from code";


//Third menu
var DownloadMenuItems = new Array();

DownloadMenuItems[0]     = new Array();
DownloadMenuItems[0][0] = "LogicCoderTutVer";
DownloadMenuItems[0][1] = "DownLoaderContact.htm"; //DownLoaderDetail.htm
DownloadMenuItems[0][2] = "Trial version of LogicCoder";

DownloadMenuItems[1]     = new Array();
DownloadMenuItems[1][0] = "LogicCoderTutorial";
DownloadMenuItems[1][1] = "Downloads/UseLogicCoder.pdf"; 
DownloadMenuItems[1][2] = "LogicCoder Tutorial";

DownloadMenuItems[2]     = new Array();
DownloadMenuItems[2][0] = "SortAlgorithms";
DownloadMenuItems[2][1] = "DownLoadSortingInfo.htm";
DownloadMenuItems[2][2] = "Sorting/merge Algorithms";


// fourth menu
var ServicesMenuItems = new Array();

ServicesMenuItems[0]     = new Array();
ServicesMenuItems[0][0] = "AboutOnlineService";
ServicesMenuItems[0][1] = "OnlineServices.htm";
ServicesMenuItems[0][2] = "About our services";

ServicesMenuItems[1]     = new Array();
ServicesMenuItems[1][0] = "ServiceRegister";
ServicesMenuItems[1][1] = "CompanyRegistrationForm.htm"; 
ServicesMenuItems[1][2] = "Register to use service";

ServicesMenuItems[2]     = new Array();
ServicesMenuItems[2][0] = "Partnership";
ServicesMenuItems[2][1] = "Partners00.htm"; 
ServicesMenuItems[2][2] = "Our partnership programme";

ServicesMenuItems[3]     = new Array();
ServicesMenuItems[3][0] = "FreeDownload";
ServicesMenuItems[3][1] = "DownLoaderDetail.htm";
ServicesMenuItems[3][2] = "Download LogicCoder free";

ServicesMenuItems[4]     = new Array();
ServicesMenuItems[4][0] = "StandardFlowchart";
ServicesMenuItems[4][1] = "MoreSampleFlowcharts.htm";
ServicesMenuItems[4][2] = "More sample flowcharts"; 

ServicesMenuItems[5]     = new Array();
ServicesMenuItems[5][0] = "OnlineShop";
ServicesMenuItems[5][1] = "ResourceStore.htm";
ServicesMenuItems[5][2] = "Shop online"; 

ServicesMenuItems[6]     = new Array();
ServicesMenuItems[6][0] = "ProgrammingBooks";
ServicesMenuItems[6][1] = "BooksDetail.htm";
ServicesMenuItems[6][2] = "Programming books"; 

ServicesMenuItems[7]     = new Array();
ServicesMenuItems[7][0] = "FreeCodeTranslation";
ServicesMenuItems[7][1] = "FileUpload.htm";
ServicesMenuItems[7][2] = "Translate code to flowchart free"; 

ServicesMenuItems[8]     = new Array();
ServicesMenuItems[8][0] = "ContactUs";
ServicesMenuItems[8][1] = "ContactUs.htm";
ServicesMenuItems[8][2] = "How to contact us"; 


// Fifth menu
var SortingMenuItems = new Array();

SortingMenuItems[0]     = new Array();
SortingMenuItems[0][0] = "TheSrtingProblem";
SortingMenuItems[0][1] = "AboutSorting.htm";
SortingMenuItems[0][2] = "The Sorting Problem";

SortingMenuItems[1]     = new Array();
SortingMenuItems[1][0] = "MergeSort";
SortingMenuItems[1][1] = "MergeInfo.htm"; 
SortingMenuItems[1][2] = "Using merge to sort";

SortingMenuItems[2]     = new Array();
SortingMenuItems[2][0] = "KronrodTechnique";
SortingMenuItems[2][1] = "KrondInfo.htm"; 
SortingMenuItems[2][2] = "Kronrod's merge technique";

SortingMenuItems[3]     = new Array();
SortingMenuItems[3][0] = "BestMerge";
SortingMenuItems[3][1] = "BestMergeInfo.htm";
SortingMenuItems[3][2] = "The best merge algorithm";

SortingMenuItems[4]     = new Array();
SortingMenuItems[4][0] = "Analyse2DSort";
SortingMenuItems[4][1] = "TwoDimensionalSortInfo.htm";
SortingMenuItems[4][2] = "Analysis of 2-D sorting"; 

SortingMenuItems[5]     = new Array();
SortingMenuItems[5][0] = "OtherSortInfo";
SortingMenuItems[5][1] = "OthertMergeInfo.htm";
SortingMenuItems[5][2] = "O(n) move optimum sort"; 

SortingMenuItems[6]     = new Array();
SortingMenuItems[6][0] = "DownloadSortInfo";
SortingMenuItems[6][1] = "DownLoadSortingInfo.htm";
SortingMenuItems[6][2] = "Download information"; 


// Sixth menu
var OnlineLearnMenuItems = new Array();

OnlineLearnMenuItems[0]     = new Array();
OnlineLearnMenuItems[0][0] = "ProgramFlowcharts";
OnlineLearnMenuItems[0][1] = "FlowchartTutorial00.htm";
OnlineLearnMenuItems[0][2] = "Program flowcharts";

OnlineLearnMenuItems[1]     = new Array();
OnlineLearnMenuItems[1][0] = "TheRules";
OnlineLearnMenuItems[1][1] = "FlowchartTutorial01.htm"; 
OnlineLearnMenuItems[1][2] = "Understanding the rules";

OnlineLearnMenuItems[2]     = new Array();
OnlineLearnMenuItems[2][0] = "ExampleProblem";
OnlineLearnMenuItems[2][1] = "FlowchartTutorial02.htm"; 
OnlineLearnMenuItems[2][2] = "Example program solution";

OnlineLearnMenuItems[3]     = new Array();
OnlineLearnMenuItems[3][0] = "Introduction";
OnlineLearnMenuItems[3][1] = "LogicCoderTutorial00.htm";
OnlineLearnMenuItems[3][2] = "Introduction to LogicCoder";

OnlineLearnMenuItems[4]     = new Array();
OnlineLearnMenuItems[4][0] = "BuildingAFlowchart";
OnlineLearnMenuItems[4][1] = "LogicCoderTutorial01.htm";
OnlineLearnMenuItems[4][2] = "Building a flowchart"; 

OnlineLearnMenuItems[5]     = new Array();
OnlineLearnMenuItems[5][0] = "Editing";
OnlineLearnMenuItems[5][1] = "LogicCoderTutorial02.htm";
OnlineLearnMenuItems[5][2] = "Editing and coding"; 

OnlineLearnMenuItems[6]     = new Array();
OnlineLearnMenuItems[6][0] = "Abstraction";
OnlineLearnMenuItems[6][1] = "LogicCoderTutorial03.htm";
OnlineLearnMenuItems[6][2] = "Abstracting complex logic"; 


function createMenu(menuName, menuItems)
         {
               var divHTML = '<DIV ID="' + menuName + 'MenuDiv" CLASS="DivMenu"';
               divHTML = divHTML + ' onmouseout="return hideMenu1(this)">';

               var tableHTML = '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1 ID="' + menuName + 'Table">';
               var tableRowHTML = "";
               var rowCount;
               var totalNoRows = menuItems.length;
               for(rowCount = 0; rowCount < totalNoRows; rowCount++)
                  {
                   if(menuItems[rowCount][0].charAt(0) == '>')
                    {
                     var L         = menuItems[rowCount][0].length;
                     var Name = menuItems[rowCount][0].substring(1, L);

                     tableRowHTML = tableRowHTML + '<TR><TD ID="' + menuName + Name + '" RollOver RollOut';
                     tableRowHTML = tableRowHTML + ' onclick="goPage(\'' + menuItems[rowCount][1] + '\')"';
                     tableRowHTML = tableRowHTML + ' onMouseOver="return showMenu(' + Name + 'MenuDiv,' +  ' 250,  130, \' '+  menuName + Name + '\' )" onMouseOut="return hideMenu(' + Name + 'MenuDiv, ' + '\' ' + menuName + Name +'\' )"';
                     tableRowHTML = tableRowHTML + 'CLASS="TDMenu">' + menuItems[rowCount][2] + '</TD></TR>'; 
                     }
                  else
                     {
                      tableRowHTML = tableRowHTML + '<TR><TD ID="' + menuName + menuItems[rowCount][0] + '" RollOver RollOut';
                      tableRowHTML = tableRowHTML + ' onclick="goPage(\'' + menuItems[rowCount][1] + '\')"';
                      tableRowHTML = tableRowHTML + 'CLASS="TDMenu">' + menuItems[rowCount][2] + '</TD></TR>'; 
                      }
                   }
              return divHTML + tableHTML + tableRowHTML + '</TABLE></DIV>';
              }

function showMenu(menuToShow, X, Y, SourceID)
  {
   var srcElement = event.srcElement;
   var xPos = parseInt(srcElement.offsetLeft) + X;
   var yPos = parseInt(srcElement.offsetTop) + Y; 
  // alert("X value: "+ X);
  // alert("xPos value: "+ xPos);

   menuToShow.style.left     = xPos; 
   menuToShow.style.top     = yPos;
   srcElement.style.bgcolor = "#FAFAFA"; 
   document.getElementById (SourceID).style.color = "red"; 
  }

function hideMenu(menuToHide, SourceID)
        {
         if(event.toElement != menuToHide && menuToHide.contains(event.toElement) == false)
           {
            menuToHide.style.left = -200;
            menuToHide.style.top  = -1000;
            menuToHide.style.vissibility = 'hidden';
            }
         document.getElementById(SourceID).style.color = "black"; 
         }

function hideMenu1(menuToHide)
        {
         if(event.toElement != menuToHide && menuToHide.contains(event.toElement) == false)
           {
            menuToHide.style.left   = -200;
            menuToHide.style.top   = -1000;
            menuToHide.style.vissibility = 'hidden';
            }
       //document.getElementById(SourceID).style.color = "black"; 
         }

function document_onmouseover()
         {
          var srcElement = event.srcElement;

          if(srcElement.tagName == "TD" && typeof(srcElement.RollOver) != "undefined")
            {
             srcElement.style.color = "white";
             srcElement.style.backgroundColor = "darkblue";
             }
          }

function document_onmouseout()
      {
       var srcElement = event.srcElement; 
	   
       if(srcElement.tagName == "TD" && typeof(srcElement.RollOut) != "undefined")
         {
          srcElement.style.color = "darkblue";
          srcElement.style.backgroundColor = "#FAFAFA"; 
          }
      }


function DisplayTutorialPurchaseForm()
          {
           var USPrice, NetVal;
           TotalOrder = 0;

          CreateResourceDB(); 
          document.writeln('<hr>');
          document.writeln('<form name="PurchaseTut" method="post" action="">');
          document.writeln('<table width="100%" border="1" cellspacing="2" cellpadding="0" hspace="0">');
          document.writeln('<tr><td width="70%" bgcolor="#FFCC99"><b>Product Description</b></td>');
          document.writeln('<td width="10%" bgcolor="#FFCC99"><div align="center"><b>Price(US$) </b></div></td>');
          document.writeln('<td width="9%" bgcolor="#FFCC99"><div align="center"><b>Price(£) </b></div></td>');
          document.writeln('<td width="9%" bgcolor="#FFCC99"><div align="left"><b>Selection </b></div></td></tr>');
          for(var n = 4; n < ResourceDB.length; n++) 
             { 
              document.writeln('<tr><td width="70%" bgcolor="##CCFFCC" align="left"><h4>' + ResourceDB[n].Title + '</h4></td>'); 
              USPrice = ExchangeRate*ResourceDB[n].Price;
              NetVal  = fixFloat(USPrice, 2);
              document.writeln('<td width="10%" bgcolor="##CCFFCC" align="center">' + NetVal + '</td>'); 
              document.writeln('<td width="9%" bgcolor="##CCFFCC" align="center">' + ResourceDB[n].Price + '</td>'); 
              document.writeln('<td width="9%" bgcolor="##CCFFCC">Purchase <input type="checkbox" name="checkbox' + n + '" value="checkbox"' + ' onclick="SetTutorialOrderValue(PurchaseTut.checkbox' + n + ', ' + n + ')"' + '></td></tr>'); 
              }
          document.writeln('</table>');
          document.writeln('<a href=ShopCart.htm>'+ '<center> <h1> view Order Summary and checkout</h1> </center></a>'); 
          document.writeln('</form>');
          }

function DisplayBookPurchaseForm()
          {
           var USPrice, NetVal;
           TotalOrder = 0;

          CreateResourceDB(); 
          document.writeln('<hr>');
          document.writeln('<form name="PurchaseTut" method="post" action="">');
          document.writeln('<table width="100%" border="1" cellspacing="2" cellpadding="0" hspace="0">');
          document.writeln('<tr><td width="70%" bgcolor="#FFCC99"><b>Product Description</b></td>');
          document.writeln('<td width="10%" bgcolor="#FFCC99"><div align="center"><b>Price(US$) </b></div></td>');
          document.writeln('<td width="9%" bgcolor="#FFCC99"><div align="center"><b>Price(£) </b></div></td>');
          document.writeln('<td width="9%" bgcolor="#FFCC99"><div align="left"><b>Selection </b></div></td></tr>');
          for(var n = 0; n < 4; n++) 
             { 
              document.writeln('<tr><td width="70%" bgcolor="##CCFFCC" align="left"><h4>' + ResourceDB[n].Title + '</h4></td>'); 
              USPrice = ExchangeRate*ResourceDB[n].Price;
              NetVal  = fixFloat(USPrice, 2);
              document.writeln('<td width="10%" bgcolor="##CCFFCC" align="center">' + NetVal + '</td>'); 
              document.writeln('<td width="9%" bgcolor="##CCFFCC" align="center">' + ResourceDB[n].Price + '</td>'); 
              document.writeln('<td width="9%" bgcolor="##CCFFCC">Purchase <input type="checkbox" name="checkbox' + n + '" value="checkbox"' + ' onclick="SetTutorialOrderValue(PurchaseTut.checkbox' + n + ', ' + n + ')"' + '></td></tr>'); 
              }
          document.writeln('</table>');
          document.writeln('<a href=ShopCart.htm>'+ '<center> <h1> view Order Summary and checkout</h1> </center></a>'); 

          document.writeln('</form>');
          }

function SetTutorialOrderValue(TheFormField, n)
         {
          var ItemCode = ResourceDB[n].Code;                
         
         if(TheFormField.checked == true)
           {
            AddItemToShopCart(ItemCode, 1, true); 
            }
         else if(AllOrders[n] == 1)
                {
                 deleteOrder(ItemCode, true);
                 }
         }

function DisplayOrderForm()
         {
          CreateResourceDB(); 
          if(ShopCartSelect == true) //(TotalOrder > 0)&&(
            document.writeln('<a href=OnlineServices/ShopCart.htm>'+ '<center> <h1> view shopping cart</h1> </center></a>'); 
          else
            document.writeln('Shoping cart is empty.');
          document.writeln('<hr>'); 

          document.writeln('<form name="LstForm" method="post" action="ViewShoppingCartSummary(LstForm)">');
          document.writeln('<tr><td width="15%" bgcolor="#FFCC99"><b>Product Code</b> </td>');
          document.writeln('<td width="54%" bgcolor="#FFCC99"><div align="center"><b>Product Description</b> </div></td>');
          document.writeln('<td width="10%" bgcolor="#FFCC99"><div align="center"><b>Unit Price </b></div></td>');
          document.writeln('<td width="17%" bgcolor="#FFCC99"><div align="left"><b>Make Selection </b></div></td></tr>');
          for(var n = 0; n < ResourceDB.length; n++) 
             { 
              document.writeln('<tr> <td width="15%" bgcolor="#CCFFCC" align="left">' + ResourceDB[n].Code + '</td>');
              document.writeln('<td width="54%" bgcolor="##CCFFCC" align="left"><h4>' + ResourceDB[n].Title + '</h4></td>'); 
              document.writeln('<td width="10%" bgcolor="##CCFFCC" align="center">' + '$'+ ResourceDB[n].Price +'</td>'); 
              document.writeln('<td width="17%" bgcolor="##CCFFCC"><p>Purchase <input type="checkbox" name="checkbox' + n + '"' + 'value="checkbox"' + ' onclick="SetOrderValue(LstForm.textfield' + n + ',LstForm.checkbox' + n + ', ' + n + ')"' + '><br>Quantity'); 
              document.writeln('<input type="text" name="textfield' + n + '"' + 'size="2" maxlength="2" value="0" onblur ="SetOrderTable(LstForm.textfield' + n + '.value, LstForm.textfield' + n + ', LstForm.checkbox' + n + ', ' + n + ')"' + '></p></td></tr>');
              }
          document.writeln('</form>');
          //document.writeln('<a href="javascript:ViewShoppingCartSummary(\'' + LstForm + '\')">' + '<center> <h1> view shopping cart</h1> </center></a>'); 
          }

function DisplayOrderSummary( )
         { 
          var OrderIds, ResourcePrice, ResourceTotal, OrderTotal, ResourceNum;

          CreateResourceDB(); 
          if(TotalOrder == 0)
            for(var n = 0; n < ResourceDB.length; n++)
               TotalOrder += AllOrders[n];

          if(TotalOrder == 0)
            location.replace('ResourceStore.htm');
          var OrderTotal = 0;

          document.writeln('<table width="100%" border="1" cellspacing="2" cellpadding="2" hspace="0">');
          document.writeln('<form name="OrderForm" method="GET" action="">');
          document.writeln('<tr><td width="15%" bgcolor="#FFCC99"><b>Product Code</b> </td>');
          document.writeln('<td width="52%" bgcolor="#FFCC99"><div align="center"><b>Product Description</b> </div></td>');
          document.writeln('<td width="10%" bgcolor="#FFCC99"><div align="center"><b>Quantity </b></div></td>');
          document.writeln('<td width="8%" bgcolor="#FFCC99"><div align="center"><b>Unit Price </b></div></td>');
          document.writeln('<td width="10%" bgcolor="#FFCC99"><div align="center"><b>Total Price </b></div></td></tr>');

          for(var n = 0; n < NumItems; n++)
             {
              ResourceNum = AllOrders[n]; 
              if(ResourceNum > 0)
                {
                 OrderIds += ResourceDB[n].Code + ",";
                 document.writeln('<td width="15%" bgcolor="#FFCC55" align="left">' + ResourceDB[n].Code + '</td>');  
                 document.writeln('<td width="52%" bgcolor="#FFCC55" align="left"><h3>' + ResourceDB[n].Title + '</h3></td>');         
                 document.writeln('<td width="10%" bgcolor="#FFCC55" align="center">' + ResourceDB[n].Quantity +'</td>'); 
                 ResourcePrice = ResourceDB[n].Price;
                 ResourceTotal = ResourceNum*ResourcePrice;
                 OrderTotal += parseFloat(ResourceTotal);
                 document.writeln('<td width="8%" bgcolor="#FFCC55" align-"left">' + '$'+ ResourcePrice + '</td>'); 
                 document.writeln('<td width="10%" bgcolor="#FFCC55" align="left">' +'$' + fixFloat(ResourceTotal, 2) + '</td>'); 
                 document.writeln('<td><a href="javascript:deleteOrder(' + n + ', ' + false + ')">' + 'Delete</a></td></tr>'); 
                 }
              }  
         document.writeln('<tr><td colspan="4" align="right"><b>Subtotal:</b></td>'); 
         document.writeln('<td align="center"><b>$' + fixFloat(OrderTotal, 2) + '</b></td></tr>'); 
         //document.writeln('<tr><td colspan="4" align="right"><b>US$ Equivalent at ' + fixFloat(ExchangeRate, 2) + '</b></td>'); 
         document.writeln('<td align="center"><b>' + fixFloat(ExchangeRate *OrderTotal, 2) + '</b></td></tr>'); 
         TotalOrder = "&total=" + fixFloat(ExchangeRate *OrderTotal, 2);
         document.writeln('</form>');
         document.writeln('</table>');
          }

function DisplayOtherOrderSummary(Type)
         { 
          var n, OrderIds, ResourcePrice, ResourceTotal, OrderTotal, ResourceNum;
          var Start, End;

          CreateResourceDB(); 
          if(TotalOrder == 0)
            for(n = 0; n < ResourceDB.length; n++)
               TotalOrder += AllOrders[n];

          if(TotalOrder == 0)
            if(Type = 0)
              location.replace('PurchaseTutorialVersion.htm');
            else
              location.replace('PurchaseBooks.htm');

          var OrderTotal = 0;
          document.writeln('<table width="100%" border="1" cellspacing="2" cellpadding="2" hspace="0">');
          document.writeln('<form name="OrderForm" method="GET" action="">');
          document.writeln('<tr><td width="15%" bgcolor="#FFCC99"><b>Product Code</b> </td>');
          document.writeln('<td width="52%" bgcolor="#FFCC99"><div align="center"><b>Product Description</b> </div></td>');
          document.writeln('<td width="10%" bgcolor="#FFCC99"><div align="center"><b>Quantity </b></div></td>');
          document.writeln('<td width="8%" bgcolor="#FFCC99"><div align="center"><b>Unit Price </b></div></td>');
          document.writeln('<td width="10%" bgcolor="#FFCC99"><div align="center"><b>Total Price </b></div></td></tr>');
          for(n = 0; n < NumItems; n++)
             {
              ResourceNum = AllOrders[n]; 
              if(ResourceNum > 0)
                {
                 OrderIds += ResourceDB[n].Code + ",";
                 document.writeln('<td width="15%" bgcolor="#FFCC55" align="left">' + ResourceDB[n].Code + '</td>');  
                 document.writeln('<td width="52%" bgcolor="#FFCC55" align="left"><h3>' + ResourceDB[n].Title + '</h3></td>');         
                 document.writeln('<td width="10%" bgcolor="#FFCC55" align="center">' + ResourceDB[n].Quantity +'</td>'); 
                 ResourcePrice = ResourceDB[n].Price;
                 ResourceTotal = ResourceNum*ResourcePrice;
                 OrderTotal += parseFloat(ResourceTotal);
                 document.writeln('<td width="8%" bgcolor="#FFCC55" align-"left">' + '$'+ ResourcePrice + '</td>'); 
                 document.writeln('<td width="10%" bgcolor="#FFCC55" align="left">' +'$' + fixFloat(ResourceTotal, 2) + '</td>'); 
                 document.writeln('<td><a href="javascript:deleteOrder(' + n + ', ' + false + ')">' + 'Delete</a></td></tr>'); 
                 }
              }  
         document.writeln('<tr><td colspan="4" align="right"><b>Subtotal:</b></td>'); 
         document.writeln('<td align="center"><b>$' + fixFloat(OrderTotal, 2) + '</b></td></tr>'); 
         document.writeln('<td align="center"><b>' + fixFloat(1.6*OrderTotal, 2) + '</b></td></tr>'); 
         TotalOrder = "&total=" + fixFloat(ExchangeRate*OrderTotal, 2);
         document.writeln('</form>');
         document.writeln('</table>');
          }

function CheckPassword(DocFieldName, DocFieldName1)
         {
          if(DocFieldName1.value != DocFieldName.value)
            {
             alert("Both passwords do not match\nPlease re-enter password twice");
             DocFieldName.focus();
             }
          }
		

