
function AddToShortList(propertyId, referenceNumber)
{
	ShortlistFunctions.AddProperty(propertyId, referenceNumber, ShortList_CallBack);
}

function ShortList_CallBack(response)
{
    try
    {
	    document.getElementById('ShortListResults').innerHTML = response.value;
	}
	catch (e)
	{
	    // eat exception as this will fail on short list page.
	}
}

function RemoveFromShortList(propertyId)
{
	ShortlistFunctions.RemoveProperty(propertyId, ShortList_CallBack);
}

function ProcessShortlist(element, propertyId, referenceNumber, addFlag)
{
    if (_addFlags[element.id] != true && _addFlags[element.id] != false)
    {
        _addFlags[element.id] = addFlag;
    }
    
    if (_addFlags[element.id] == true)
    {
        _addFlags[element.id] = false;
        AddToShortList(propertyId, referenceNumber);
    }
    else
    {
        _addFlags[element.id] = true;
        RemoveFromShortList(propertyId);
    }
    UpImage(element);
}

function DownImage(element, addFlag)
{
    if (_addFlags[element.id] != true && _addFlags[element.id] != false)
    {
        _addFlags[element.id] = addFlag;
    }
    
    if (_addFlags[element.id] == true)
    {
        element.src = addDownImage;
        element.title = addTip;
    }
    else if (_addFlags[element.id] == false)
    {
        element.src = removeDownImage;
        element.title = removeTip;
    }
}

function UpImage(element)
{
    if (_addFlags[element.id] == true)
    {
        element.src = addUpImage;
        element.title = addTip;
    }
    else if (_addFlags[element.id] == false)
    {
        element.src = removeUpImage;
        element.title = removeTip;
    }
}

function ShortlistCount()
{
	ShortlistFunctions.NumberOfProperties(ShortList_CallBack);
}

function HasProperties()
{
	var hasProperties = false;
	if (document.getElementById('ShortListResults').innerHTML > 0)
	{
	    hasProperties = true;
	}
	return hasProperties;
}
