// JavaScript Document
/*
 * Fading Banner, base script, version 1.1
 *
 * Copyright (C) 2007 Dmitriy Khudorozhkov
 *
 * This software is provided "as-is", without any express or implied warranty.
 * In no event will the author be held liable for any damages arising from the
 * use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 *
 * 2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 *
 * 3. This notice may not be removed or altered from any source distribution.
 *
 *  - Dmitriy Khudorozhkov, kh_dmitry2001@mail.ru
 */

function FadingBanner(parentId, type, width, height, bg, timeout)
{
  this.batches  = [];
  this.current  = 0;
  this.images   = [];
  this.parent   = document.getElementById(parentId);
  this.root     = null;
  this.timeout  = timeout || 5000;
  this.type     = (type == "vertical") ? "vertical" : "horizontal";

  while(this.parent.firstChild)
    this.parent.removeChild(this.parent.firstChild);

  return this._construct(width, height, bg);
}

FadingBanner.prototype = {

  // public methods:

  add: function(batch, imageSrc, imageWidth, imageHeight, link)
  {
    var l = this.batches.length;
    for(var i = 0; i < l; i++)
      if(this.batches[i] == batch)
        break;

    if(i == l) this.batches[l] = batch;

    if(!this.images[batch]) this.images[batch] = [];

    var l2 = this.images[batch].length;

    var imag = this.images[batch][l2] = new Object;

    imag.src    = imageSrc;
    imag.link   = link;
    imag.width  = imageWidth;
    imag.height = imageHeight;

    var top = 0, left = 0, isH = (this.type == "horizontal");

    for(i = 0; i < l2; i++)
    {
      var _img = this.images[batch][i];

      if(isH)
      {
        left += _img.width;
      }
      else
      {
        top += _img.height;
      }
    }

    var a = imag.obj = document.createElement("A");
    a.href = imag.link;
    a.target = "_self";
    a.style.display = "none";

    var img = document.createElement("IMG");
    img.src = imag.src;
    img.id  = "fb_img_" + this.parent.id + "_" + String(batch) + "_" + String(l2);

    a.appendChild(img);
    this.root.appendChild(a);

    var is = img.style;
    is.position = "absolute";
    is.top      = top + "px";
    is.left     = left + "px";
    is.width    = imag.width;
    is.height   = imag.height;
    is.border   = "0";
    is.opacity  = 0;
    is.filter   = "alpha(opacity=0)";

    this.batches.sort(function (a, b) { return a - b; });
    this.current = this.batches[0];

    return l2 + 1;
  },

  start: function()
  {
    this.root.style.display = "block";

    this._showbatch();
  },

  // support methods follow:

  _construct: function(width, height, bg)
  {
    var banner = document.createElement("DIV");
    var bs = banner.style;

    bs.position = "relative";
    bs.top      = "0px";
    bs.left     = "0px";
    bs.width    = width + "px";
    bs.height   = height + "px";
    bs.zIndex	= "1";

    bs.display  = "none";
    bs.backgroundColor = bg || "#FFF";

    this.root = this.parent.appendChild(banner);

    return this;
  },

  _callLater: function(obj, func, param)
  {
    param = param || null;
    return obj ? (function() { obj[func](param); }) : (function() { func(param); });
  },

  _next: function()
  {
    var _out = function(_obj)
    {
      var _go = function(__obj)
      {
        var cur = __obj.current, l = __obj.images[cur].length;

        for(var i = 0; i < l; i++)
          __obj.images[cur][i].obj.style.display = "none";

        l = __obj.batches.length;
        for(i = 0; i < l; i++)
          if(__obj.current == __obj.batches[i])
            break;

        __obj.current = (i == l - 1) ? __obj.batches[0] : __obj.batches[i + 1];

        __obj._showbatch();
      }

      // fade-out current batch:
      var cur = _obj.current, l = _obj.images[cur].length;

      for(var i = 0; i < l; i++)
      {
        var img = _obj.images[cur][i];
        _obj._fade(img.obj.firstChild.id, 0, 50, 10, (i == (l - 1) ? function() { _go(_obj); } : null));
      }
    }

    setTimeout(this._callLater(null, _out, this), this.timeout);
  },

  _showbatch: function()
  {
    var cur = this.current, l = this.images[cur].length;

    for(var i = 0; i < l; i++)
    {
      var img = this.images[cur][i];
      img.obj.style.display = "block";

      this._fade(img.obj.firstChild.id, 100, 50, 10, (i == (l - 1) ? this._callLater(this, "_next") : null));
    }
  },

  _fade: function(id, destOp, rate, delta, callback)
  {
    var obj = document.getElementById(id);

    if(obj.timer) clearTimeout(obj.timer);

    var curOp = obj.filters ? obj.filters.alpha.opacity : (obj.style.opacity * 100.0);
    var direction = (curOp <= destOp) ? 1 : -1;

    delta  = Math.min(direction * (destOp - curOp), delta);
    curOp += direction * delta;

    if(obj.filters)
      obj.filters.alpha.opacity = curOp;
    else
      obj.style.opacity = curOp / 100.0;

    if(curOp != destOp)
      obj.timer = setTimeout(function() { FadingBanner.prototype._fade(id, destOp, rate, delta, callback); }, rate);
    else
      if(callback) callback();
  }
};

function AddBanner(file,url)
{
	//this.path = "http://www.anti-body.com/images/0000000/" + file; / if live
	this.path = "http://dev.anti-body.com/images/0000000/" + file;
	this.width = 788;
	this.height = 43;
	this.url = url;
}

function Rotator(index)
{
	var rotator = new FadingBanner("banner", "horizontal", 788, 43, "", 5000);
	var banners = new Array();
	
	banners[0] = new AddBanner("00000001.jpg","http://www.anti-body.com/community/caught/");
	banners[1] = new AddBanner("00000002.jpg","http://www.anti-body.com/coconut/");
	banners[2] = new AddBanner("00000003.jpg","http://www.anti-body.com/events/screenings/");
	banners[3] = new AddBanner("00000004.jpg","http://www.fairtradewhitehouse.com/");
	banners[4] = new AddBanner("00000005.jpg","http://www.anti-body.com/events/inhome/");
	banners[5] = new AddBanner("00000006.jpg","http://www.anti-body.com/fairtrade/");

	if(index > banners.length || !index)
		index = 0;
		
	var count=0;
	var size = banners.length;
	for(var i=index; // The starting point
		count<size;	 // count must not exceed the number of banners
		i=((i+1)%size),count++) // increment i by the remainder of i+1 divided by the number of banners
		rotator.add(count, 
			    banners[i].path, 
			    banners[i].width, 
			    banners[i].height, 
			    banners[i].url);
	rotator.start(); // start rotator
}

function DropDown()
{
	stm_bm(["drowpdown",850,"","http://www.anti-body.com/images/nav/blank.gif",0,"","",0,0,250,0,1000,1,0,0,"","",67108865,0,1,2,"hand","hand","http://www.anti-body.com/"],this);
	stm_bp("p0",[0,4,0,0,0,0,0,0,100,"",-2,"",-2,50,0,0,"#999999","#c6ab8e","",3,0,0,"#000000"]);
	stm_ai("p0i0",[2,"","http://www.anti-body.com/images/nav/about.jpg","http://www.anti-body.com/images/nav/about.jpg",71,29,0,"http://www.anti-body.com/about/","_self","","","","",0,0,0,"http://www.anti-body.com/images/nav/arrow_r.gif","http://www.anti-body.com/images/nav/arrow_r.gif",0,0,0,0,1,"#c6ab8e",1,"#c6ab8e",1,"","",3,3,0,0,"#E6EFF9","#000000","#000000","#000000","8pt Verdana","8pt Verdana",0,0]);
	stm_bp("p1",[1,4,0,0,2,3,0,0,100,"",-2,"",-2,50,0,0,"#999999","#c6ab8e","",3,1,1,"#c6ab8e"]);
	stm_aix("p1i0","p0i0",[0,"Careers","","",-1,-1,0,"http://www.anti-body.com/about/careers/","_self","","","","",0,0,0,"http://www.anti-body.com/images/nav/arrow_r.gif","http://www.anti-body.com/images/nav/arrow_r.gif",0,0,0,0,1,"#c6ab8e",0,"#c6ab8e",0,"","",3,3,0,0,"#673500 #c6ab8e #c6ab8e  #c6ab8e","#673500 #c6ab8e #c6ab8e  #c6ab8e"],150,20);
	stm_bpx("p2","p1",[1,2]);
//stm_aix("p2i0","p1i0",[0,"Employee Interviews","","",-1,-1,0,"http://www.anti-body.com/about/careers/employee/","_self","","","","",0,0,0,"",""],150,20);
	stm_ai("p2i1",[6,1,"#673500","",-1,-1,0]);
	stm_aix("p2i2","p2i0",[0,"Career Opportunities","","",-1,-1,0,"http://www.anti-body.com/about/careers/opportunities/","_self","","","","",0,0,0,"",""],150,20);
	stm_aix("p2i3","p2i1",[]);
	stm_aix("p2i4","p2i0",[0,"Internships","","",-1,-1,0,"http://www.anti-body.com/about/careers/internships/","_self","","","","",0,0,0,"",""],150,20);
	stm_aix("p2i5","p2i1",[]);
	stm_aix("p2i6","p2i0",[0,"Commitments","","",-1,-1,0,"http://www.anti-body.com/about/careers/commitments/","_self","","","","",0,0,0,"",""],150,0);
	stm_ep();
	stm_aix("p1i1","p2i1",[]);
	stm_aix("p1i2","p1i0",[0,"Media","","",-1,-1,0,"http://www.anti-body.com/about/media/","_self","","","","",0,0,0,"",""],150,20);
	stm_bpx("p3","p2",[]);
	//stm_aix("p3i0","p2i0",[0,"Film Screenings","","",-1,-1,0,"http://www.anti-body.com/events/screenings/","_self","","","","",0,0,0,"",""],150,20);
	//stm_aix("p3i1","p2i1",[]);
	stm_aix("p3i2","p2i0",[0,"On the Small Screen","","",-1,-1,0,"http://www.anti-body.com/about/media/screen/","_self","","","","",0,0,0,"",""],150,20);
	stm_aix("p3i3","p2i1",[]);
	stm_aix("p3i4","p2i0",[0,"Press Releases","","",-1,-1,0,"http://www.anti-body.com/about/media/releases/","_self","","","","",0,0,0,"",""],150,20);
	stm_aix("p3i5","p2i1",[]);
	stm_aix("p3i6","p2i0",[0,"In the Press","","",-1,-1,0,"http://www.anti-body.com/about/media/press/","_self","","","","",0,0,0,"",""],150,0);
	stm_aix("p3i7","p2i1",[]);
	stm_aix("p3i8","p2i0",[0,"Press Kit","","",-1,-1,0,"http://www.anti-body.com/data/press_kit.zip"],150,0);
	stm_ep();
	stm_aix("p1i3","p2i1",[]);
	stm_aix("p1i4","p2i0",[0,"Affiliates","","",-1,-1,0,"http://www.anti-body.com/about/affiliates/","_self","","","","",0,0,0,"",""],150,20);
	stm_ep();
	stm_aix("p0i1","p0i0",[2,"","http://www.anti-body.com/images/nav/fairtrade.jpg","http://www.anti-body.com/images/nav/fairtrade.jpg",-1,-1,0,"http://www.anti-body.com/fairtrade/","_self","","","","",0,0,0,"http://www.anti-body.com/images/nav/arrow_r.gif","http://www.anti-body.com/images/nav/arrow_r.gif",0,0,0,0,1,"#c6ab8e",0,"#c6ab8e",0]);
	stm_bpx("p4","p1",[]);
	stm_aix("p4i0","p0i1",[0,"About","","",-1,-1,0,"http://www.anti-body.com/fairtrade/","_self","","","","",0,0,0,"",""],150,20);
	stm_aix("p4i1","p2i1",[]);
	stm_aix("p4i2","p4i0",[0,"Togo, Africa","","",-1,-1,0,"http://www.anti-body.com/fairtrade/togo/"],150,20);
	stm_aix("p4i3","p2i1",[]);
	stm_aix("p4i4","p4i0",[0,"Liberia, Africa","","",-1,-1,0,"http://www.anti-body.com/fairtrade/liberia/"],150,20);
	stm_aix("p4i5","p2i1",[]);
	stm_aix("p4i6","p4i0",[0,"Certified","","",-1,-1,0,"http://www.anti-body.com/fairtrade/certified/"],150,20);
	stm_aix("p4i7","p2i1",[]);
	stm_aix("p4i8","p4i0",[0,"Memberships","","",-1,-1,0,"http://www.anti-body.com/fairtrade/member/"],150,20);
	stm_ep();
	stm_aix("p0i2","p0i1",[2,"","http://www.anti-body.com/images/nav/events.jpg","http://www.anti-body.com/images/nav/events.jpg",-1,-1,0,"http://www.anti-body.com/events/"]);
	stm_bpx("p5","p1",[]);
	stm_aix("p5i0","p4i0",[0,"Speaking","","",-1,-1,0,"http://www.anti-body.com/events/speaking/"],150,20);
	stm_aix("p5i1","p2i1",[]);
	//stm_aix("p5i2","p4i0",[0,"In-Store","","",-1,-1,0,"http://www.anti-body.com/events/instore/"],150,20);
	//stm_aix("p5i3","p2i1",[]);
	stm_aix("p5i4","p4i0",[0,"In-Home","","",-1,-1,0,"http://www.anti-body.com/events/inhome/"],150,20);
	stm_aix("p5i5","p2i1",[]);
	stm_aix("p5i6","p4i0",[0,"Documentary","","",-1,-1,0,"http://www.anti-body.com/events/screenings/"],150,20);
	stm_ep();
	stm_aix("p0i3","p0i1",[2,"","http://www.anti-body.com/images/nav/wholesale.jpg","http://www.anti-body.com/images/nav/wholesale.jpg",-1,-1,0,"http://www.anti-body.com/wholesale/"]);
	stm_bpx("p6","p1",[]);
	stm_aix("p6i0","p4i0",[0,"Login","","",-1,-1,0,"#"],150,20);
	stm_aix("p6i1","p2i1",[]);
	stm_aix("p6i2","p4i0",[0,"Private Label","","",-1,-1,0,"http://www.anti-body.com/wholesale/privatelabels/"],150,20);
	stm_aix("p6i3","p2i1",[]);
	stm_aix("p6i4","p4i0",[0,"New Accounts","","",-1,-1,0,"http://www.anti-body.com/wholesale/newaccounts/"],150,20);
	stm_ep();
	stm_aix("p0i4","p0i1",[2,"","http://www.anti-body.com/images/nav/community.jpg","http://www.anti-body.com/images/nav/community.jpg",-1,-1,0,"http://www.anti-body.com/community/"]);
	stm_bpx("p7","p1",[]);
	stm_aix("p7i0","p4i0",[0,"Get Caught!","","",-1,-1,0,"http://www.anti-body.com/community/caught/"],150,20);
	stm_aix("p7i1","p2i1",[]);
	stm_aix("p7i2","p4i0",[0,"Campaigns","","",-1,-1,0,"http://www.anti-body.com/coconut/"],150,20);
	stm_aix("p7i3","p2i1",[]);
	stm_aix("p7i4","p4i0",[0,"Customize","","",-1,-1,0,"http://www.anti-body.com/community/customize/"],150,20);
	stm_aix("p7i5","p2i1",[]);
	stm_aix("p7i6","p4i0",[0,"Blog","","",-1,-1,0,"http://antibody.wordpress.com"],150,20);
	stm_ep();

	stm_aix("p0i5","p4i0",[2,"","http://www.anti-body.com/images/nav/contact.jpg","http://www.anti-body.com/images/nav/contact.jpg",-1,-1,0,"http://www.anti-body.com/contact/"]);
	
	stm_ep();
	stm_em();
	showFloatMenuAt('drowpdown',0,0);
}


function DropDownM()
{
	stm_bm(["drowpdown",850,"","http://www.anti-body.com/images/nav/blank.gif",0,"","",0,0,250,0,1000,1,0,0,"","",67108865,0,1,2,"hand","hand","http://www.anti-body.com/"],this);
	stm_bp("p0",[0,4,0,0,0,0,0,0,100,"",-2,"",-2,50,0,0,"#999999","#c6ab8e","",3,0,0,"#000000"]);
	stm_ai("p0i0",[2,"","http://www.anti-body.com/images/nav/about.jpg","http://www.anti-body.com/images/nav/about.jpg",71,29,0,"http://www.anti-body.com/about/","_self","","","","",0,0,0,"http://www.anti-body.com/images/nav/arrow_r.gif","http://www.anti-body.com/images/nav/arrow_r.gif",0,0,0,0,1,"#c6ab8e",1,"#c6ab8e",1,"","",3,3,0,0,"#E6EFF9","#000000","#000000","#000000","8pt Verdana","8pt Verdana",0,0]);
	stm_bp("p1",[1,4,0,0,2,3,0,0,100,"",-2,"",-2,50,0,0,"#999999","#c6ab8e","",3,1,1,"#c6ab8e"]);
	stm_aix("p1i0","p0i0",[0,"Careers","","",-1,-1,0,"http://www.anti-body.com/about/careers/","_self","","","","",0,0,0,"http://www.anti-body.com/images/nav/arrow_r.gif","http://www.anti-body.com/images/nav/arrow_r.gif",0,0,0,0,1,"#c6ab8e",0,"#c6ab8e",0,"","",3,3,0,0,"#673500 #c6ab8e #c6ab8e  #c6ab8e","#673500 #c6ab8e #c6ab8e  #c6ab8e"],150,20);
	stm_bpx("p2","p1",[1,2]);
	
	stm_ai("p2i1",[6,1,"#673500","",-1,-1,0]);
	stm_aix("p2i2","p2i0",[0,"Career Opportunities","","",-1,-1,0,"http://www.anti-body.com/about/careers/opportunities/"],150,20);
	stm_aix("p2i3","p2i1",[]);
	stm_aix("p2i4","p2i0",[0,"Internships","","",-1,-1,0,"http://www.anti-body.com/about/careers/internships/"],150,20);
	stm_aix("p2i5","p2i1",[]);
	stm_aix("p2i6","p2i0",[0,"Commitments","","",-1,-1,0,"http://www.anti-body.com/about/careers/commitments/"],150,0);
	stm_ep();
	stm_aix("p1i1","p2i1",[]);
	stm_aix("p1i2","p1i0",[0,"Media","","",-1,-1,0,"http://www.anti-body.com/about/media/"],150,20);
	stm_bpx("p3","p2",[]);
	//stm_aix("p3i0","p2i0",[0,"Film Screenings","","",-1,-1,0,"http://www.anti-body.com/events/screenings/"],150,20);
	//stm_aix("p3i1","p2i1",[]);
	stm_aix("p3i2","p2i0",[0,"On the Small Screen","","",-1,-1,0,"http://www.anti-body.com/about/media/screen/"],150,20);
	stm_aix("p3i3","p2i1",[]);
	stm_aix("p3i4","p2i0",[0,"Press Releases","","",-1,-1,0,"http://www.anti-body.com/about/media/releases/"],150,20);
	stm_aix("p3i5","p2i1",[]);
	stm_aix("p3i6","p2i0",[0,"In the Press","","",-1,-1,0,"http://www.anti-body.com/about/media/press/"],150,0);
	stm_bpx("p8","p2",[]);
	stm_aix("p8i8","p8i0",[0,"Press Kit","","",-1,-1,0,"http://www.anti-body.com//data/press_kit.zip"],150,0);
	stm_ep();
	stm_aix("p1i3","p2i1",[]);
	stm_aix("p1i4","p2i0",[0,"Affiliates","","",-1,-1,0,"http://www.anti-body.com/about/affiliates/"],150,20);
	stm_ep();
	stm_aix("p0i1","p0i0",[2,"","http://www.anti-body.com/images/nav/fairtrade.jpg","http://www.anti-body.com/images/nav/fairtrade.jpg",-1,-1,0,"http://www.anti-body.com/fairtrade/","_self","","","","",0,0,0,"http://www.anti-body.com/images/nav/arrow_r.gif","http://www.anti-body.com/images/nav/arrow_r.gif",0,0,0,0,1,"#c6ab8e",0,"#c6ab8e",0]);
	stm_bpx("p4","p1",[]);
	stm_aix("p4i0","p0i1",[0,"About","","",-1,-1,0,"http://www.anti-body.com/fairtrade/","_self","","","","",0,0,0,"",""],150,20);
	stm_aix("p4i1","p2i1",[]);
	stm_aix("p4i2","p4i0",[0,"Togo, Africa","","",-1,-1,0,"http://www.anti-body.com/fairtrade/togo/"],150,20);
	stm_aix("p4i3","p2i1",[]);
	stm_aix("p4i4","p4i0",[0,"Liberia, Africa","","",-1,-1,0,"http://www.anti-body.com/fairtrade/liberia/"],150,20);
	stm_aix("p4i5","p2i1",[]);
	stm_aix("p4i6","p4i0",[0,"Certified","","",-1,-1,0,"http://www.anti-body.com/fairtrade/certified/"],150,20);
	stm_aix("p4i7","p2i1",[]);
	stm_aix("p4i8","p4i0",[0,"Memberships","","",-1,-1,0,"http://www.anti-body.com/fairtrade/members/"],150,20);
	stm_ep();
	stm_aix("p0i2","p0i1",[2,"","http://www.anti-body.com/images/nav/events.jpg","http://www.anti-body.com/images/nav/events.jpg",-1,-1,0,"http://www.anti-body.com/events/"]);
	stm_bpx("p5","p1",[]);
	stm_aix("p5i0","p4i0",[0,"Speaking","","",-1,-1,0,"http://www.anti-body.com/events/speaking/"],150,20);
	stm_aix("p5i1","p2i1",[]);
	//stm_aix("p5i2","p4i0",[0,"In-Store","","",-1,-1,0,"http://www.anti-body.com/events/instore/"],150,20);
	//stm_aix("p5i3","p2i1",[]);
	stm_aix("p5i4","p4i0",[0,"In-Home","","",-1,-1,0,"http://www.anti-body.com/events/inhome/"],150,20);
	stm_aix("p5i5","p2i1",[]);
	stm_aix("p5i6","p4i0",[0,"Documentary","","",-1,-1,0,"http://www.anti-body.com/events/screenings/"],150,20);
	stm_ep();
	stm_aix("p0i3","p0i1",[2,"","http://www.anti-body.com/images/nav/wholesale.jpg","http://www.anti-body.com/images/nav/wholesale.jpg",-1,-1,0,"http://www.anti-body.com/wholesale/"]);
	stm_bpx("p6","p1",[]);
	stm_aix("p6i0","p4i0",[0,"Auto-Reorder Form","","",-1,-1,0,"auto_reorder.php"],150,20);
	stm_aix("p6i1","p2i1",[]);
	stm_aix("p6i2","p4i0",[0,"Private Label","","",-1,-1,0,"http://www.anti-body.com/wholesale/privatelabels/"],150,20);
	stm_aix("p6i3","p2i1",[]);
	stm_aix("p6i4","p4i0",[0,"New Accounts","","",-1,-1,0,"http://www.anti-body.com/wholesale/newaccounts/"],150,20);
	stm_ep();
	stm_aix("p0i4","p0i1",[2,"","http://www.anti-body.com/images/nav/community.jpg","http://www.anti-body.com/images/nav/community.jpg",-1,-1,0,"http://www.anti-body.com/community/"]);
	stm_bpx("p7","p1",[]);
	stm_aix("p7i0","p4i0",[0,"Get Caught!","","",-1,-1,0,"http://www.anti-body.com/community/caught/"],150,20);
	stm_aix("p7i1","p2i1",[]);
	stm_aix("p7i2","p4i0",[0,"Campaigns","","",-1,-1,0,"http://www.anti-body.com/coconut/"],150,20);
	stm_aix("p7i3","p2i1",[]);
	stm_aix("p7i4","p4i0",[0,"Customize","","",-1,-1,0,"http://www.anti-body.com/community/customize/"],150,20);
	stm_aix("p7i5","p2i1",[]);
	stm_aix("p7i6","p4i0",[0,"Blog","","",-1,-1,0,"http://antibody.wordpress.com"],150,20);
	stm_ep();
	stm_aix("p0i5","p4i0",[2,"","http://www.anti-body.com/images/nav/contact.jpg","http://www.anti-body.com/images/nav/contact.jpg",-1,-1,0,"http://www.anti-body.com/contact/"]);
	
	stm_ep();
	stm_em();
	showFloatMenuAt('drowpdown',0,0);
}

var timeout;
var ts = 10;
var ms = 2;
function Gallery()
{
	if(!document.getElementById('nxt') || 
	   !document.getElementById('prv') || 
	   !document.getElementById('gallery'))
	   return;
	   
	var next = document.getElementById('nxt');
	var previous = document.getElementById('prv');
	var gallery = document.getElementById('gallery');
	var item = gallery.getElementsByTagName('li');
	var slider = document.getElementById('slider');
	var zoomin = document.getElementById('zoomin');
	var descr = document.getElementById('imagedesc');
	slider.style.marginLeft = '0px';
	
	next.onmouseover = function()
	{
		timeout = setTimeout(moveLeft,ts);
	}
	
	next.onmouseout = function()
	{
		clearTimeout(timeout);
	}
	
	previous.onmouseover = function()
	{
		timeout = setTimeout(moveRight,ts);
	}
	
	previous.onmouseout = function()
	{


		clearTimeout(timeout);
	}
	
	var images = slider.getElementsByTagName('a');
	for(var i=0; i<images.length; i++)
	{
		images[i].onclick = function()
		{
			var list = this.getElementsByTagName('img')[0].src.split('/');
			var image = list[list.length-1];			
			zoomin.src = 'http://www.anti-body.com/images/fairtrade/gallery/large/' + image;
			descr.src = 'http://www.anti-body.com/images/fairtrade/gallery/text/' + image;
		}
	}
	
}

function abs(num)
{
	return num>=0?num:(-1*num);
}

function moveLeft()
{
	var next = document.getElementById('nxt');
	var previous = document.getElementById('prv');
	var gallery = document.getElementById('gallery');
	var item = gallery.getElementsByTagName('li');
	var slider = document.getElementById('slider');

	var cellWidth = (item.length*(73+10))-10;
	var margin = parseInt(slider.style.marginLeft);
	if((cellWidth-(abs(margin)+154)) >=0 && item.length > 2)
	{
		slider.style.marginLeft = parseInt(slider.style.marginLeft)-ms+'px';
		timeout = setTimeout(moveLeft,ts);
	}
	else
		clearTimeout(timeout);
}

function moveRight()
{
	var next = document.getElementById('nxt');
	var previous = document.getElementById('prv');
	var gallery = document.getElementById('gallery');
	var item = gallery.getElementsByTagName('li');
	var slider = document.getElementById('slider');
	
	var cellWidth = (item.length*(73+10))-10;
	var margin = parseInt(slider.style.marginLeft);
	if(margin<0 && (cellWidth-margin)>0 && item.length > 2)
	{	
		slider.style.marginLeft = parseInt(slider.style.marginLeft)+ms+'px';
		timeout = setTimeout(moveRight,ts);
	}
	else
		clearTimeout(timeout);
}
// Custom func for top cat

function cat_over(id)	{
	document.getElementById('subcatbox_'+id).style.display = '';
}

function cat_out(id)	{
	document.getElementById('subcatbox_'+id).style.display = 'none';
}

function NewsList()
{
	if(!document.getElementById('newslist') || 
	   !document.getElementById('newsimage'))
		return;
		
	var root = document.getElementById('newslist');
	var item = root.getElementsByTagName('li');
	if(item.length < 2) return;
	
	var update = document.getElementById('newsimage');
	var previous = item[0].getElementsByTagName('img')[0].src

	for(var i=1; i<item.length; i++)
	{
		var link  = item[i].getElementsByTagName('a')[0];

		link.onmouseover = function()
		{
			update.src = this.parentNode.getElementsByTagName('img')[0].src;
		}
		
		link.onmouseout = function()
		{
			update.src = previous;
		}
	}
}

function Bios()
{
	if(!document.getElementById('bios')) return;
	var bios = document.getElementById('bios');
	var images = bios.getElementsByTagName('img');
	for(var i=0; i<images.length; i++)
	{
	 	var image = images[i];
	 	var prevous = '';
		image.onmouseover = function()
		{
		 	var list = this.src.split('/');
		 	previous = "http://www.anti-body.com/images/about/" + list[list.length-1].split('.')[0];
			this.src = previous + "_rollover.jpg";
		}
	 	image.onmouseout = function()
	 	{
			this.src = previous + ".jpg";
		}
	}
}

/****************************************************
     Author: Eric King
     Url: http:/redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http:/www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos)
{
	if(pos=="random")
	{
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="center")
	{
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	else 
		if((pos!="center" && pos!="random") || pos==null)
		{
			LeftPosition=0;
			TopPosition=20;
		}
	settings='width='+w+
			 ',height='+h+
			 ',top='+TopPosition+
			 ',left='+LeftPosition+
			 ',scrollbars='+scroll+
			 ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
}

function Popups()
{
	if(document.getElementById('promo')) 
	{
		var promo = document.getElementById('promo');
		promo.onclick = function()
		{
			NewWindow('http://www.anti-body.com/video/promo.html','abwindow','359','249','no','center');
			return false;
		}
	}
	if(document.getElementById('promo_comming')) 
	{
		var promo = document.getElementById('promo_comming');
		promo.onclick = function()
		{
			NewWindow('http://www.anti-body.com/video/promo_comming.html','abwindow','500','400','no','center');
			return false;
		}
	}

	if(document.getElementById('promo2'))
	{
		var promo2 = document.getElementById('promo2');
		promo2.onclick = function()
		{
			NewWindow('http://www.anti-body.com/video/promo2.html','abwindow','500','400','no','center');
			return false;
		}
	}
	if(document.getElementById('promo3'))
	{
		var promo2 = document.getElementById('promo3');
		promo2.onclick = function()
		{
			NewWindow('http://www.anti-body.com/video/promo3.html','abwindow','440','360','no','center');
			return false;
		}
	}
if(document.getElementById('promo4'))
	{
		var promo2 = document.getElementById('promo4');
		promo2.onclick = function()
		{
			NewWindow('http://www.anti-body.com/video/promo4.html','abwindow','440','360','no','center');
			return false;
		}
	}
	if(document.getElementById('schedule'))
	{
		var schedule = document.getElementById('schedule');
		schedule.onclick = function()
		{
			NewWindow('http://www.anti-body.com/video/schedule.html','abwindow','500','400','no','center');
			return false;
		}
	}	
	
	if(document.getElementById('events_documentary'))
	{
		var events_documentary = document.getElementById('events_documentary');
		events_documentary.onclick = function()
		{
			NewWindow('http://www.anti-body.com/video/events_documentary.html','abwindow','425','355','no','center');
			return false;
		}
	}
	
	if(document.getElementById('liberian_popup'))
        {
                var events_documentary = document.getElementById('liberian_popup');
                events_documentary.onclick = function()
                {
                        NewWindow('http://dev.anti-body.com/video/liberian.html','abwindow','425','350','no','center');
                        return false;
                }
        }
	
	if(document.getElementById('tax_popup'))
        {
                var events_documentary = document.getElementById('tax_popup');
                events_documentary.onclick = function()
                {
                        NewWindow('http://anti-body.com/video/tax.html','abwindow','500','400','no','center');
                        return false;
                }
        }

}
