
//Ref Jquery
$(document).ready(function() {

    $('.button_wrapper').hover(function() {
        $(this).children('.button_bg').toggleClass('bg_blue_light');
    },function(){
        $(this).children('.button_bg').toggleClass('bg_blue_light');
    });
   
    $('.button_report1').hover(function() {
        $(this).toggleClass('button_report_hover');
            }, function() {
        $(this).toggleClass('button_report_hover');
    });
    
    $('.nav_item_off').hover(function() {
        $(this).toggleClass('nav_item_on');
    },function(){
        $(this).toggleClass('nav_item_on');
    });
    
    $('.sub_nav_hover').hover(function() {             
        $(this).toggleClass('sub_nav_item_on');
    },function(){
        $(this).toggleClass('sub_nav_item_on');
    });

    $('.button_go').hover(function() {
        $(this).toggleClass('button_go_hover');
    }, function() {
        $(this).toggleClass('button_go_hover');
    });

    $('.button_sighting_map').hover(function() {
        $(this).toggleClass('button_sighting_map_hover');
    }, function() {
        $(this).toggleClass('button_sighting_map_hover');
    });

    $('.right_sightings_item_01').hover(function() {
        $(this).toggleClass('right_profile_sightings_on');
    }, function() {
        $(this).toggleClass('right_profile_sightings_on');
    });


    $('input.registration_search_result').hover(function() {
        $(this).addClass('bg_blue_light');
    }, function() {
        $(this).removeClass('bg_blue_light');
    });
});

// Ref /JQuery/jquery.autocomplete.js
function speciesAutoComplete(inputId) {
    var searchword = $("input#" + inputId).val();
    $("#" + inputId).autocomplete("../WebServices/ghBirdAutoCompleteData.ashx?searchword=" + searchword, { 
        minChars:2,
        cachedLength:1,
        mustMatch:true,
        max:100 
    });
}

function threatStatus(Id) {
    var strThreatStatus = "";
    
    switch(Id) {
        case 1:
            strThreatStatus = "Extinct";
            break;
        case 2:
            strThreatStatus = "Extinct in the wild";
            break;
        case 3:
            strThreatStatus = "Critically endangered";
            break;
        case 4:
            strThreatStatus = "Endangered";
            break;
        case 5:
            strThreatStatus = "Vulnerable";
            break;
        case 6:
            strThreatStatus = "Near threatened";
            break;
        case 7:
            strThreatStatus = "Least concern";
            break;
        default:
            strThreatStatus = "Least concern";
            break;
    }
               
    return strThreatStatus;
}

var maxHelpPopups = 10; //Static number can change

function openHelp(Id) {
    //close all pop ups first
    for(i = 1; i < maxHelpPopups; i++) {
        if($("#helpPopup" + i).length) {
            $("#helpPopup" + i).hide();
        }
    }
    
    $("#helpPopup" + Id).show("slow");
}

function closeHelp(Id) {
    $("#helpPopup" + Id).hide("slow");
}

function CommentFocus(inputId) {
    $(function() {
        $("#" + inputId).focus();
    });
}

function changeBg() {
    alert("hello");
  
    $(this).removeClass('grey');
    alert("hello2");
}

function closeFancyBoxRedirct(redirectURL) {
    parent.window.location = redirectURL;
    
}
