﻿Type.registerNamespace("Hcn");

Hcn.RequestFailed = function(result, userContext, methodName)
{
    //alert(result._message);
};

Type.registerNamespace("CountryState");

CountryState.Init = function(errorMessage)
{
    CountryState.ErrorMessage = errorMessage;
    CountryState.States = new Array();
};

CountryState.InitControl = function(selectCountry, selectState, emptyOption)
{
    if (typeof (CountryState.Controls) == "undefined")
    {
        CountryState.Controls = Array();
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(CountryState.ReInitControl);
    }
        
    CountryState.Controls.push( 
        {
            "SelectCountryName": selectCountry,
            "SelectStateName": selectState,
            "EmptyOption": emptyOption
        });
};

CountryState.ReInitControl = function(source, args)
{
    for (var i in CountryState.Controls)
    {
        var country = jQuery("#" + CountryState.Controls[i].SelectCountryName);
        var state = jQuery("#" + CountryState.Controls[i].SelectStateName);
        if (country.length > 0 && state.length > 0)
            country[0].Control = new CountryState.Control(country, state, CountryState.Controls[i].EmptyOption);
    }
};

CountryState.SelectState_Validate = function(source, args)
{
    args.IsValid = CountryState.ValidateState(jQuery("#" + jQuery(source).attr("country"))[0].Control.State);
};

CountryState.ValidateState = function(state)
{
    return state.attr("set") == "true" && (state.val() == null || state.val() != "0");
};

CountryState.Control = function(country, state, emptyOption)
{
    this.Country = country;
    this.State = state;
    this.EmptyOption = emptyOption;
};

CountryState.Control.prototype =
{
    DropDownListCountry_Changeing: function()
	{
        this.State.attr("disabled", "disabled");
        this.State.attr("set", "false");
        this.State.children().remove();
        if (this.Country.val() != "0")
            this.SetState();
    },

    SetState: function()
	{
        var countryId = this.Country.val();
        if (typeof(CountryState.States[countryId]) == "undefined")
            Hcn.Service.GetStatesByCountry(countryId, this.GetStatesByCountrySucceeded, Hcn.RequestFailed, { "sender": this, "countryId": countryId });
        else
		{
            this.State.attr("set", "true");
            if (CountryState.States[countryId].length != 0)
			{
                this.State.append("<option value=\"0\">" + this.EmptyOption + "</option>");
                for (var i in CountryState.States[countryId])
                    this.State.append("<option value=\"" + CountryState.States[countryId][i].Id + "\" cd=\"" + CountryState.States[countryId][i].Cd + "\">" + CountryState.States[countryId][i].Name + "</option>");
                this.State.attr("disabled", "");
            }
        }
    },

    GetStatesByCountrySucceeded: function(result, userContext, methodName)
	{
	    if (result.Status == Hcn.WebMethodStatus.Ok)
        {
            CountryState.States[userContext.countryId] = result.Response;
            userContext.sender.SetState();
        }
        else
            alert(CountryState.ErrorMessage);
    }
};

Type.registerNamespace("GeographicPosition");

GeographicPosition.Init = function(selectCountry, selectState, inputResult, spanSelectedView, aEditLink, removeLinkText, countError, containsError, countryError, stateError, validationMode)
{
    GeographicPosition.SelectCountryName = selectCountry;
    GeographicPosition.SelectStateName = selectState;
    GeographicPosition.InputResultName = inputResult;
    GeographicPosition.SpanSelectedViewName = spanSelectedView;
    GeographicPosition.AEditLinkName = aEditLink;
    
    GeographicPosition.RemoveLinkText = removeLinkText;
    GeographicPosition.CountError = countError;
    GeographicPosition.ContainsError = containsError;
    GeographicPosition.CountryError = countryError;
    GeographicPosition.StateError = stateError;
    GeographicPosition.ValidationMode = validationMode;
    
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(GeographicPosition.ReInit);
};

GeographicPosition.ReInit = function(sender, args)
{
    GeographicPosition.DivGeographicPositionControls = jQuery("#divGeographicPositionControls");
    GeographicPosition.DivGeographicPosition = jQuery("#divGeographicPosition");
    
    if (GeographicPosition.DivGeographicPositionControls.length > 0)
    {
        GeographicPosition.SelectCountry = jQuery("#" + GeographicPosition.SelectCountryName);
        GeographicPosition.SelectState = jQuery("#" + GeographicPosition.SelectStateName);
        GeographicPosition.InputResult = jQuery("#" + GeographicPosition.InputResultName);
        GeographicPosition.SpanSelectedView = jQuery("#" + GeographicPosition.SpanSelectedViewName);
        GeographicPosition.AEditLink = jQuery("#" + GeographicPosition.AEditLinkName);

        GeographicPosition.SpanEditLinkPlace1 = GeographicPosition.DivGeographicPositionControls.find("#spanEditLinkPlace1");
        GeographicPosition.SpanEditLinkPlace2 = GeographicPosition.DivGeographicPositionControls.find("#spanEditLinkPlace2");
        
        GeographicPosition.DivMessage = GeographicPosition.DivGeographicPosition.find("#divMessage");
        GeographicPosition.InputCity = GeographicPosition.DivGeographicPosition.find("#inputCity");
        GeographicPosition.TrGeographicPosition = GeographicPosition.DivGeographicPosition.find("#trGeographicPosition");

        if (GeographicPosition.InputResult.val().trim() != "")
		{
            GeographicPosition.Positions = Sys.Serialization.JavaScriptSerializer.deserialize(GeographicPosition.InputResult.val());
            if (typeof(GeographicPosition.Positions) !== "object" || GeographicPosition.Positions.length == 0)
			{
                GeographicPosition.Positions = new Array();
                GeographicPosition.InputResult.val("");
            }
        }
        else
            GeographicPosition.Positions = new Array();
    }
};

GeographicPosition.GetFormatLocation = function(country, state, city)
{
    var location = country.Name;
    if (state != null)
        location += " > " + state.Cd;
    if (city != null)
        location += " > " + city;
    return location;
};

GeographicPosition.RedrawTable = function()
{
    GeographicPosition.TrGeographicPosition.parent().find("tr:not(#" + GeographicPosition.TrGeographicPosition.attr("id") + ")").remove();
    for (var i in GeographicPosition.PositionsTemp)
        GeographicPosition.TrGeographicPosition.after("<tr id=\"" + i + "\"><td>" + GeographicPosition.GetFormatLocation(GeographicPosition.PositionsTemp[i].Country, GeographicPosition.PositionsTemp[i].State, GeographicPosition.PositionsTemp[i].City) + "</td><td align=\"center\"><a href=\"javascript: GeographicPosition.Remove(" + i + ")\">" + GeographicPosition.RemoveLinkText + "<a></td></tr>");
};

GeographicPosition.Show = function()
{
    GeographicPosition.DivMessage.text("");
    GeographicPosition.PositionsTemp = Array.clone(GeographicPosition.Positions);
    GeographicPosition.RedrawTable();
    Global.ShowOverlay();
    GeographicPosition.DivGeographicPosition.show();
};

GeographicPosition.Hide = function()
{
    GeographicPosition.DivGeographicPosition.hide();
    Global.HideOverlay();
};

GeographicPosition.Add = function()
{
    if (GeographicPosition.PositionsTemp.length > 4)
    {
        GeographicPosition.DivMessage.text(GeographicPosition.CountError);
        return;
    }

    if (GeographicPosition.SelectCountry.val() == "0")
    {
        GeographicPosition.DivMessage.text(GeographicPosition.CountryError);
        return;
    }

    if (GeographicPosition.ValidationMode == "Full" && CountryState.ValidateState(GeographicPosition.SelectState) == false)
    {
        GeographicPosition.DivMessage.text(GeographicPosition.StateError);
        return;
    }
    
    if (GeographicPosition.InputCity.val().trim() != "" && CountryState.ValidateState(GeographicPosition.SelectState) == false)
    {
        GeographicPosition.DivMessage.text(GeographicPosition.StateError);
        return;
    }

    var geographicPosition =
        {
            "Country":
            {
                "Id": GeographicPosition.SelectCountry.val(),
                "Name": GeographicPosition.SelectCountry.find(":selected").text()
            },
            "State": (GeographicPosition.SelectState.val() != null && CountryState.ValidateState(GeographicPosition.SelectState) ?
                {
                        "Cd": GeographicPosition.SelectState.find(":selected").attr("cd"),
                        "Id": GeographicPosition.SelectState.val(),
                        "Name": GeographicPosition.SelectState.find(":selected").text()
                } : null),
            "City": (GeographicPosition.InputCity.val().trim() != "" ? GeographicPosition.InputCity.val().trim() : null)
        };

        geographicPosition.Hesh = geographicPosition.Country.Id + "-" + (geographicPosition.State == null ? "null" : geographicPosition.State.Id) + "-" + (geographicPosition.City == null ? "null" : geographicPosition.City);

    for (var i in GeographicPosition.PositionsTemp)
        if (GeographicPosition.PositionsTemp[i].Hesh == geographicPosition.Hesh)
        {
            GeographicPosition.DivMessage.text(GeographicPosition.ContainsError);
            return;
        }

    GeographicPosition.DivMessage.text("");

    GeographicPosition.PositionsTemp.push(geographicPosition);
    GeographicPosition.RedrawTable();
};

GeographicPosition.Remove = function(i)
{
    GeographicPosition.DivMessage.text("");
    if (typeof(GeographicPosition.PositionsTemp[i]) !== "undefined")
        Array.removeAt(GeographicPosition.PositionsTemp, i);
    GeographicPosition.RedrawTable();
};

GeographicPosition.RemoveAll = function()
{
    GeographicPosition.DivMessage.text("");
    Array.clear(GeographicPosition.PositionsTemp);
    GeographicPosition.RedrawTable();
};

GeographicPosition.Cancel = function()
{
    GeographicPosition.Hide();
};

GeographicPosition.Ok = function()
{
    GeographicPosition.Positions = GeographicPosition.PositionsTemp;
    var result = "";
    var delimiter = "";
    for (var i in GeographicPosition.Positions)
    {
        result += delimiter + GeographicPosition.GetFormatLocation(GeographicPosition.PositionsTemp[i].Country, GeographicPosition.PositionsTemp[i].State, GeographicPosition.PositionsTemp[i].City);
        delimiter = "; ";
    }
    GeographicPosition.SpanEditLinkPlace1.find("*").remove();
    GeographicPosition.SpanEditLinkPlace2.find("*").remove();
        if (GeographicPosition.Positions.length > 0)
    {
        GeographicPosition.SpanEditLinkPlace2.append("<br />");
        GeographicPosition.SpanEditLinkPlace2.append(GeographicPosition.AEditLink);
    }
    else
        GeographicPosition.SpanEditLinkPlace1.append(GeographicPosition.AEditLink);
    GeographicPosition.SpanSelectedView.text(result);
    
    GeographicPosition.InputResult.val(Sys.Serialization.JavaScriptSerializer.serialize(GeographicPosition.Positions));
    GeographicPosition.Hide();
};

GeographicPosition.Clear = function()
{
    GeographicPosition.PositionsTemp = Array();
    GeographicPosition.Ok();
};

Type.registerNamespace("Industry");

Industry.Init = function(selectIndustry, inputResult, spanSelectedView, aEditLink, removeLinkText, countError, containsError, industryError)
{
    Industry.DivIndustryName = "divIndustry";
    
    Industry.SelectIndustryName = selectIndustry;
    Industry.InputResultName = inputResult;
    Industry.SpanSelectedViewName = spanSelectedView;
    Industry.AEditLinkName = aEditLink;

    Industry.RemoveLinkText = removeLinkText;
    Industry.CountError = countError;
    Industry.ContainsError = containsError;
    Industry.IndustryError = industryError;
        
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(Industry.ReInit);
};

Industry.ReInit = function(sender, args)
{
    Industry.DivIndustryControls = jQuery("#divIndustryControls");
    Industry.DivIndustry = jQuery("#" + Industry.DivIndustryName);
    
    if (Industry.DivIndustryControls.length > 0)
    {
        Industry.SelectIndustry = jQuery("#" + Industry.SelectIndustryName);
        Industry.InputResult = jQuery("#" + Industry.InputResultName);
        Industry.SpanSelectedView = jQuery("#" + Industry.SpanSelectedViewName);
        Industry.AEditLink = jQuery("#" + Industry.AEditLinkName);
        
        Industry.SpanEditLinkPlace1 = Industry.DivIndustryControls.find("#spanEditLinkPlace1");
        Industry.SpanEditLinkPlace2 = Industry.DivIndustryControls.find("#spanEditLinkPlace2");
        
        Industry.DivMessage = Industry.DivIndustry.find("#divMessage");
        Industry.TrIndustry = Industry.DivIndustry.find("#trIndustry");

        if (Industry.InputResult.val().trim() != "")
        {
            Industry.Industries = Sys.Serialization.JavaScriptSerializer.deserialize(Industry.InputResult.val());
            if (typeof(Industry.Industries) !== "object" || Industry.Industries.length == 0)
            {
                Industry.Industries = new Array();
                Industry.InputResult.val("");
            }
        }
        else
            Industry.Industries = new Array();
    }
};

Industry.RedrawTable = function()
{
    Industry.TrIndustry.parent().find("tr:not(#" + Industry.TrIndustry.attr("id") + ")").remove();
    for (var i in Industry.IndustriesTemp)
        Industry.TrIndustry.after("<tr id=\"" + i + "\"><td>" + Industry.IndustriesTemp[i].Name + "</td><td align=\"center\"><a href=\"javascript: Industry.Remove(" + i + ")\">" + Industry.RemoveLinkText + "<a></td></tr>");
};

Industry.Show = function()
{
    Industry.DivMessage.text("");
    Industry.IndustriesTemp = Array.clone(Industry.Industries);
    Industry.RedrawTable();
    Global.ShowOverlay();
    Industry.DivIndustry.show();
};

Industry.Hide = function()
{
    Industry.DivIndustry.hide();
    Global.HideOverlay();
};

Industry.Add = function()
{
    if (Industry.IndustriesTemp.length > 4)
    {
        Industry.DivMessage.text(Industry.CountError);
        return;
    }

    if (Industry.SelectIndustry.val() == "0")
    {
        Industry.DivMessage.text(Industry.IndustryError);
        return;
    }

    var industry =
        {
            "Id": Industry.SelectIndustry.val(),
            "Name": Industry.SelectIndustry.find(":selected").text()
        };

    for (var i in Industry.IndustriesTemp)
        if (Industry.IndustriesTemp[i].Id == industry.Id)
        {
            Industry.DivMessage.text(Industry.ContainsError);
            return;
        }

    Industry.DivMessage.text("");

    Industry.IndustriesTemp.push(industry);
    Industry.RedrawTable();
};

Industry.Remove = function(i)
{
    Industry.DivMessage.text("");
    if (typeof(Industry.IndustriesTemp[i]) !== "undefined")
        Array.removeAt(Industry.IndustriesTemp, i);
    Industry.RedrawTable();
};

Industry.RemoveAll = function()
{
    Industry.DivMessage.text("");
    Array.clear(Industry.IndustriesTemp);
    Industry.RedrawTable();
};

Industry.Cancel = function()
{
    Industry.Hide();
};

Industry.Ok = function()
{
    Industry.Industries = Industry.IndustriesTemp;
    var result = "";
    var delimiter = "";
    for (var i in Industry.Industries)
    {
        result += delimiter + Industry.Industries[i].Name;
        delimiter = ", ";
    }
    Industry.SpanEditLinkPlace1.find("*").remove();
    Industry.SpanEditLinkPlace2.find("*").remove();
    if (Industry.Industries.length > 0)
    {
        Industry.SpanEditLinkPlace2.append("<br />");
        Industry.SpanEditLinkPlace2.append(Industry.AEditLink);
    }
    else
        Industry.SpanEditLinkPlace1.append(Industry.AEditLink);
    Industry.SpanSelectedView.text(result);
    Industry.InputResult.val(Sys.Serialization.JavaScriptSerializer.serialize(Industry.Industries));
    Industry.Hide();
};

Industry.Clear = function()
{
    Industry.IndustriesTemp = Array();
    Industry.Ok();
};

Type.registerNamespace("Job");

Job.Init = function(selectJob, inputResult, spanSelectedView, aEditLink, removeLinkText, countError, containsError, jobError)
{
    Job.DivJobName = "divJob";
    
    Job.SelectJobName = selectJob;
    Job.InputResultName = inputResult;
    Job.SpanSelectedViewName = spanSelectedView;
    Job.AEditLinkName = aEditLink;

    Job.RemoveLinkText = removeLinkText;
    Job.CountError = countError;
    Job.ContainsError = containsError;
    Job.JobError = jobError;
        
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(Job.ReInit);
};

Job.ReInit = function(sender, args)
{
    Job.DivJobControls = jQuery("#divJobControls");
    Job.DivJob = jQuery("#" + Job.DivJobName);
    
    if (Job.DivJobControls.length > 0)
    {
        Job.SelectJob = jQuery("#" + Job.SelectJobName);
        Job.InputResult = jQuery("#" + Job.InputResultName);
        Job.SpanSelectedView = jQuery("#" + Job.SpanSelectedViewName);
        Job.AEditLink = jQuery("#" + Job.AEditLinkName);
        
        Job.SpanEditLinkPlace1 = Job.DivJobControls.find("#spanEditLinkPlace1");
        Job.SpanEditLinkPlace2 = Job.DivJobControls.find("#spanEditLinkPlace2");
        
        Job.DivMessage = Job.DivJob.find("#divMessage");
        Job.TrJob = Job.DivJob.find("#trJob");

        if (Job.InputResult.val().trim() != "")
        {
            Job.Jobs = Sys.Serialization.JavaScriptSerializer.deserialize(Job.InputResult.val());
            if (typeof(Job.Jobs) !== "object" || Job.Jobs.length == 0)
            {
                Job.Jobs = new Array();
                Job.InputResult.val("");
            }
        }
        else
            Job.Jobs = new Array();
    }
};

Job.RedrawTable = function()
{
    Job.TrJob.parent().find("tr:not(#" + Job.TrJob.attr("id") + ")").remove();
    for (var i in Job.JobsTemp)
        Job.TrJob.after("<tr id=\"" + i + "\"><td>" + Job.JobsTemp[i].Name + "</td><td align=\"center\"><a href=\"javascript: Job.Remove(" + i + ")\">" + Job.RemoveLinkText + "<a></td></tr>");
};

Job.Show = function()
{
    Job.DivMessage.text("");
    Job.JobsTemp = Array.clone(Job.Jobs);
    Job.RedrawTable();
    Global.ShowOverlay();
    Job.DivJob.show();
};

Job.Hide = function()
{
    Job.DivJob.hide();
    Global.HideOverlay();
};

Job.Add = function()
{
    if (Job.JobsTemp.length > 4)
    {
        Job.DivMessage.text(Job.CountError);
        return;
    }

    if (Job.SelectJob.val() == "0")
    {
        Job.DivMessage.text(Job.JobError);
        return;
    }

    var job =
        {
            "Id": Job.SelectJob.val(),
            "Name": Job.SelectJob.find(":selected").text()
        };

    for (var i in Job.JobsTemp)
        if (Job.JobsTemp[i].Id == job.Id)
        {
            Job.DivMessage.text(Job.ContainsError);
            return;
        }

    Job.DivMessage.text("");

    Job.JobsTemp.push(job);
    Job.RedrawTable();
};

Job.Remove = function(i)
{
    Job.DivMessage.text("");
    if (typeof(Job.JobsTemp[i]) !== "undefined")
        Array.removeAt(Job.JobsTemp, i);
    Job.RedrawTable();
};

Job.RemoveAll = function()
{
    Job.DivMessage.text("");
    Array.clear(Job.JobsTemp);
    Job.RedrawTable();
};

Job.Cancel = function()
{
    Job.Hide();
};

Job.Ok = function()
{
    Job.Jobs = Job.JobsTemp;
    var result = "";
    var delimiter = "";
    for (var i in Job.Jobs)
    {
        result += delimiter + Job.Jobs[i].Name;
        delimiter = ", ";
    }
    Job.SpanEditLinkPlace1.find("*").remove();
    Job.SpanEditLinkPlace2.find("*").remove();
        if (Job.Jobs.length > 0)
    {
        Job.SpanEditLinkPlace2.append("<br />");
        Job.SpanEditLinkPlace2.append(Job.AEditLink);
    }
    else
        Job.SpanEditLinkPlace1.append(Job.AEditLink);
    Job.SpanSelectedView.text(result);
    Job.InputResult.val(Sys.Serialization.JavaScriptSerializer.serialize(Job.Jobs));
    Job.Hide();
};

Job.Clear = function()
{
    Job.JobsTemp = Array();
    Job.Ok();
};

Type.registerNamespace("AdminSearchCandidates");

AdminSearchCandidates.Init = function(inputNames, inputDate)
{
    AdminSearchCandidates.InputNamesName = inputNames;
    AdminSearchCandidates.InputDateName = inputDate;
    AdminSearchCandidates.InputDateReg = /^\d\d\/\d\d\/\d\d\d\d$/;
    
    AdminSearchCandidates.DivContainerPlaceHtml = jQuery("#divContainerPlace").html();
    
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(AdminSearchCandidates.ReInit);
};

AdminSearchCandidates.ReInit = function(sender, args)
{
    AdminSearchCandidates.InputNames = jQuery("#" + AdminSearchCandidates.InputNamesName);
    AdminSearchCandidates.InputDate = jQuery("#" + AdminSearchCandidates.InputDateName);
    AdminSearchCandidates.DivContainerPlace = jQuery("#divContainerPlace");
    AdminSearchCandidates.DivContainerPlace.html(AdminSearchCandidates.DivContainerPlaceHtml);

    var date = AdminSearchCandidates.InputDate.val().trim();
    var dateNow = new Date();
    AdminSearchCandidates.Calendar = new YAHOO.widget.Calendar("divCalendar",
        {
            selected: AdminSearchCandidates.InputDateReg.test(date) ? date : "",
            maxdate: String.format("{0:d}/{1:d}/{2:d}", dateNow.getMonth() + 1, dateNow.getDate(), dateNow.getFullYear()),
            iframe: false,
            hide_blank_weeks: true
        });

    AdminSearchCandidates.Container = new YAHOO.widget.Panel("divContainer",
        {
            width: "16em",
            draggable: false,
            close: true,
            visible: false
        });

    YAHOO.util.Event.on(AdminSearchCandidates.InputDateName, "focus", AdminSearchCandidates.Show);

    AdminSearchCandidates.Calendar.render();
    AdminSearchCandidates.Calendar.selectEvent.subscribe(AdminSearchCandidates.Select);
    AdminSearchCandidates.Container.render();

    if (jQuery.browser.msie)
        AdminSearchCandidates.DivContainerPlace.css("left", Math.round((jQuery("#wrapper")[0].offsetWidth - 180) / 2) + "px");
    else
        AdminSearchCandidates.DivContainerPlace.css("left", Math.round((window.outerWidth - 210) / 2) + "px");
        
    AdminSearchCandidates.DivContainerPlace.show();

    if (jQuery.browser.msie)
    {
        AdminSearchCandidates.Container.show();
        AdminSearchCandidates.Container.hide();
    }
};

AdminSearchCandidates.Show = function()
{
    AdminSearchCandidates.Container.show();
};

AdminSearchCandidates.Select = function(event, date)
{
    if (AdminSearchCandidates.Calendar.getSelectedDates().length > 0)
    {
        AdminSearchCandidates.InputDate.val(String.format("{1:d2}/{2:d2}/{0:d4}", date[0][0][0], date[0][0][1], date[0][0][2]));
    }
    else
        AdminSearchCandidates.InputDate.val("");
    AdminSearchCandidates.Container.hide();
};

AdminSearchCandidates.Clear = function()
{
    AdminSearchCandidates.Container.hide();
    AdminSearchCandidates.InputNames.val("");
    AdminSearchCandidates.InputDate.val("");
    Industry.Clear();
    Job.Clear();
    GeographicPosition.Clear();
    AdminSearchCandidates.ReInit();
};

Type.registerNamespace("CandidateSearchJobs");

CandidateSearchJobs.Init = function(inputKeywords, inputCountry, inputJobTitle, inputIndustry)
{
    CandidateSearchJobs.InputKeywordsName = inputKeywords;
    CandidateSearchJobs.InputCountryName = inputCountry;
    CandidateSearchJobs.InputJobName = inputJobTitle;
    CandidateSearchJobs.InputIndustryName = inputIndustry;
    CandidateSearchJobs.InputDateReg = /^\d\d\/\d\d\/\d\d\d\d$/;
    
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(CandidateSearchJobs.ReInit);
};

CandidateSearchJobs.ReInit = function(sender, args)
{
    CandidateSearchJobs.InputKeywords = jQuery("#" + CandidateSearchJobs.InputKeywordsName);
    CandidateSearchJobs.InputCountry = jQuery("#" + CandidateSearchJobs.InputCountryName);
    CandidateSearchJobs.InputJob = jQuery("#" + CandidateSearchJobs.InputJobName);
    CandidateSearchJobs.InputIndustry = jQuery("#" + CandidateSearchJobs.InputIndustryName);
};

CandidateSearchJobs.Show = function()
{
    CandidateSearchJobs.Container.show();
};

CandidateSearchJobs.Clear = function()
{
    CandidateSearchJobs.InputKeywords.val("");
    CandidateSearchJobs.InputCountry.attr("selectedIndex", 0);
    CandidateSearchJobs.InputJob.attr("selectedIndex", 0);
    CandidateSearchJobs.InputIndustry.attr("selectedIndex", 0);
    //Industry.Clear();
    //Job.Clear();
    //GeographicPosition.Clear();
};

Type.registerNamespace("Home");

Home.Init = function(inputKeywords)
{
    /*Home.InputKeywords = jQuery("#" + inputKeywords);
    Home.InputKeywords.focus(Home.KeywordsFocus);
    Home.InputKeywords.blur(Home.KeywordsBlur);
    
    Home.Show = "signin";
    Home.H3SignIn = jQuery("#signin_toggle");
    //Home.DivSignIn = Home.H3SignIn.next();
    Home.H3SignIn.click(Home.ShowSignIn);
    //Home.SignInHeight = Home.DivSignIn[0].offsetHeight;
    
    Home.H3Search = jQuery("#search_toggle");
    Home.DivSearch = Home.H3Search.next();
    Home.H3Search.click(Home.SearchGoto);
    Home.SearchHeight = Home.DivSearch[0].offsetHeight;
    Home.DivSearch.css("height", Home.SearchHeight);*/
};

Home.SearchGoto = function ()
{
    window.location.href = "/candidate/searchjobs.aspx";
};

Home.ShowSignIn = function()
{
    if (Home.Show == "search")
    {
        Home.H3SignIn.css("background-position", "0px");
        Home.H3SignIn.css("cursor", "default");
        Home.H3Search.css("background-position", "-272px 0px");
        Home.H3Search.css("cursor", "pointer");
        Home.SearchHeight = Home.DivSearch[0].offsetHeight;
        //Home.DivSignIn.animate({ "height": Home.SignInHeight + "px" }, 500, "swing", Home.ResetSignInHeight);
        Home.DivSearch.animate({ "height": "0px" }, 500, "swing");
        Home.Show = "signin"
    }
};

Home.ResetSignInHeight = function()
{
    //Home.DivSignIn.removeAttr("style");
};

Home.ShowSearch = function()
{
    if (Home.Show == "signin")
    {
        Home.H3SignIn.css("background-position", "-272px 0px");
        Home.H3SignIn.css("cursor", "pointer");
        Home.H3Search.css("background-position", "0px");
        Home.H3Search.css("cursor", "default");
        //Home.SignInHeight = Home.DivSignIn[0].offsetHeight;
        //Home.DivSignIn.animate({"height": "0px"}, 500, "swing");
        Home.DivSearch.animate({"height": Home.SignInHeight + "px"}, 500, "swing", Home.ResetSearchHeight);
        Home.Show = "search"
    }
};

Home.ResetSearchHeight = function()
{
    Home.DivSearch.removeAttr("style");
};

Home.KeywordsFocus = function()
{
    if (Home.InputKeywords.val().trim() == "Keyword(s)")
    {
        Home.InputKeywords.val("");
    }
};

Home.KeywordsBlur = function()
{
    if (Home.InputKeywords.val().trim() == "")
    {
        Home.InputKeywords.val("Keyword(s)");
    }
};

Type.registerNamespace("Global");

Global.Init = function()
{
    Global.InitMainMenu();
    Global.InitForm();
};

Global.InitMainMenu = function()
{
    jQuery("#navigation").emenu();
    jQuery("#topnav").find("ul").css("visibility", "hidden").css("opacity", "0");
    jQuery("#navigation").css("visibility", "visible");
};

Global.InitForm = function()
{
    jQuery('div.form-holder div.form-line').append("<div class='cleaner'>&nbsp;</div>");
    jQuery('div.form-holder div.form-label label.required').prepend("<span class='alert'>*</span>&nbsp;");
};

Global.ReInitForm = function(sender, args)
{
    if (args._panelsUpdated.length > 0)
        Global.InitForm();
};

Global.ShowOverlay = function()
{
    var overlay = jQuery("#overlay");

    var height = 0;

    if (jQuery.browser.msie)
        height = document.documentElement.offsetHeight;
    else
        height = window.innerHeight;
        
    if (jQuery.browser.msie && jQuery.browser.version >= 8)
        height -= 4;
    
    var bodyHeight = document.body.offsetHeight;
    if (jQuery.browser.msie == false || (jQuery.browser.msie && jQuery.browser.version >= 8))
        bodyHeight += 60;
        
    if (bodyHeight > height)
        height = bodyHeight;
        
    overlay.css("height", height + "px");
        
    if (jQuery.browser.msie)
        jQuery("#main_text").find("select").hide();
        
    overlay.show();
};

Global.HideOverlay = function()
{
    var overlay = jQuery("#overlay");
    if (jQuery.browser.msie)
        jQuery("#main_text").find("select").show();
    overlay.hide();
};

Global.HideMessage = function()
{
    jQuery("#messages").hide();
};