﻿var textbox;
var button;

function RunSearch(button, text)
{
    this.textbox = $get(text);
    this.button = button;
    
    JobsGroup.Locations.VerifyLocation(textbox.value, HandleVerify);    
}

function HandleVerify(result)
{
    var test = result;
    
    if(result == true)
    {
        __doPostBack(this.button, 'BasicRun') 
    }
    else if(textbox.value == 'E.g. London, Greater London, South East, ENGLAND')
    {
        __doPostBack(this.button, 'BasicRun')
    }
    else 
    {
        alert('Please enter a correct location');
    }
}

function RunAdvancedSearch(button, text)
{
    this.textbox = $get(text);
    this.button = button;
    
    JobsGroup.Locations.VerifyLocation(textbox.value, HandleVerifyAdvanced);
}

function HandleVerifyAdvanced(result)
{
    if(result == true)
    {
        __doPostBack(this.button, 'AdvancedRun') 
    }
    else if(textbox.value == 'E.g. London, Greater London, South East, ENGLAND')
    {
        __doPostBack(this.button, 'AdvancedRun')
    }
    else 
    {
        alert('Please enter a correct location');
    }
}