﻿//----------------------------------------------------------------------
//script is based on the Fredrik Normén's solution presented in his blog:
//http://fredrik.nsquared2.com/viewpost.aspx?postid=407
//----------------------------------------------------------------------
//Script enables update progress display when triggered from
//other controls than the ones wrapped in the update panel as
//trigger controls do not enable update progress.
//The script has to be put after the update manager, otherwise will not work


//It works by hooking up to the initialize and endRequest of the pageRequestManager
var prm = Sys.WebForms.PageRequestManager.getInstance();

//and then hooking up to the events of the page request manager
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);

var postBackElement;

//function performed on the initializing async postback
function InitializeRequest(sender, args) {

    //checks if the page is while async postback and if so it cancells it
    if (prm.get_isInAsyncPostBack()) {
        args.set_cancel(true);
    }

    //gets the element that caused postback
    postBackElement = args.get_postBackElement();

    //do some advanced dropdown maintenance (see BatSelectorClientSide)
    manageBatSelector(postBackElement.id);


//    //and if the element is the wanted one
//    if (postBackElement.id == 'ZoomToFit' ||
//        postBackElement.id == 'LastView' ||
//        postBackElement.id == 'Strafe' ||
//        postBackElement.id == 'DropDownSpecies' ||
//        postBackElement.id == 'DropDownFamily' ||
//        postBackElement.id == 'DropDownGenus' ||
//        postBackElement.id == 'SearchDrawings' ||
//        postBackElement.id == 'SearchButton' ||
//        postBackElement.id == 'ClearSelectionButton' ||
//        postBackElement.id == 'TooManyRecordsReturnTop100' ||
//        postBackElement.id == 'TooManyRecordsReturnAll'
//        ) {
//        //it displays the updateProgress after given amount of miliseconds

//        setTimeout(showUpdateProgress, 500);


//    }
}

//function performed on the end of an async request
function EndRequest(sender, args) {

    //check if there are download buttons to be shown
    showDownloadButtons();
    
    //talk to google maps
    talkToMaps();

}