if(!window.JSFX)
	JSFX=new Object();
JSFX.ImageZoomRunning = false;
/*****
* Function    : zoomIn
*			null		->	OFF.
*			OFF		->	ZOOM_IN + start timer
*			ZOOM_OUT	->	ZOOM_IN
*			ZOOM_IN_OUT	->	ZOOM_IN
*****/
JSFX.zoomOn = function(img, zoomStep, maxZoom)
{
	if(img)
	{
		if(!zoomStep)
		{
			if(img.mode == "EXPAND")
				zoomStep = img.height/5.5;
			else
				zoomStep = img.width/5.5;
		}

		if(!maxZoom)
		{
			if(img.mode == "EXPAND")
				maxZoom = img.height/1;
			else
				maxZoom = img.width/1;
		}


		if(img.state == null)
		{
			img.state = "OFF";;
			img.index = 0;
			img.orgWidth =  img.width;
			img.orgHeight = img.height;
			img.zoomStep = zoomStep;
			img.maxZoom  = maxZoom;
		}

		if(img.state == "OFF")
		{
			img.state = "ZOOM_IN";
			start_zooming();
		}
		else if( img.state == "ZOOM_IN_OUT"
			|| img.state == "ZOOM_OUT")
		{
			img.state = "ZOOM_IN";
		}
	}
}
JSFX.zoomIn = function(img, zoomStep, maxZoom)
{
	img.mode = "ZOOM";
	JSFX.zoomOn(img, zoomStep, maxZoom);
}
JSFX.stretchIn = function(img, zoomStep, maxZoom)
{
	img.mode = "STRETCH";
	JSFX.zoomOn(img, zoomStep, maxZoom);
}
JSFX.expandIn = function(img, zoomStep, maxZoom)
{
	img.mode = "EXPAND";
	JSFX.zoomOn(img, zoomStep, maxZoom);
}
/*****
* Function    : zoomOut
*			ON		->	ZOOM_OUT + start timer
*			ZOOM_IN	->	ZOOM_IN_OUT.
*****/
JSFX.zoomOut = function(img)
{
	if(img)
	{
		if(img.state=="ON")
		{
			img.state="ZOOM_OUT";
			start_zooming();
		}
		else if(img.state == "ZOOM_IN")
		{
			img.state="ZOOM_IN_OUT";
		}
	}
}
/*****
* Function    : start_zooming
*****/
function start_zooming()
{
	if(!JSFX.ImageZoomRunning)
		ImageZoomAnimation();
}

JSFX.setZoom = function(img)
{
	if(img.mode == "STRETCH")
	{
		img.width  = img.orgWidth  + img.index;
		img.height = img.orgHeight;
	}
	else if(img.mode == "EXPAND")
	{
		img.width  = img.orgWidth;
		img.height = img.orgHeight + img.index;
	}
	else
	{
		img.width  = img.orgWidth   + img.index;
		img.height = img.orgHeight  + (img.index * (img.orgHeight/img.orgWidth));
	}
}
/*****
* Function    : ImageZoomAnimation
*****/
function ImageZoomAnimation()
{
	JSFX.ImageZoomRunning = false;
	for(i=0 ; i<document.images.length ; i++)
	{
		var img = document.images[i];
		if(img.state)
		{
			if(img.state == "ZOOM_IN")
			{
				img.index+=img.zoomStep;
				if(img.index > img.maxZoom)
					img.index = img.maxZoom;

				JSFX.setZoom(img);

				if(img.index == img.maxZoom)
					img.state="ON";
				else
					JSFX.ImageZoomRunning = true;
			}
			else if(img.state == "ZOOM_IN_OUT")
			{
				img.index+=img.zoomStep;
				if(img.index > img.maxZoom)
					img.index = img.maxZoom;

				JSFX.setZoom(img);
	
				if(img.index == img.maxZoom)
					img.state="ZOOM_OUT";
				JSFX.ImageZoomRunning = true;
			}
			else if(img.state == "ZOOM_OUT")
			{
				img.index-=img.zoomStep;
				if(img.index < 0)
					img.index = 0;

				JSFX.setZoom(img);

				if(img.index == 0)
					img.state="OFF";
				else
					JSFX.ImageZoomRunning = true;
			}
		}
	}
	/*** Check to see if we need to animate any more frames. ***/
	if(JSFX.ImageZoomRunning)
		setTimeout("ImageZoomAnimation()", 30);
}
/*****
* Function    : PAGE SCROLL
******/

var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;
  
    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    if (!destinationLink) destinationLink = document.getElementById(anchor);

    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;
  
    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    // Stop any current scrolling
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 25;

ss.addEvent(window,"load",ss.fixAllLinks);


/*****
* Function    : menuIn
*			null		->	OFF.
*			OFF		->	menu_IN + start timer
*			menu_OUT	->	menu_IN
*			menu_IN_OUT	->	menu_IN
*****/
JSFX.menuOn = function(img, menuStep, maxmenu)
{
	if(img)
	{
		if(!menuStep)
		{
			if(img.mode == "EXPAND")
				menuStep = img.height/6;
			else
				menuStep = img.width/6;
		}

		if(!maxmenu)
		{
			if(img.mode == "EXPAND")
				maxmenu = img.height/1.5;
			else
				maxmenu = img.width/1.5;
		}


		if(img.state == null)
		{
			img.state = "OFF";
			img.index = 0;
			img.orgWidth =  img.width;
			img.orgHeight = img.height;
			img.menuStep = menuStep;
			img.maxmenu  = maxmenu;
		}

		if(img.state == "OFF")
		{
			img.state = "menu_IN";
			start_menuing();
		}
		else if( img.state == "menu_IN_OUT"
			|| img.state == "menu_OUT")
		{
			img.state = "menu_IN";
		}
	}
}
JSFX.menuIn = function(img, menuStep, maxmenu)
{
	img.mode = "menu";
	JSFX.menuOn(img, menuStep, maxmenu);
}
JSFX.stretchIn = function(img, menuStep, maxmenu)
{
	img.mode = "STRETCH";
	JSFX.menuOn(img, menuStep, maxmenu);
}
JSFX.expandIn = function(img, menuStep, maxmenu)
{
	img.mode = "EXPAND";
	JSFX.menuOn(img, menuStep, maxmenu);
}
/*****
* Function    : menuOut
*			ON		->	menu_OUT + start timer
*			menu_IN	->	menu_IN_OUT.
*****/
JSFX.menuOut = function(img)
{
	if(img)
	{
		if(img.state=="ON")
		{
			img.state="menu_OUT";
			start_menuing();
		}
		else if(img.state == "menu_IN")
		{
			img.state="menu_IN_OUT";
		}
	}
}
/*****
* Function    : start_menuing
*****/
function start_menuing()
{
	if(!JSFX.ImagemenuRunning)
		ImagemenuAnimation();
}

JSFX.setmenu = function(img)
{
	if(img.mode == "STRETCH")
	{
		img.width  = img.orgWidth  + img.index;
		img.height = img.orgHeight;
	}
	else if(img.mode == "EXPAND")
	{
		img.width  = img.orgWidth;
		img.height = img.orgHeight + img.index;
	}
	else
	{
		img.width  = img.orgWidth   + img.index;
		img.height = img.orgHeight  + (img.index * (img.orgHeight/img.orgWidth));
	}
}
/*****
* Function    : ImagemenuAnimation
*****/
function ImagemenuAnimation()
{
	JSFX.ImagemenuRunning = false;
	for(i=0 ; i<document.images.length ; i++)
	{
		var img = document.images[i];
		if(img.state)
		{
			if(img.state == "menu_IN")
			{
				img.index+=img.menuStep;
				if(img.index > img.maxmenu)
					img.index = img.maxmenu;

				JSFX.setmenu(img);

				if(img.index == img.maxmenu)
					img.state="ON";
				else
					JSFX.ImagemenuRunning = true;
			}
			else if(img.state == "menu_IN_OUT")
			{
				img.index+=img.menuStep;
				if(img.index > img.maxmenu)
					img.index = img.maxmenu;

				JSFX.setmenu(img);
	
				if(img.index == img.maxmenu)
					img.state="menu_OUT";
				JSFX.ImagemenuRunning = true;
			}
			else if(img.state == "menu_OUT")
			{
				img.index-=img.menuStep;
				if(img.index < 0)
					img.index = 0;

				JSFX.setmenu(img);

				if(img.index == 0)
					img.state="OFF";
				else
					JSFX.ImagemenuRunning = true;
			}
		}
	}
	/*** Check to see if we need to animate any more frames. ***/
	if(JSFX.ImagemenuRunning)
		setTimeout("ImagemenuAnimation()", 40);
}