// Right Side Product Finder Component: Search Button
function productSegmentSearch(listPath, defaultSearchValue){
	var q = jQuery('#product-finder-name').val();
	var segmentS = jQuery('#search-form-dd-segment option:selected').val();
	var substrateS = jQuery('#search-form-dd-substrate option:selected').val();
	var typeS = jQuery('#search-form-dd-type option:selected').val();
	var functionS = jQuery('#search-form-dd-function option:selected').val();
	
	//var q = document.getElementById('product-finder-name').value;
	
	var red = document.getElementById('text' + segmentS + '1');
	if (red){
	    window.location = 'http://' + window.location.host + red.value;
	}
	else{
	
    if (q == defaultSearchValue){ q = '0'; }
        window.location = 'http://' + window.location.host + listPath + '?q='+ q + '&segmentS=' + segmentS + '&substrateS=' + substrateS + '&typeS=' + typeS + '&functionS=' + functionS;
    }
}

// clear product search textbox
function productClearTextSearch(defaultValue){
	var q = document.getElementById('product-finder-name').value;
	if (q = defaultValue){
		document.getElementById('product-finder-name').value='';
	}
}

// Left Side Product Finder Component - Search Button
function productTextSearch(listPath, segment){
	
	var q = document.getElementById('product-finder-name').value;
	if (q != ''){
		if(segment != ''){
			window.location = 'http://' + window.location.host + listPath + '?segment=' + segment + "&q=" + q;
		}
		else{
			window.location = 'http://' + window.location.host + listPath + '?q=' + q;
		}
	}
}

// Left Side Product Finder Component - Reset Buttons
function clearSearchFilters(listPath){
    window.location = 'http://' + window.location.host + listPath;
}

function loadProductList(q, segmentS, substrateS, typeS, functionS){
    jQuery("#productlist").load('/product-list/product-search-results/ajaxresults.aspx?q=' + encodeURIComponent(q) + '&segmentS=' + encodeURIComponent(segmentS) +'&substrateS=' + encodeURIComponent(substrateS) + '&typeS=' + encodeURIComponent(typeS) + '&functionS=' + encodeURIComponent(functionS));
}
