﻿//display the control panel dialog when the button is clicked
function showOptions()
{
    var opt = document.getElementById("demoOptions");

    if (opt)
    {
        if (opt.style.display == "")
            {
                opt.style.display = "none";
                sendConfigOptions();
            }
        else
            {
                opt.style.display = "";
                URLString=window.location.href;
            }
    }
}

function sendConfigOptions()
{
  var value='';
		//saving the values set by the user by sending them in the request for the next load
		if (URLString.indexOf("config")!=-1)
			{URLString=URLString.substring(0,URLString.indexOf("config")-1)}
		
		if (URLString.indexOf("?")==-1)
			{URLString = URLString + "?";}
		else
			{URLString = URLString + "&";}
			
		URLString = URLString + 'config=true';
		value=document.getElementById('SearchTopStrip_ChkExplanation').checked;
		URLString = URLString + '&AllowExplain=' + value;
		value=document.getElementById('SearchTopStrip_ChkCompare').checked;
		URLString = URLString + '&AllowCompare=' + value;
		value=document.getElementById('SearchTopStrip_ChkShowHighlights').checked;
		URLString = URLString + '&ShowHighlights=' + value;
		value=document.getElementById('SearchTopStrip_ChkShowScore').checked;
		URLString = URLString + '&ShowScore=' + value;
		value=document.getElementById('SearchTopStrip_ChkShowCounters').checked;
		URLString = URLString + '&ShowCounters=' + value;
		value=document.getElementById('SearchTopStrip_chkMVTParams').checked;
		URLString = URLString + '&ShowMVT=' + value;
		value=document.getElementById('SearchTopStrip_chkCommonRefinements').checked;
		URLString = URLString + '&ShowCommonRefinements=' + value;
		value=document.getElementById('SearchTopStrip_cmbItemsPerPage').value;
		URLString = URLString + '&ItemsPerPage=' + value;
		value=document.getElementById('SearchTopStrip_cmbItemsPerRow').value;
		URLString = URLString + '&ItemsPerRow=' + value;
		value=document.getElementById('SearchTopStrip_cmbViewBy').value;
		URLString = URLString + '&ViewBy=' + value;
		value=document.getElementById('SearchTopStrip_cmbbuyerSegments').value;
		URLString = URLString + '&BuyerSegments=' + value;
		  
		window.location.href = URLString;
}


