﻿function searchFormTextBoxChange(textBox) {
    var textBoxValue = textBox.value;
    
    if (textBoxValue == '') {
        textBox.value = 'Sök resmål...';
    }
}

function searchFormTextBoxClick(textBox) {
    var textBoxValue = textBox.value;
    
    if (textBoxValue == 'Sök resmål...') {
        textBox.value = '';
    }
}

function searchLocation(searchFormTextBoxID) {
    var textBox = document.getElementById(searchFormTextBoxID);
    if (textBox != null) {
        var searchString = textBox.value;
        searchString = escape(searchString);
        //location.href = '/karta?k=' + searchString;
        location.href = '/services/search.aspx?k=' + searchString;
    }  
    return false; 
}

function searchLocationObj(textBox) {
    if (textBox != null) {
        var searchString = textBox.value;
        searchString = escape(searchString);
        //location.href = '/karta?k=' + searchString;
        location.href = '/services/search.aspx?k=' + searchString;
    }  
    return false; 
}

function searchAddressCmd(searchFormTextBoxID) {
    var textBox = document.getElementById(searchFormTextBoxID);
    if (textBox != null) {
        var searchString = textBox.value;
        searchAddress(searchString);
    }  
    return false; 
}

function searchAddressObj(textBox) {
    if (textBox != null) {
        var searchString = textBox.value;
        searchAddress(searchString);
    }  
    return false; 
}

function checkEnterSearchLocation(e, textbox) {
    if (e && e.which) {
        e = e;
        characterCode = e.which;
    } else {
        e = event;
        characterCode = e.keyCode;
    }
    if (characterCode == 13) {
        searchLocationObj(textbox);
        return false; 
    } else {
        return true 
    }
}

function checkEnterSearchAddress(e, textbox) {
    if (e && e.which) {
        e = e;
        characterCode = e.which;
    } else {
        e = event;
        characterCode = e.keyCode;
    }
    if (characterCode == 13) {
        searchAddressObj(textbox);
        return false; 
    } else {
        return true 
    }
}
