/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category  Symmetrics
 * @package   Symmetrics_CatDescriptionShort
 * @author    Symmetrics GmbH <info@symmetrics.de>
 * @author    Eric Reiche <er@symmetrics.de>
 * @copyright 2009 Symmetrics GmbH
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 * @link      http://www.symmetrics.de/
 */

Event.observe(window, 'load', function() {
    var paragraph2toggle = false;
    descriptionElements = $$('.col-main div.category-description');
    descriptionElement = descriptionElements[0];
    if (descriptionElement) {
        descriptionText = descriptionElement.innerHTML;
        if (descriptionText.length > desccharcount && desccharcount != '') {
            descriptionArray = new Array();
            descriptionArray[1] = descriptionText.substr(0, desccharcount);
            descriptionArray[2] = descriptionText.substr(desccharcount, descriptionText.length);
            
            descriptionElement.innerHTML = descriptionArray[1];
            morebutton = '<a href="javascript:;" id="catdescmore">' + descmorelink + '</a>';
            lessbutton = '<a href="javascript:;" id="catdescless">' + desclesslink + '</a>';
             
            descriptionElement.insert({
                'after' : morebutton
            });
            descriptionElement.insert({
                'after' : lessbutton
            });
             
            $('catdescmore').style.display = 'inline';
            $('catdescless').style.display = 'none';
        
            Event.observe($('catdescmore'), 'click', function() {
                descriptionElement.innerHTML = descriptionArray[1] + descriptionArray[2];
                $('catdescmore').style.display = 'none';
                $('catdescless').style.display = 'inline';
            });
            
            Event.observe($('catdescless'), 'click', function() {
                descriptionElement.innerHTML = descriptionArray[1];
                $('catdescmore').style.display = 'inline';
                $('catdescless').style.display = 'none';
            });
        }
    }
});

