﻿
if(location.href === 'http://www.balmforth.co.uk/ServicesMortgages.aspx')
{
	location.href = 'http://www.balmforth.co.uk';
}


var textValue;
var color;

function SearchAutoComplete_OnClientItemSelected(itemSelected) {
    textValue = itemSelected._currentPrefix;
}

function bob() {
    $('#SearchAutoCompleteEx_completionListElem li').mousedown(function(evt) {
        if ($(this).text() === 'More...') {
            color = $('.locationTextBox').css('color');
            $('.locationTextBox').css('color', 'transparent');
        }
    });
}

function SearchAutoComplete_OnClientPopulated() {
    bob();
    var $autocompleteList = $('#SearchAutoCompleteEx_completionListElem');
    if ($autocompleteList.length != 0) {
        var txtBoxContent;
        var $autocompleteListLIs = $autocompleteList.find('li');
        var $autocompleteListLastLI = $($autocompleteListLIs[$autocompleteListLIs.length - 1]);
        var txt = $autocompleteListLastLI.text();
        $($autocompleteListLIs[0]).addClass('firstElement');
        $($autocompleteListLIs[0]).mouseup(function(evt) { evt.preventDefault(); $('.locationTextBox').attr('value', textValue); });
        if (txt === 'More...') {
            $autocompleteListLastLI.css({
                'font-weight': 'bold',
                'font-style': 'italic'               
            });
            $autocompleteListLastLI.mouseup(function(evt) {
                evt.preventDefault();
                $('.locationTextBox').attr('value', textValue);
                $('.locationTextBox').css('color', color);
                $('.btn').click();
            });
        }        
    }
}

