var _searchParams;

function showShortlist(shortlist)
{
    try {
        if (!shortlist)
            shortlist = Get_Cookie('Shortlist');
        _searchParams = { SearchType:"Shortlist", MRU: shortlist };
        InitSearch("Shortlist",$('#shortlist'));
    }
    catch(ex)
    {
        raiseError("Error in updateRecentlyViewed:"+ex.description);
    }
}

function InitSearch(searchType, displaydiv)
{
    try
    {
        $.post("/ChaletSearch.aspx", _searchParams, function(data){PopulateSidebar(searchType, displaydiv,data);});
    }
    catch(ex)
    {
        alert('An error occured attempting to perform your search.\nPlease try again or contact us by phone for further assistance.');
        raiseError("Error in Init search:"+ex.description);
    }    
}

function PopulateSidebar(searchtype, div, data)
{
    try
    {
        var output = "", JS = "";
        var codearray = data.split("<div class='sectionbreaker' />");
        if (codearray.length == 3)
        {
            if (codearray[0].replace(/^\s+|\s+$/g, '') != "")
            {
                output = "Error retrieving search results. Please try again or contact us by phone for further assistance.";
                raiseError("Ajax call returned error:"+codearray[0]);
            }
            else
            {
                output = codearray[1];
                JS = codearray[2];
            }
        }
        else
        {
            output = "Error retrieving search results. Please try again or contact us by phone for further assistance.";
            raiseError("Ajax call failed, result:"+data);
        }
        div.html(output);
        setTimeout(JS,100);
        try
        {
            updateSLInfoOnEnqPanel();
        }
        catch(ex) {}
    }
    catch(ex)
    {
        alert('An error occured attempting to show your search results.\nPlease try again or contact us by phone for further assistance.');
        raiseError("Error in Sidebar populate:"+ex.description);
    }
}

var SLenqOpen=false;

function updateSLInfoOnEnqPanel()
{
    var SLinfo = "";
    $('.shortlistAddInfo').each(function(){SLinfo+=(SLinfo==""?"":",<br>")+"<li>"+$(this).val();+"</li>"});
	if (SLinfo!="")                
		SLinfo="<fieldset class='enq-shortlist'><legend>Shortlisted Chalets</legend><ul>"+SLinfo+"</ul></fieldset>";
	$('#SLinfo').html(SLinfo);
}

function applyEnquireToggle()
{
    $('#enquire-shortlist').toggle(function() {
        updateSLInfoOnEnqPanel();
		$('#enquiry-panel').animate({
	    	marginLeft: (SLenqOpen==true?"-2400px":"2400px")
        }, 'slow' );
        SLenqOpen = !SLenqOpen;
	}, function() {
	    updateSLInfoOnEnqPanel();
		$('#enquiry-panel').animate({
	    	marginLeft: (SLenqOpen==true?"-2400px":"2400px")
        }, 'slow' );
        SLenqOpen = !SLenqOpen;
	});
}

function clearFilterStrings(){}
function addFilterString(a,b){}
