function refineBySearchType(searchType)
{
	document.paginateSearchForm.searchType.value = searchType; 
    document.paginateSearchForm.submit();	        
}    

function refineByContentType(contentType)
{
	document.paginateSearchForm.contentType.value = contentType; 
	document.paginateSearchForm.productFilter.value = ''; 
	document.paginateSearchForm.rpp.value = ''; 
	document.paginateSearchForm.Nf.value = ''; 	
	document.paginateSearchForm.Ns.value = ''; 				
	
	if (contentType == 'PRODUCT')
	{
		document.paginateSearchForm.Ntk.value = 'Product'; 
		document.paginateSearchForm.navigation.value = 'NULL'; 
	} else if (contentType == 'CONTENT')
	{
		document.paginateSearchForm.Ntk.value = 'Content'; 
	}
    document.paginateSearchForm.submit();	        
}  

function refineByPerPage(rppComboValue)
{
	document.paginateSearchForm.rpp.value = rppComboValue;	
	document.paginateSearchForm.navigation.value = 'NULL'; 				        	            
    document.paginateSearchForm.submit();
} 

function refineByProductFilterCheckbox(clickedElement)
{
	var productFilter;
	var doFilter = true;
	var productCheckbox = $('Checkbox_Product');
	var accessoryCheckbox = $('Checkbox_Accessory');
	
	if (productCheckbox && accessoryCheckbox)
	{
		if (productCheckbox.checked && accessoryCheckbox.checked)
		{
		} else if (productCheckbox.checked)
		{
			productFilter = 'PRODUCT_ONLY';
		} else if (accessoryCheckbox.checked)
		{
			productFilter = 'ACCESSORY_ONLY';
		} else
		{
			doFilter = false;
		}
		
		if (doFilter)
		{
			document.paginateSearchForm.productFilter.value = productFilter; 	
	        document.paginateSearchForm.submit();	
        } else
        {
        	clickedElement.checked = true;
        	alert('Temp: To display results, at least one of the display options must be checked. Please select either Products or Accessories.');
        }   		
	}	    	       
}  


// comparison map
var comparisonSkusByCategory = {};
var allComparisonSkus = [];
function toggleAllComparisonCheckboxes(categoryName)
{			
	var noneChecked = true;
    for(i=0; i<allComparisonSkus.length; i++)
    { 
        var comparisonSku = allComparisonSkus[i] ;
    	var comparisonElement = document.getElementById(comparisonSku);
        if (comparisonElement!=null)   
        {
			if($('compare_div_'+ comparisonSku).hasClassName('invisibleElement'))
			{
			$('compare_div_'+ comparisonSku).removeClassName('invisibleElement');
			}	                	                
            if (document.getElementById(comparisonSku).checked)
            {
            	noneChecked = false;
            } else if (comparisonSkusByCategory[categoryName].indexOf(comparisonSku) < 0)
            {
				if(!$('compare_div_'+ comparisonSku).hasClassName('invisibleElement'))
				{
				$('compare_div_'+ comparisonSku).addClassName('invisibleElement');
				}			                    
                
            }
        }
    }	
    
    if (noneChecked)
    {
        for(i=0; i<allComparisonSkus.length; i++)
        { 
            var comparisonSku = allComparisonSkus[i] ;
        	var comparisonElement = document.getElementById(comparisonSku);
            if (comparisonElement!=null)   
            {
                //comparisonElement.parentNode.style.display = 'block';
				if($('compare_div_'+ comparisonSku).hasClassName('invisibleElement'))
				{
				$('compare_div_'+ comparisonSku).removeClassName('invisibleElement');
				}			                
                
            	//document.getElementById('compare_text_'+ comparisonSku).style.display = 'block';
            	//document.getElementById('compare_link_'+ comparisonSku).style.display = 'none';
            }
        }		            
    }            
    
    document.compareProductForm.compareUser.value = categoryName;            
}


function initSearchPricingAjax() 
{
	ajaxEngine.registerRequest("SYGetContractUnitPrices", "SYGetContractUnitPrices");	
	
	var ProductPricingAjaxResponseObject = {};
	ProductPricingAjaxResponseObject.ajaxUpdate = function(ajaxResponse) {				
		var fieldNames = ajaxResponse.childNodes;  
		var stringToUse = {};		
		for (var i = 0; i < fieldNames.length; i++) 
	   	{	  
	   		if ((fieldNames[i].nodeType == 1) && (fieldNames[i].getAttribute("id")=="products"))
	   		{	 
	   			var extendedTextNodes = fieldNames[i].childNodes;
	   			for(var textCount = 0; textCount < extendedTextNodes.length; textCount++){
	   				if(textCount==0)
	   					stringToUse = fieldNames[i].childNodes[textCount].data;
	   				else
	   					stringToUse = stringToUse + fieldNames[i].childNodes[textCount].data;
	   			}				
				break;
	   		}	   			   		
	   	}
	   	 						
		var myJSONObject = eval('('+stringToUse+')');	
		
		for (productId in myJSONObject.products)
		{ 				
			displaySearchPriceSection(productId, myJSONObject.products[productId]);
		}		
	}

	ajaxEngine.registerAjaxObject("ProductPricingAjaxResponseObject", ProductPricingAjaxResponseObject);
}	
