﻿// JScript File    
function CompareProducts(url)
{
    // loop thru the inputs on the page, construct the url and refresh the page
    var cbArray = document.getElementsByName("cprItem");
    var selectionList = '';
        
    for(var x = 0; x < cbArray.length; x++ )
    {        
        if(cbArray[x].className = 'cpritem' && cbArray[x].checked == true)
        {
            selectionList += cbArray[x].id.substring(2,cbArray[x].id.length) + '|';
        }
    }
    
    if(selectionList.length > 0)
    {
        // strip the trailing pipe
        selectionList = selectionList.substring(0,selectionList.length - 1);
        
        // send them to the right page
        window.location.href = url + "?compare=" + selectionList
    }
    else
    {
        alert('You must select products to compare');
    }
    
}
