function Thumbnail(propertyId) {
     photoWindow = window.open('','propertyId', "toolbar=no,scrollbars=no,locationbar=no,personalbar=no,statusbar=no, resizable=yes, width=360, height=320");
     photoWindow.location.href = "DisplayPropertyPhoto.aspx?propertyId=" + propertyId;
}
function ShowReport(propertyId) {
     reportWindow = window.open('','propertyId', "toolbar=no,scrollbars=yes,locationbar=no,personalbar=no,statusbar=no, resizable=yes");
     reportWindow.location.href = "report.aspx?propertyId=" + propertyId;
}

function CollapsePanel(control)
{
	document.getElementById(control).className = "collapsedPanel";
	document.getElementById('searchControl_extendedSearchToggle').src = "images/expand_blue.jpg";
	SetCookie(control, "collapsedPanel");	
}

function ExpandPanel(control)
{
	document.getElementById(control).className = "expandedPanel";
	document.getElementById('searchControl_extendedSearchToggle').src = "images/collapse_blue.jpg";
	SetCookie(control, "expandedPanel");
}

function TogglePanel(control)
{	
	var currentState = GetCookie(control);
	if(currentState != "collapsedPanel")
		CollapsePanel(control);
	else
		ExpandPanel(control);
}

function RestorePanel(control)
{		
    var displayState = GetCookie(control);	
	document.getElementById(control).className = displayState ? displayState : "collapsedPanel";
}

function SetCookie(name, value, expires, path, domain, secure)
{
    document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function GetCookie(name)
{
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ( ( !start ) &&
         ( name != document.cookie.substring( 0, name.length ) ) )
    {
       return null;
    }
    if ( start == -1 ) return null;
    var end = document.cookie.indexOf( ";", len );
    if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}

function AddFilter()
{
	var fieldName = document.getElementById("searchControl_fieldsDropDown").value;
	var operatorName = document.getElementById("searchControl_operatorsDropDown").value;
	var matchValue = document.getElementById("searchControl_filterValueTextBox").value;
	var listBox = document.getElementById("searchControl_filterListBox");
	var newOption = "'" + fieldName + "' '" + operatorName + "' '" + matchValue + "'";	
	listBox.options[listBox.options.length] = new Option(newOption,newOption);	
	SetFilters();	
}

function RemoveFilter()
{
	var listBox = document.getElementById("searchControl_filterListBox");
	listBox.options[listBox.selectedIndex] = null;
	SetFilters();
}

function SetFilters()
{	
	var filterString = "";
	var listBox = document.getElementById("searchControl_filterListBox");
	for(var i=0; i < listBox.options.length; i++)
	{
	   filterString = filterString + listBox.options[i].value + ";";
	}
	document.getElementById("searchControl_filtersTextbox").value = filterString;
}

function ClearFilters()
{
	var listBox = document.getElementById("searchControl_filterListBox");
	listBox.options[listBox.selectedIndex] = null;
	while(listBox.options.length > 0)
	{
	   listBox.options[0] = null;
	}
	document.getElementById("searchControl_filtersTextbox").value = "";
}