function showMore(infoIdToClose, linkIdToClose, infoIdToShow, linkIdToOpen)
{
    document.getElementById(infoIdToClose).style.display = 'none';
    document.getElementById(linkIdToClose).style.display = 'none';
    document.getElementById(infoIdToShow).style.display = '';
    document.getElementById(linkIdToOpen).style.display = '';
    document.getElementById(linkIdToOpen).style.cursor = 'pointer';
    document.getElementById(linkIdToOpen).style.textDecoration = 'underline';
}

//  ============================ Begin Compare Functionality =============================
var compareValues;

function setMessageOnLoad(maxProductsToCompare, txtComparisonId, compareLabel)
{
    var txtCompareValues = document.getElementById(txtComparisonId);
    if (txtCompareValues != null)
    {
        var arrayNoOfElements = txtCompareValues.value.split("|");
        var lblCompare = document.getElementById(compareLabel);

        if (txtCompareValues.value == "")
        {
            lblCompare.innerHTML = productCount(0, maxProductsToCompare);
        }
        else
        {
            lblCompare.innerHTML = productCount(arrayNoOfElements.length, maxProductsToCompare);
        }
    }
    
} 

function compareClick(sender, id, txtComparisonId, compareLabel, maxProductsToCompare)
{   
    var txtCompareValues = document.getElementById(txtComparisonId);
    var lblCompare = document.getElementById(compareLabel);
    
    if(sender.checked)
    {
        if (txtCompareValues.value == "")
        {
            txtCompareValues.value += id;
        }
        else
        {
            txtCompareValues.value += "|" + id;
        }
        
        var arrayNoOfElements = txtCompareValues.value.split("|");
        
        lblCompare.innerHTML = productCount(arrayNoOfElements.length, maxProductsToCompare);
    
        if (arrayNoOfElements != null)
        {
            if (arrayNoOfElements.length == maxProductsToCompare)
            {
                disableCheckboxes();
            }
        }
    }
    else
    {
        var selectionArray = txtCompareValues.value.split("|");
        
        var arrayPosition = selectionArray.indexOf(id); 
        
        txtCompareValues.value = "";
        
        for (var i = 0; i < selectionArray.length; i++)
        {
            if (i != arrayPosition)
            {
                if (txtCompareValues.value.length == 0)
                {
                    txtCompareValues.value += selectionArray[i];
                }
                else
                {
                    txtCompareValues.value += "|" + selectionArray[i];
                }
            }
        }
        
        lblCompare.innerHTML = productCount(selectionArray.length - 1, maxProductsToCompare);
        
        enableCheckboxes();
    }
    
}

function productCount(count, maxProductsToCompare)
{
    var text;
    var productsSelected;
    productsSelected = maxProductsToCompare - count;
    
    if (count == 0)
    {
        text = "Tick to compare up to " + maxProductsToCompare + " products side by side";
    } 
    else if (maxProductsToCompare == count)
    {
        text = "Click compare to view selections";
    }
    else if (productsSelected == 1)
    {
        text = "Tick to compare up to 1 more product";
    }
    else
    {
        text = "Tick to compare up to " + productsSelected + " more products"; 
    }
    
    return text;
}


function disableCheckboxes() 
{
    for(i=0; i<document.mainForm.elements.length; i++)
    {
        if(document.mainForm.elements[i].type == "checkbox")
        {
            if (document.mainForm.elements[i].checked == false)
            {
                document.mainForm.elements[i].disabled = true;
                
                // Check IE
                if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
                {
                    document.mainForm.elements[i].parentElement.disabled = true;
                }
            }
        }
    }
}

function enableCheckboxes()
{
    for(i=0; i<document.mainForm.elements.length; i++)
    {
        if(document.mainForm.elements[i].type == "checkbox")
        {
            document.mainForm.elements[i].disabled = false;
            
            // Check IE
            if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
            {
                document.mainForm.elements[i].parentElement.disabled = false;
            }
        }
    }
}
//  ============================ End Compare Functionality =============================

//  ============================ Begin Filter Functionality =============================

var $jq = jQuery.noConflict(); 

function ToggleSlide(idOfFurtherContent,caller,expandImage,collapseImage)
{
	$jq('#'+idOfFurtherContent).slideToggle("slow")
	
	var $this = $jq(caller);		
	
	if($this.attr("src") == expandImage)
	{
		$this.attr("src",collapseImage);
	}else if($this.attr("src") == collapseImage)
	{
		$this.attr("src",expandImage);
	}			
}

//  ============================ End Filter Functionality =============================