/********************************/
//
//   tools.js
//   Miscellaneous functions
//
//   Written by Denby Angus for TheBabyWearer.com
//   started 5 Sept 2003
//   last amended 15 March 2008
//
/*********************************/

// Return flag test for whether page is framed.
function isTop () {
  var istop = (top == self) ? 1 : 0;
  return istop;
}

// COOKIES
var COOKIE_PREFIX = 'vb_';

function Get_Cookie(name) {
  var start = document.cookie.indexOf(name+"=");
  var len = start+name.length+1;
  if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
  if (start == -1) return null;
  var end = document.cookie.indexOf(";",len);
  if (end == -1) end = document.cookie.length;
  return unescape(document.cookie.substring(len,end));
}

// Set common variables
var userName = Get_Cookie(COOKIE_PREFIX + 'username');
var userID = Get_Cookie(COOKIE_PREFIX + 'userid');
var sessionhash = Get_Cookie(COOKIE_PREFIX + 'sessionhash');
var currentURL = location.href;
var homeurl = 'http://www.thebabywearer.com/';
var forumurl = homeurl + 'forum/';

function Set_Cookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" +escape(value) +
    ( (expires) ? ";expires=" + expires.toGMTString() : "") +
    ( (path) ? ";path=" + path : ";path=/") + 
    ( (domain) ? ";domain=" + domain : ";domain=.thebabywearer.com") +
    ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name) {
  var date = new Date(0);
  var expires = date.toGMTString();
  document.cookie = name+'=value;expires='+expires+';domain=.thebabywearer.com;path=/';
}

// http://www.quirksmode.org/js/cookies.html
// Faster neater cookies.
var Cookies = {
  init: function () {
    var allCookies = top.document.cookie.split('; ');
    for (var i=0;i<allCookies.length;i++) {
      var cookiePair = allCookies[i].split('=');
      this[cookiePair[0]] = cookiePair[1];
    }
  },
  create: function (name,value,days) {
    if (days) {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    top.document.cookie = name+"="+value+expires+';domain=.thebabywearer.com;path=/';
    this[name] = value;
  },
  erase: function (name) {
    this.create(name,'',-1);
    this[name] = undefined;
  }
};
Cookies.init();
/*
examples:
  Cookies.create('hyuserid','$USERID',30); // 30 days expiry
  Cookies['hyuserid']
  Cookies.erase('hyuserid');
*/
var userid = Cookies['hyuserid'];

// Manage terms agreement links on rateme.pl
function termsagree (agree) {
  if (agree) {
    Cookies.create('tbwterms','yes',7);
    window.location=window.location;
  } else {
    alert('You may not view the reviews at TheBabyWearer.com.');
    history.back();
  }
}

// Redirect from opening article containing this function if not logged in.
function SecureArticle() {
  /*if ( !userName ) {
    location.href = homeurl + 'no_article_access.htm';
  }*/
}

// Redirect from opening page containing this function if not logged in.
function SecurePage() {
  if ( !userName ) {
    location.href = homeurl + 'no_page_access.htm';
  }
}

// Is browser Internet Explorer? (extracted from browsersniffer.js)
var agt = navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);

var iePos = appVer.indexOf('msie');
var is_opera = (agt.indexOf("opera") != -1);
var is_konq = false;
var kqPos = agt.indexOf('konqueror');
if (kqPos !=-1) {
  is_konq = true;
}
var is_safari = ((agt.indexOf('safari')!=-1) && (agt.indexOf('mac')!=-1)) ? true:false;
var is_khtml = (is_safari || is_konq);
var is_ie = ((iePos!=-1) && (!is_opera) && (!is_khtml)) ? true : false;

var is_mac = (agt.indexOf("mac")!=-1);
var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
  if(is_mac) {
    var iePos = agt.indexOf('msie');
    is_minor = parseFloat(agt.substring(iePos+5,agt.indexOf(';',iePos)));
  }
  else is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
    is_major = parseInt(is_minor);
}

/* There were problems with setting the base font as a percentage (ie 100%) because of relative font size changes throughout the page in most browsers. If an absolute size is used (eg 12px), the user can't adjust the text size in IE (but they can in NN et al). Using a predefined relative size (eg x-small), IE users can still adjust the text size and the display formats properly. The browser_sniffer checks for the browser type and returns true or false for the var "is_ie".
*/
function setBaseFont (target) {
 // do nothing
}

// Write browser-specific styles
/*
  if (typeof target != 'undefined') {
    var windoc = target.document;
  } else {
    var windoc = window.document;
  }
*/

var windoc = window.document;
windoc.write('<style type="text/css">');
if (is_ie && (is_major >= 7) ) {
  windoc.write('@import url(http://www.thebabywearer.com/newmenu_ie7.css);');
} else {
  windoc.write('@import url(http://www.thebabywearer.com/newmenu.css);');
}

if (is_ie) { // Internet Explorer
  windoc.write('#cssmenu a, #cssmenu h2 {font-size: 11px}');
  windoc.write('#cssmenu ul li {float:left; width:100%;}');
  windoc.write('#cssmenu ul li a {height: 1%;}');
  windoc.write('#cssmenu ul li h2 {height: 1%;}');
} else {
  windoc.write('#cssmenu a, #cssmenu h2 {font-size: 12px}');
}
windoc.write('</style>');

// pause javascript execution.
function pause(millis) {
  date = new Date();
  var curDate = null;

  do { var curDate = new Date(); }
  while(curDate-date < millis);
}

/* text blinking script for IE */
/* for others, use CSS "text-decoration: blink;"
e.g.
<span style="text-decoration: blink"><blink><b>Boo!</b></blink></span>
*/
function blinkIt() {
  if (!document.all) return;
  else {
    for(i=0;i<document.all.tags('blink').length;i++) {
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility == 'visible') ? 'hidden' : 'visible';
    }
  }
}
function setBlinking() {
  setInterval('blinkIt()',500);
}
window.onload = setBlinking;

function setgentable () {
// Write browser-specific style width for general table
  document.write('<style type="text/css">');
  if (is_ie) { // Internet Explorer
    document.write('.gentable { width:95%;}');
  }
  else {
    document.write('.gentable { width:750px;}');
  }
  document.write('</style>');
}

function formatImg(pos) {
  document.write('<span class="imgcap" style="float:'+pos+'">');
}

function show(object) {
  if (document.layers && document.layers[object] != null) { // Netscape 4.0+
    document.layers[object].display = 'block';
  } else if (document.getElementById) { // IE 5.0+ and Netscape 6.0+
    document.getElementById(object).style.display = 'block';
  }
}
function hide(object) {
  if (document.layers && document.layers[object] != null) { // Netscape 4.0+
    document.layers[object].display = 'none';
  } else if (document.getElementById) { // IE 5.0+ and Netscape 6.0+
    document.getElementById(object).style.display = 'none';
  }
}

// Limit text characters input for a textarea.
function limitInput(formelement,maxlen) {
  if (formelement.value != "" && formelement.value.length > maxlen) {
    formelement.value = formelement.value.substring(0, maxlen);
  }
}

function submit_form(form_name) {
  document.forms[form_name].submit();
}
// Enables the submission of the Home page login form by pressing the enter key.
// Add  onkeypress="return loginentsub(event)"  to all the <input type="text"> tags
// of the login form.
function loginentsub(e) {
  var dosubmit = false;
  if (is_ie && event.keyCode == 13) {
    dosubmit = true;
  } else if (e && e.which == 13) {
    dosubmit = true;
  }
  if (dosubmit) {
    submit_form('loginform');
  } else {
    return true;
  }
}

// Resize window if small popunder. Must be loaded in body onload.
function ExpandPopunder() {
  if (document.layers) {
    width = window.innerWidth;
  }
  else if (document.all) {
    width = document.body.clientWidth;
  }
  width = window.innerWidth;
  if (width < 200) {
    self.resizeTo(750,550);
    self.focus();
  }
}
// Present a close window button if a popup/popunder.
function MakeCloseButton() {
  if (window.opener) {
    document.write('<button onclick="javascript:self.close();">Close window</button>');
  }
}

function lrtrim(strText) { 
  // this will get rid of leading spaces 
  while (strText.substring(0,1) == ' ') 
    strText = strText.substring(1, strText.length);

  // this will get rid of trailing spaces 
  while (strText.substring(strText.length-1,strText.length) == ' ')
    strText = strText.substring(0, strText.length-1);

  return strText;
} 
function rtrimnl(strText) {
  // this will get rid of trailing newlines & whitespace.
  while (strText.substring(strText.length-1,strText.length) == ' ' || strText.substring(strText.length-1,strText.length) == '\n')
    strText = strText.substring(0, strText.length-1);

  return strText;
} 

function roundit(num,roundto) {
  return Math.round(num/roundto)*roundto;
}
// format value to display as string with 2 dec places.
function format2DecPlaces(num) {
  var n = Math.round(100*(num - Math.floor(num)))/100;
  if (n == 0) {
    num += '.00';
  } else if ( (10*n-Math.floor(10*n)) == 0 ) {
    num += '0';
  }
  return num;
}
function isVowel(ch) {
// Given   : ch is a character
// Returns : true if ch is a vowel
  var vowels;
  vowels = "aeiouAEIOU";
  return (vowels.indexOf(ch) != -1);
}

//ToolTip style popup messages for hyperlinks.
//Script created by Jim Young (www.requestcode.com) and amended by Denby Angus.
function showtip(current,e,num,adjx,adjy,note) {
  var newRegDrawDetailsMsg = 'All users who <b>register</b> between<br>midnight (GMT) of the first day<br>and midnight (GMT) of the last day<br>will be automatically included in the draw.<br><b>Note:</b> Vendors of babywearing products and<br>their employees are ineligible.';
  var subscribedMembersDetailsMsg = 'Members may subscribe for<br />up to 5 forum feature upgrades.<br />Members will be entered once for each<br />current upgrade subscription<br />for the draw each 16th of the month.<br />See the <b>Forums</b> for more details.';
  var activeUserDrawDetailsMsg = '<b>Active Members</b> are all registered members who have contributed to the community<br>by posting in any TBW Forum (except the Classes and Workshops forums,<br>the For Sale or Trade forums or any of the private forums), OR<br>who have posted a review of a vendor or product,<br>between midnight (GMT) of the first day and midnight (GMT) of the last day.<br>One entry will be automatically included per member.<br><b>Note:</b> Previous winners of the Active Members draw<br>and vendors of babywearing products and their employees are ineligible.';
  var vendorDefinition ='A vendor of babywearing products<br>but <b>NOT</b> '+note+'.';
  var scheduledChats = '<b>Chat Session hosted by Alison</b><br />&nbsp; &nbsp; PST Monday 7.30pm<br />&nbsp; &nbsp; EST Monday 10.30pm<br />&nbsp; &nbsp; GMT Tuesday 3.30am<br />&nbsp; &nbsp; AEST Tuesday 12.30am<br /><b>Chat Session hosted by Alison</b><br />&nbsp; &nbsp; PST Wednesday 7.30pm<br />&nbsp; &nbsp; EST Wednesday 10.30pm<br />&nbsp; &nbsp; GMT Thursday 3.30am<br />&nbsp; &nbsp; AEST Thursday 12.30am<br /><b>All welcome!</b>';

  var tip=new Array
/*    tip[0]=logoutMsg
    tip[1]=loginMsg
    tip[2]=registerMsg*/
    tip[3]=subscribedMembersDetailsMsg
    tip[4]=newRegDrawDetailsMsg
    tip[5]=activeUserDrawDetailsMsg
//    tip[6]=previousWinnersMsg
//    tip[7]=directDepositDetails
    tip[8]=vendorDefinition;
    tip[9]=scheduledChats;
  var tipx = eval(adjx);
  var tipy = eval(adjy);

  if (document.layers) { // Netscape 4.0+ 
    theString="<DIV CLASS='ttip'>"+tip[num]+"</DIV>" 
    document.tooltip.document.write(theString);
    document.tooltip.document.close();
    document.tooltip.left=e.pageX + tipx;
    document.tooltip.top=e.pageY + tipy;
    document.tooltip.visibility="show";
  }
  else {
    if(document.getElementById) { //  Internet Explorer 5.0+ and Netscape 6.0+ 
      elm=document.getElementById("tooltip");
      elmd=document.getElementById(current.id);
      elm.innerHTML=tip[num];
      var maxHeight = 400;
      var maxWidth = 700;
      elm.style.height = (elm.style.height>maxHeight) ? maxHeight : elm.style.height;
      elm.style.width = (elm.style.width>maxWidth) ? maxWidth : elm.style.width;
      if(document.all) { // for IE5+ only
        elm.style.pixelTop=(document.body.scrollTop + event.clientY) + tipy
        elm.style.pixelLeft=(document.body.scrollLeft + event.clientX) + tipx
      } 
      else { // NS6 only 
        elm.style.top=e.pageY + tipy;
        elm.style.left=e.pageX + tipx;
      }
      elm.style.visibility = "visible";
    }
  }
}

function hidetip(){
  if (document.layers) { // Netscape 4.0+
    document.tooltip.visibility="hidden";
  }
  else {
    if(document.getElementById) { // Netscape 6.0+ and Internet Explorer 5.0+
      elm.style.visibility="hidden";
    }
  }
}

function ChatRoomLink() {
  if (!userName) {
    document.write('<b>The Chat Room is always open!</b><br />(but you need to be logged in first)');
  } else {
    document.write('<b>The <a href="" onClick="window.open(\'forum/chat.php?&do=popup\', \'sigmachat\', \'width=650,height=400,left=50,top=50,statusbar=no,scrollbars=no,toolbar=no,menubar=no,resizable=yes\'); return false">Chat Room</a> is always open!</b>');
    //document.write('<b>The <a href="forum/chat.php">Chat Room</a> is always open!</b>');
  }
}

// Close browser window if popup chat room closes. Added Denby Angus 1/6/06
if (window.name == 'sigmachat' && location.pathname != '/forum/chat.php') {
  self.close();
}

// Offer a confirming popup. Optional prompt text.
// Returns true if "yes", false if "no".
function dblcheck(prompt) {
  prompt = (!prompt) ? 'Are you sure you wish to proceed with these changes?' : prompt;
  if ( confirm(prompt) ) {
    return true;
  } else {
    window.status = '';
    return false;
  }
}

//////////////////////////////////////////////////////////////////////
// Randomly display ads for CP shop products.
function showCPAds() {
  var TBWURLroot = homeurl + 'images/';
  var CPURLroot = 'http://www.cafepress.com/thebabywearer?type=';

  var links = new Array;
    links[0] = '<br /><a href="' + CPURLroot + '118" target="_blank">';
    links[1] = '<br /><a href="' + CPURLroot + '112" target="_blank">';
    links[2] = '<br /><a href="' + CPURLroot + '113" target="_blank">';
    links[3] = '<br /><a href="' + CPURLroot + '18" target="_blank">';
    links[4] = '<br /><a href="' + CPURLroot + '0" target="_blank">';
    links[5] = '<br /><a href="' + CPURLroot + '70" target="_blank">';
    links[6] = '<br /><a href="' + CPURLroot + '119" target="_blank">';
    links[7] = '<br /><a href="' + CPURLroot + '73" target="_blank">';
    /*links[8] = '<br /><a href="' + CPURLroot + '3" target="_blank">';
    links[9] = '<br /><a href="' + CPURLroot + '50" target="_blank">';
    links[10] = '<br /><a href="' + CPURLroot + '77" target="_blank">';*/

//<a href="http://www.cafepress.com/thebabywearer?type=118"><b>Buttons</b></a> now available! Two new designs: <b>I love babywearing</b> and <b>Ask me about babywearing</b>, as well as all of the existing designs. Buttons can be pinned anywhere--on your hat, your sling, your tote bag!<br>
//<b>Only US$1.65 each</b><br />
  var descriptions = new Array;
    descriptions[0] = links[0] +'<b>Buttons</b></a>';
    descriptions[1] = links[1] +'<b>Value T&minus;shirts</b></a>';
    descriptions[2] = links[2] +'<b>Women\'s Ringer T&minus;shirts</b></a>';
    descriptions[3] = links[3] +'<b>Messenger Bags</b></a>';
    descriptions[4] = links[4] +'<b>Mugs</b></a>';
    descriptions[5] = links[5] +'<b>Kid\'s T&minus;shirts</b></a>';
    descriptions[6] = links[6] +'<b>Fridge Magnets</b></a>';
    descriptions[7] = links[7] +'<b>Bibs</b></a>';

  var imgFiles = new Array;
    imgFiles[0] = TBWURLroot + 'shop/borngreenbutton1.jpeg';
    imgFiles[1] = TBWURLroot + 'shop/realmenvalueT.jpeg';
    imgFiles[2] = TBWURLroot + 'shop/heldbabyringerT.jpeg';
    imgFiles[3] = TBWURLroot + 'shop/realmenmessengerbag.jpeg';
    imgFiles[4] = TBWURLroot + 'shop/fabricmug.jpeg';
    imgFiles[5] = TBWURLroot + 'shop/bornbluekidT.jpeg';
    imgFiles[6] = TBWURLroot + 'shop/bwfuturemagnet1.jpeg';
    imgFiles[7] = TBWURLroot + 'shop/borngreenbib.jpeg';

  var titles = new Array;
    titles[0] = 'Babies: Born to be Worn (Green) Button';
    titles[1] = 'Real Men Wear Babies Value T-shirt';
    titles[2] = 'A Held Baby is a Happy Baby Women\'s Ringer T-shirt';
    titles[3] = 'Real Men Wear Babies Messenger Bag';
    titles[4] = 'Babywearing - Part of the Fabric of Parenting Mug';
    titles[5] = 'Babies: Born to be Worn (Blue) Kid\'s T-shirt';
    titles[6] = 'Babywearing for our Future Magnet';
    titles[7] = 'Babies: Born to be Worn (Green) Bib';

  var adCount = links.length;
  // randomly choose the ad array index number.
  var adNum = Math.floor(Math.random()*adCount+1)-1;
  //var adNum = 1;

  //display the randomly selected ad.
  document.write(links[adNum] + '<img src="' + imgFiles[adNum] + '" title="' + titles[adNum] + '" id="thinblackborder"></a>' + descriptions[adNum] + '<br />');

}
/////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////
// DROP DOWN MENUS

function cssmenudefs() {
// CSS Menu definitions
// Called by menu_defnew.js

  var cgipath = homeurl + 'cgi-bin/';
  var cgidbpath = homeurl + 'cgi-bin/db/';
  var cgireviewspath = homeurl + 'cgi-bin/reviews/';
  var reviewscriptpath0 = cgireviewspath + 'review.pl';
  var reviewscriptpath = cgireviewspath + 'reviews.pl';
  var articlespath = homeurl + 'articles/';
  var infopath = homeurl + 'info/';   // gen information for vendors & buyers.
  var listspath = homeurl + 'lists/';
  var fundspath = homeurl + 'funds/'; // gen information about donations, wholesaling, raffles etc.

  // calibrate the menu text size for IE and non-IE.
  var roundedto = 0.2;
  if (is_ie) {
    var units = 'px';
    if (is_major <= 6) {
      var multh = 0.5;
      var mult = 0.95;
    } else {
      var multh = 0.8;
      var mult = 0.76;
    }
  } else {
    var units = 'em';
    var multh = 0.065;
    var mult = 0.070;
  }

  // menu heading item widths
  var widthaa = roundit(50*multh,roundedto) + units;//help
  var widtha = roundit(60*multh,roundedto) + units;//home,admin,shops
  var widthb = roundit(75*multh,roundedto) + units;//articles,reviews
  var widthc = roundit(85*multh,roundedto) + units;//donations
  var widthd = roundit(100*multh,roundedto) + units;//forum,vendors
  var widthdd = roundit(115*multh,roundedto) + units;//gallery
  var widthe = roundit(135*multh,roundedto) + units;//links
  // submenu item widths
  var width1 = roundit(95*mult,roundedto) + units;
  var width2 = roundit(145*mult,roundedto) + units;
  var width3 = roundit(195*mult,roundedto) + units;//admin,articles,
  var width4 = roundit(220*mult,roundedto) + units;//vendor reviews
  var width5 = roundit(255*mult,roundedto) + units;
  var width6 = roundit(265*mult,roundedto) + units;

  document.write('<div id="cssmenu">');

  document.write('<ul style="width: ' + widtha + '"><li><a href="' + homeurl + '" title="" target="_self"><b>&nbsp;Home&nbsp;</b></a></li></ul>');

//ADMIN
  //if ( (userName == "KoalaMama") || (userName == "denby") || (userName == "MonteMama") || (userName == "gcriss") || (userName == "mom2twinsplus2") ) {
  if ( (userName == "KoalaMama") || (userName == "denby") || (userName == "MonteMama") || (userName == "gcriss") || (userName == "mom2twinsplus2") || (userName == "testreg") ) {
    document.write('<ul style="width: ' + widtha + '"><li><h2>&nbsp;Admin&nbsp;</h2>');
      document.write('<ul>');
  }
  if ( (userName == "KoalaMama") || (userName == "denby") || (userName == "MonteMama") ) {
        document.write('<li style="width: ' + width5 + '"><a href="http://www1.sigmachat.com/panel/console/login.php?room=95353" title="" target="_self">ChatRoom Console</a></li>');
  }
// GLENDA
  if ( (userName == "gcriss") || (userName == "KoalaMama") || (userName == "denby") || (userName == "MonteMama") ) {
        document.write('<li style="width: ' + width5 + '"><a href="' + forumurl + 'get_posts.php" title="" target="_self">Select active user winner</a></li>');
        document.write('<li style="width: ' + width5 + '"><a href="' + forumurl + 'drawupgrades.php" title="" target="_self">Select upgrades subscription winner</a></li>');
        document.write('<li style="width: ' + width5 + '"><a href="' + forumurl + 'drawactivevendors.php" title="" target="_self">Select active vendor winner</a></li>');
        document.write('<li style="width: ' + width5 + '"><a href="' + forumurl + 'drawbwowk.php" title="" target="_self">Select babywearer of the week winner</a></li>');
  }
//ALISON
  if ( (userName == "mom2twinsplus2") || (userName == "KoalaMama") || (userName == "denby") || (userName == "MonteMama") ) {
        document.write('<li style="width: ' + width5 + '"><a href="' + cgipath + 'reviews_stats.pl" title="" target="_self">Reviews statistics</a></li>');
        document.write('<li style="width: ' + width5 + '"><a href="' + cgireviewspath + 'allnewtopics.pl" title="" target="_self">Manage new topics</a></li>');
        document.write('<li style="width: ' + width5 + '"><a href="' + cgireviewspath + 'reviewsadmin.pl" title="" target="_self">Reviews Admin Panel</a></li>');
        document.write('<li style="width: ' + width5 + '"><a href="' + cgireviewspath + 'vendor.pl" title="" target="_self">Submit New Vendor Details</a></li>');
  }
  if ( (userName == "KoalaMama") || (userName == "denby") || (userName == "MonteMama") || (userName == "gcriss") || (userName == "mom2twinsplus2") || (userName == "testreg") ) {
      document.write('</ul>');
    document.write('</li></ul>');
  }

//ARTICLES
  document.write('<ul style="width: ' + widthb + '"><li><h2>&nbsp;Articles&nbsp;</h2>');
    document.write('<ul>');
      document.write('<li style="width: ' + width3 + '"><a href="http://www.thebabywearer.com/index.php?page=bwbenefits" target="_top">Benefits of Babywearing </a></li>');
      document.write('<li style="width: ' + width3 + '"><a href="http://www.thebabywearer.com/index.php?page=choosinglinks" target="_top">Choosing a babycarrier</a></li>');
      document.write('<li style="width: ' + width3 + '"><a href="http://www.thebabywearer.com/index.php?page=usinglinks" target="_top">Using your babycarrier</a></li>');
      document.write('<li style="width: ' + width3 + '"><a href="http://www.thebabywearer.com/index.php?page=bwstories" target="_self">Personal stories and humour</a></li>');
      document.write('<li style="width: ' + width3 + '"><a href="http://www.thebabywearer.com/index.php?page=sewing" target="_self">Sewing and improvising</a></li>');

    document.write('</ul>');
  document.write('</li></ul>');

//REVIEWS
  document.write('<ul style="width: ' + widthb + '"><li><h2>&nbsp;Reviews&nbsp;</h2>');
    document.write('<ul>');
      document.write('<li style="width: ' + width2+ '"><a href="http://www.thebabywearer.com/index.php?page=reviewguide" target="_self">Review Guide</a></li>');
      document.write('<li style="width: ' + width2+ '"><a href="' + reviewscriptpath0 + '?product" title="" target="_self">Product reviews</a>');
      document.write('<li style="width: ' + width2+ '"><a href="' + reviewscriptpath0 + '?vendor" title="" target="_self">Vendor reviews</a>');
      document.write('</li>');
    document.write('</ul>');
  document.write('</li></ul>');

//PRODUCT DIRECTORY
  document.write('<ul style="width: ' + widthe + '"><li><a href="' + cgireviewspath + 'productlinks.pl" title="" target="_self"><b>&nbsp;Product&nbsp;Directory&nbsp;</b></a></li></ul>');

//FORUM
  document.write('<ul style="width: ' + widthd + '"><li><a href="' + homeurl + 'forum" target="_self"><b>&nbsp;Forum/Chat&nbsp;</b></a></li></ul>');

//GALLERY
  document.write('<ul style="width: ' + widthdd + '"><li><a href="' + homeurl + 'gallery" target="_self"><b>&nbsp;Photo&nbsp;Gallery&nbsp;</b></a></li></ul>');

//SHOPS
  document.write('<ul style="width: ' + widtha + '"><li><h2>&nbsp;Shops&nbsp;</h2>');
    document.write('<ul>');
      document.write('<li style="width: ' + width4 + '"><a href="http://astore.amazon.com/thebabywearer-20" target="_self">TBW Amazon Store - USA</a></li>');
      document.write('<li style="width: ' + width4 + '"><a href="http://astore.amazon.co.uk/thebabywearer-21" target="_self">TBW Amazon Store - UK</a></li>');
	   document.write('<li style="width: ' + width4 + '"><a href="http://astore.amazon.ca/thebabywear07-20" target="_self">TBW Amazon Store - Canada</a></li>');
	    document.write('<li style="width: ' + width4 + '"><a href="' + cgipath + 'bookshop.pl?locale=uk" title="" target="_self">TBW Recommended Books - UK</a></li>');
      document.write('<li style="width: ' + width4 + '"><a href="' + cgipath + 'bookshop.pl?locale=us" title="" target="_self">TBW Recommended Books - US</a></li>');
      document.write('<li style="width: ' + width4 + '"><a href="http://www.cafepress.com/thebabywearer" title="" target="_blank">Babywearing advocacy products</a></li>');
    document.write('</ul>');
  document.write('</li></ul>');

//DONATIONS
  document.write('<ul style="width: ' + widthc + '"><li><a href="http://www.thebabywearer.com/index.php?page=donations" target="_self"><b>&nbsp;Donations&nbsp;</b></a></li></ul>');

//FOR VENDORS
  document.write('<ul style="width: ' + widthd + '"><li><h2>&nbsp;For&nbsp;Vendors&nbsp;</h2>');
    document.write('<ul>');
      document.write('<li style="width: ' + width5 + '"><a href="' + cgireviewspath + 'vendor.pl" title="" target="_self">Submit New Vendor Details</a></li>');
  
      document.write('<li style="width: ' + width5 + '"><a href="http://www.thebabywearer.com/index.php?page=vendors" target="_self">Business Promotion at TBW</a></li>');
      document.write('<li style="width: ' + width5 + '"><a href="' + fundspath + 'cpwholesaleintro.htm" title="" target="_self">TBW CafePress Shop wholesale ordering</a></li>');
      document.write('<li style="width: ' + width5 + '"><a href="' + infopath + 'ratemeimages.htm" title="" target="_self">Rate Me At TBW link buttons</a></li>');
    document.write('</ul>');
  document.write('</li></ul>');

//HELP
  document.write('<ul style="width: ' + widthaa + '"><li><h2>&nbsp;Help&nbsp;</h2>');
    document.write('<ul>');
      document.write('<li style="width: ' + width1 + '"><a href="http://www.thebabywearer.com/index.php?page=help" target="_self">Site help</a></li>');
      document.write('<li style="width: ' + width1 + '"><a href="http://www.thebabywearer.com/index.php?page=fraud" target="_self">Fraud info</a></li>');
      document.write('<li style="width: ' + width1 + '"><a style="border:0;padding:0"><h2>Downloads</h2></a>');
        document.write('<ul>');
          document.write('<li style="width: ' + width4 + '"><a href="' + infopath + 'TBWimages.htm" title="" target="_self">TBW link buttons</a></li>');
          document.write('<li style="width: ' + width4 + '"><a href="' + fundspath + 'cpbuttons.htm" title="" target="_self">TBW CafePress Shop link buttons</a></li>');
          document.write('<li style="width: ' + width4 + '"><a href="' + infopath + 'Cards.htm" title="" target="_self">TBW business cards</a></li>');
        document.write('</ul>');
      document.write('</li>');

      document.write('<li style="width: ' + width1 + '"><a style="border:0;padding:0"><h2>Quick&nbsp;Info</h2></a>');
        document.write('<ul>');
          document.write('<li style="width: ' + width2 + '"><a href="http://www.thebabywearer.com/index.php?page=Glossary" target="_self">Glossary</a></li>');
          document.write('<li style="width: ' + width2 + '"><a href="' + infopath + 'translator.htm" title="" target="_self">Translator</a></li>');
          document.write('<li style="width: ' + width2 + '"><a href="http://www.worldwidemetric.com/metcal.htm" title="" target="_blank">Metric converter</a></li>');
          document.write('<li style="width: ' + width2 + '"><a href="http://www.xe.com/ucc/" title="" target="_self">Currency converter</a></li>');
          document.write('<li style="width: ' + width2 + '"><a href="http://www.timeanddate.com/worldclock/" title="" target="_blank">Time zones</a></li>');
          document.write('<li style="width: ' + width2 + '"><a href="http://kropla.com/dialcode.htm" title="" target="_blank">Country phone codes</a></li>');
        document.write('</ul>');
      document.write('</li>');

      document.write('<li style="width: ' + width1 + '"><a href="http://www.thebabywearer.com/index.php?page=terms" target="_self">Terms of use</a></li>');
      document.write('<li style="width: ' + width1 + '"><a href="' + homeurl + 'w3c/policy.htm" title="" target="_self">Privacy</a></li>');
      document.write('<li style="width: ' + width1 + '"><a href="' + cgipath + 'contact.pl?w" title="" target="_self">Contact us</a></li>');
      document.write('<li style="width: ' + width1 + '"><a href="' + infopath + 'AboutUs.htm" title="" target="_self">About us</a></li>');
    document.write('</ul>');
  document.write('</li></ul>');

  document.write('</ul></div>');
}

/***********  END OF TOOLS.JS **********/

