// 2010-07-08 - JRM
// Add a product preview and read more functionality
// Using height scalling as trimming the rich text leads to 
// problems with <tags> and &escape; chars being erroneously 
// displayed.
jQuery(document).ready( function(){

// Select the product description
var pd = jQuery('#productDescription');
// Set the desired height of the preview
var height = 110;

// Rev1 testing on the css property
if(pd.height() != undefined){
//if(pd.css('height') != undefined){
    //var productDescHeight = pd.css('height').split("px")[0];
    var productDescHeight = pd.height();

    if (productDescHeight > height){
        var readMore = '<a id="readmore" href="#">Read More</a>';
        //pd.css('height', height+'px').css('overflow', 'hidden').after(readMore);
        pd.height(height).css('overflow', 'hidden').after(readMore);

        jQuery('#readmore').click(function(){
            var pd = jQuery('#productDescription');
            //pd.css('height', (pd.css('height') == height+'px') ? '' : height+'px');
            pd.height((pd.height() == height) ? '' : height);
            var link = jQuery(this);
            link.html((link.html() == "Read More") ? "Read Less" : "Read More");
            return false;  // stop page scrolling
            });
    }
}

});

