

function empty() {
if (members.loginname.value == "memberzone login") {
members.loginname.value = "";
}
}

function emptyb() {
if (members.loginname.value == "") {
members.loginname.value = "memberzone login";
}
}

function empty2() {
if (search.query.value == "search our site") {
search.query.value = "";
}
}

function empty2b() {
if (search.query.value == "") {
search.query.value = "search our site";
}
}


function AddToCart(thisForm) {

   duplicate = 0;
   iNumberInBasket = 0;
   iNumberInBasket = GetCookie("NumberInBasket");

   if ( thisForm.CeeDReference == null ) {
   alert('Error: no CeeD reference number.');
   } else {
   strCeeDReference = thisForm.CeeDReference.value; }

   if ( thisForm.EventTitle == null ) {
   alert('Error: no event title.');
   } else {
   strEventTitle = thisForm.EventTitle.value; }

   for ( i = 1; i <= iNumberInBasket; i++ ) {
      NewOrder = "Order." + i;
      database = "";
      database = GetCookie(NewOrder);
      Token0 = database.indexOf("|", 0);
      fields = new Array;
      fields[0] = database.substring( 0, Token0 );
      fields[1] = database.substring( Token0+1, database.length );
      if (fields[1] == thisForm.EventTitle.value) {
      duplicate = 1;
      }
   }

   if (duplicate == 1) {
   alert('This event has already been added to your meeting basket.');
   }

   if (duplicate == 0) {
   iNumberInBasket++;
   dbUpdatedOrder = strCeeDReference  + "|" + strEventTitle;
   strNewOrder = "Order." + iNumberInBasket;
   SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
   SetCookie("NumberInBasket", iNumberInBasket, null, "/");
   alert('1 new item added to your meeting basket.');
   }

}


function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);

   if ( endstr == -1 )
      endstr = document.cookie.length;
   return(unescape(document.cookie.substring(offset, endstr)));
}


function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;

   while ( i < clen ) {
      var j = i + alen;
      if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j));
      i = document.cookie.indexOf(" ", i) + 1;
      if ( i == 0 ) break;
   }

   return(null);
}


function SetCookie (name,value,expire,path,domain,secure) {
   var expire = new Date ();
   expire.setTime (expire.getTime() + (90 * 60000)); 
   var cookie = expire ;
   document.cookie = name + "=" + escape (value) +
                     ((expire) ? "; expires=" + expire.toGMTString() : "") +
                     ((path) ? "; path=" + path : "") +
                     ((domain) ? "; domain=" + domain : "") +
                     ((secure) ? "; secure" : "");
}


function DeleteCookie (name,path,domain) {
   if ( GetCookie(name) ) {
      document.cookie = name + "=" +
                        ((path) ? "; path=" + path : "") +
                        ((domain) ? "; domain=" + domain : "") +
                        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}


function RemoveFromCart(RemOrder) {
   if ( confirm("Click 'Ok' to remove this product from your meeting basket.") ) {
      NumberInBasket = GetCookie("NumberInBasket");
      for ( i=RemOrder; i < NumberInBasket; i++ ) {
         NewOrder1 = "Order." + (i+1);
         NewOrder2 = "Order." + (i);
         database = GetCookie(NewOrder1);
         SetCookie (NewOrder2, database, null, "/");
      }
      NewOrder = "Order." + NumberInBasket;
      SetCookie ("NumberInBasket", NumberInBasket-1, null, "/");
      DeleteCookie(NewOrder, "/");
   }
      javascript:location.reload(true);
}


function GetFromCart() {
   iNumberInBasket = GetCookie("NumberInBasket");
   if ( iNumberInBasket == null || iNumberInBasket == 0 ) {
   document.write("<b>Your meeting basket is currently empty!</b>");
   document.write("<br><br>");
   }
   else {
   WriteToForm( true );
   }
}


function addBookmark() {
var title = "CeeD";
var url = "http://www.ceed-scotland.com";
if (window.sidebar) { window.sidebar.addPanel(title, url,"");
} else if((document.all) && (window.external)) { window.external.AddFavorite(url, title);
} else { alert("Sorry, your browser doesn't support this function.");
}
}


function CartDetails() {
   iNumberInBasket = GetCookie("NumberInBasket");
   if ( iNumberInBasket == null || iNumberInBasket == 0 ) {
   document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:590px; height:31px;\"><tr><td style=\"width:53px; height:31px; padding-top:5px;\"><a href=\"index.php\"><img src=\"home.jpg\" width=\"53\" height=\"15\" alt=\"return to the home page\"></a></td><td style=\"width:270px; height:31px; padding-top:0px;\"><img src=\"spacer.gif\" width=\"270\" height=\"31\"></td><td style=\"width:96px; height:31px; padding-top:5px;\"><a href=\"javascript:addBookmark()\"><img src=\"bookmarkus.jpg\" width=\"96\" height=\"15\" alt=\"bookmark the CeeD website\"></a></td><td style=\"width:11px; height:31px; padding-top:0px;\"><img src=\"spacer.gif\" width=\"11\" height=\"31\"></td><td style=\"width:130px; height:31px; padding-top:5px;\"><a href=\"basket.php\"><img src=\"mybasket.jpg\" width=\"130\" height=\"15\"></a></td><td style=\"width:30px; height:31px; padding-top:5px;\"><a href=\"basket.php\" class=\"basket\" style=\"text-decoration:none;\"> (0)</a></td></tr></table>");
   }
   if ( iNumberInBasket == 1 ) {
   document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:590px; height:31px;\"><tr><td style=\"width:53px; height:31px; padding-top:5px;\"><a href=\"index.php\"><img src=\"home.jpg\" width=\"53\" height=\"15\" alt=\"return to the home page\"></a></td><td style=\"width:270px; height:31px; padding-top:0px;\"><img src=\"spacer.gif\" width=\"270\" height=\"31\"></td><td style=\"width:96px; height:31px; padding-top:5px;\"><a href=\"javascript:addBookmark()\"><img src=\"bookmarkus.jpg\" width=\"96\" height=\"15\" alt=\"bookmark the CeeD website\"></a></td><td style=\"width:11px; height:31px; padding-top:0px;\"><img src=\"spacer.gif\" width=\"11\" height=\"31\"></td><td style=\"width:130px; height:31px; padding-top:5px;\"><a href=\"basket.php\"><img src=\"mybasket.jpg\" width=\"130\" height=\"15\"></a></td><td style=\"width:30px; height:31px; padding-top:5px;\"><a href=\"basket.php\" class=\"basket\" style=\"text-decoration:none;\"> (1)</a></td></tr></table>");
   }
   if ( iNumberInBasket > 1 ) {
   document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:590px; height:31px;\"><tr><td style=\"width:53px; height:31px; padding-top:5px;\"><a href=\"index.php\"><img src=\"home.jpg\" width=\"53\" height=\"15\" alt=\"return to the home page\"></a></td><td style=\"width:270px; height:31px; padding-top:0px;\"><img src=\"spacer.gif\" width=\"270\" height=\"31\"></td><td style=\"width:96px; height:31px; padding-top:5px;\"><a href=\"javascript:addBookmark()\"><img src=\"bookmarkus.jpg\" width=\"96\" height=\"15\" alt=\"bookmark the CeeD website\"></a></td><td style=\"width:11px; height:31px; padding-top:0px;\"><img src=\"spacer.gif\" width=\"11\" height=\"31\"></td><td style=\"width:130px; height:31px; padding-top:5px;\"><a href=\"basket.php\"><img src=\"mybasket.jpg\" width=\"130\" height=\"15\"></a></td><td style=\"width:30px; height:31px; padding-top:5px;\"><a href=\"basket.php\" class=\"basket\" style=\"text-decoration:none;\"> (" + iNumberInBasket + ")</a></td></tr></table>");
   }
}


function WriteToForm( bDisplay ) {

   iNumberInBasket = 0;
   iNumberInBasket = GetCookie("NumberInBasket");

   if ( bDisplay )

   strOutput = "Your meeting basket currently contains the following items:<br><br>";
   strOutput2 = "";

   strOutput += "<div align='center'><table cellpadding='0' cellspacing='0' style='width:460px; border: solid 1px #333333;'><tr><td style='width:150px; height:28px; background: #666666; vertical-align: middle;'><div class='year'>CeeD Reference</div></td><td style='width:210px; height:28px; background: #666666; vertical-align: middle;'><div class='year'>Meeting Title</div></td><td style='width:100px; height:28px; background: #666666; vertical-align: middle;'><div class='year'>Remove</div></td></tr>";

   for ( i = 1; i <= iNumberInBasket; i++ ) {
      NewOrder = "Order." + i;
      database = "";
      database = GetCookie(NewOrder);

      Token0 = database.indexOf("|", 0);
      fields = new Array;
      fields[0] = database.substring( 0, Token0 );
      fields[1] = database.substring( Token0+1, database.length );

      strOutput2 += "" + fields[1] + "";
      if ( i < iNumberInBasket ) { strOutput2 += " / "; }

      if ( bDisplay ) {
      strOutput += "<tr><td colspan='3' style='width:460px; height:1px; background: #333333;'><img src='spacer.gif' width='460' height='1' alt=''></td></tr>";
      strOutput += "<tr><td style='width:150px; height:25px; vertical-align: middle;' class='content'><div align='center'>" + fields[0] + "</div></td><td style='width:210px; height:25px; vertical-align: middle;' class='content'><div align='center'>" + fields[1] + "</div></td><td style='width:100px; height:25px; vertical-align: middle;'><div align='center'><input type='button' value=' Remove ' onClick='RemoveFromCart("+i+")'></div></td></tr>";
      }
   }

   if ( bDisplay ) {
   strOutput += "</table>";
   strOutput += "</div><br><br style='line-height:8px;'>";
   strOutput += "<input type='hidden' name='meetingbasket' value='" + strOutput2 + "'>";
   }

   document.write(strOutput);

}
