/*
 * VERSION: @version $Id: fxfontplus.js 2008-04-29 15:00 $
 * PACKAGE: @package Theme Joomla Template - Color Fusion
 * COPYRIGHT: @copyright Copyright (C) 2008 Theme Joomla. All rights reserved. E & OE
 * INFO: This is a modified version created specifically for our templates.
 * Please visit our site www.themejoomla.com and read our terms and conditions for more info.
 *
 * SCRIPT: fxfontplus.js
 * SCRIPT LICENSE: Fx.FontPlus is MIT-Licensed
 * SCRIPT COPYRIGHT: @copyright Copyright (C) 2008 Theme Joomla. All rights reserved. E & OE
 * SCRIPT CREDITS: script by Bas Wenneker (http://www.solutoire.com) used with Theme Joomla Template - Color Fusion
 */

Fx.FontPlus = new Class({
  initialize: function(elements, sid, gid, gmid, growsize, growmoresize){
    this.growsize = (growsize) ? growsize : 2;
    this.growmoresize = (growmoresize) ? growmoresize : 3;

    this.elements = [];
     elements.each(function(el){
      this.elements.push([el,el.getStyle('font-size').toInt()]);
    },this);

    $(gmid).onclick = function(){this.growmore()}.bind(this);
    $(gid).onclick = function(){this.grow()}.bind(this);
    $(sid).onclick = function(){this.shrink()}.bind(this);
  },

  growmore: function(){
    this.elements.each(function(el){
      var currentfsize = el[0].getStyle('font-size').toInt();
      if(currentfsize == el[1])
        el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1],el[1]+this.growmoresize);
      else if(currentfsize == el[1]+this.growsize)
        el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growsize,el[1]+this.growmoresize);
    },this);
  },

  grow: function(){
    this.elements.each(function(el){
      var currentfsize = el[0].getStyle('font-size').toInt();
      if(currentfsize == el[1])
        el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1],el[1]+this.growsize);
      else if(currentfsize == el[1]+this.growmoresize)
        el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growmoresize,el[1]+this.growsize);
    },this);
  },

  shrink: function(){
    this.elements.each(function(el){
      var currentfsize = el[0].getStyle('font-size').toInt();
      if(currentfsize == el[1]+this.growsize)
        el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growsize, el[1]);
      else if(currentfsize == el[1]+this.growmoresize)
        el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growmoresize, el[1]);
    },this);
  }
});

window.addEvent('domready', function(){
  try {
    font = new Fx.FontPlus($$('#main_content'),$('shrink'),$('grow'),$('growmore'));
  } catch (err) {}
});
