﻿$("#results").ready(function(){
    $("#results").attr("cellpadding", "0").attr("cellspacing", "1");
    
    var szBtn = '<a href="#" class="btn" onclick="ExpandProperty(this); return false;"><img src="/images/dot-clear.gif" width="1" height="1" alt="" /></a>';
    var szIcon = '<img src="/myvado/images/products/compare/icon_select.gif" width="5" height="5" alt="">'
    $("#results .propertyCategory td").each(function(){
        this.innerHTML = szBtn + this.innerHTML;
    });
    $("#results .propertyValue").each(function(){
        var szPropertyValue = this.innerHTML.replace(/(^\s*)|(\s*$)/g,"");
        if (szPropertyValue=="Yes")
        {
            this.innerHTML = szIcon;
        } else{
            if (szPropertyValue=="-")
                this.innerHTML = "";
        } 
    });
    
    $("#results tr.property").css("display","none");
    $("#results a.btn").each(function(){
        $(this).click();
    });
    
    PutNotes();
});

function ExpandProperty( obLink )
{
    var $propertyCategoryName = $(obLink).parent();
    var $propertyCategory = $propertyCategoryName.parent();
    if ( $propertyCategoryName.hasClass("highlighted"))
    {
        $propertyCategoryName.removeClass("highlighted");
        $(obLink).removeClass("highlighted");
        PropertyItem($propertyCategory.next(), 0);
    }else{
        $propertyCategoryName.addClass("highlighted");
        $(obLink).addClass("highlighted");
        PropertyItem($propertyCategory.next(), 1);
    }
    
}
function PropertyItem(obProperty, nAction)
{
    var szDisplayValue = nAction==1 ? "":"none";
    $(obProperty).css("display", szDisplayValue);
    
    if($(obProperty).next().hasClass("property"))
        PropertyItem($(obProperty).next(), nAction);
}

function PutNotes()
{
    //note 1
    $("#results .propertyCategory31 .propertyValue").each(function(){
        var szHtml = $(this).html().replace(/(^\s*)|(\s*$)/g,"");
        if (szHtml=='2GB'|| szHtml=='8GB'|| szHtml=='4GB' )
        {
            $(this).html( szHtml+'<sup>1</sup>' );
        }
    });
    $(".notes").append("<li>Memory includes built-in software.</li>");    
    
    //note 2
    $("#results .propertyCategory34 .propertyValue").each(function(){
        var szHtml = $(this).html().replace(/(^\s*)|(\s*$)/g,"");
        if (szHtml=='Up to 130 minutes'|| szHtml=='Up to 120 minutes' )
        {
            $(this).html( szHtml+'<sup>2</sup>' );
        }
    });
    $(".notes").append("<li>Actual battery life will vary with use. Battery has limited recharge cycles and may eventually need to be replaced.</li>");   
    
    //note 3
    $("#results .propertyCategory36 .propertyValue").each(function(){
        var szHtml = $(this).html().replace(/(^\s*)|(\s*$)/g,"");
        if (szHtml.indexOf('(Vado Central not compatible)')>-1 )
        {
            $(this).html( szHtml+'<sup>3</sup>' );
        }
    });
    $(".notes").append("<li>Mac functionality limited to importing files from Vado/Vado HD and using them with QuickTime player and suitable video codecs. Vado Central software is not compatible with Mac OS.</li>");   
    
    //note 4
//    $("#results .propertyCategory36 .propertyValue").each(function(){
//        var szHtml = $(this).html().replace(/(^\s*)|(\s*$)/g,"");
//        if (szHtml.indexOf('QuickTime with a suitable video codec')>-1 )
//        {
//            $(this).html( szHtml.replace(/codec/g,"<sup>4</sup>") );
//        }
//    });
//    $(".notes").append("<li>Users can install Perian 1.1.2 from http://www.perian.org/ to view Vado HD videos.</li>");

    //note 4
    $("#results .propertyCategory37 .propertyValue").each(function(){
        var szHtml = $(this).html().replace(/(^\s*)|(\s*$)/g,"");
        if (szHtml.indexOf('Rechargeable Battery')>-1 )
        {
            $(this).html( szHtml+'<sup>4</sup>' );
        }
    });
    $(".notes").append("<li>Available in certain regions. Package contents may vary according to the different regions. Please check with your local representatives or offices for product availability.</li>");
}

