//set up the salajax settings.
var sal = new salajax();
sal.Debug = 0;
sal.EnableBackButton(true); //turns on the back buttons.
sal.EnableBookmarks(true); //saves state in the clients cookies so bookmarks will work provided they havn't deleted their cookies.
sal.OnStart = 'TestOnStart()'; //enables a script to run before the request is made. e.g. change pointer/icon/loading section of page.
sal.OnEnd = 'TestOnEnd()'; //enables a script to run after the request is returned. e.g. change pointer/icon/loading section of page.
sal.PresendHtml = '<img border="0" src="/images/24-1.gif" alt="Loading..." align="center" />';
sal.OnError = 'DefaultOnError()';//set a function to pass to if there is an error.
sal.OnErrorHtml = '<img border="0" src="/images/error_icon.gif" alt="Error!" /><font color="red">Error!</font>'; //When calling  etInnerHTMLFromAjaxResponse and there is an error, this will be displayed.
sal.EvalScripts = true; //if set to true, will evaluate any javascript in the responseText.
                         //NOTE: to use functions returned in your responseText you must declare the functions in your ajax response like this:
                         //         var FunctionToChange = function(var1,var2)
                         //         {
                         //             //do stuff
                         //         }
                         //
this.KeepDotNetViewState = false; //if set to true will post the current viewstate when using .NET
//end setting the salajax settings.



//set up the salajax settings.
var sal2 = new salajax();
sal2.Debug = 0;
sal2.EnableBackButton(false); //turns on the back buttons.
sal2.EnableBookmarks(false); //saves state in the clients cookies so bookmarks will work provided they havn't deleted their cookies.
sal2.OnStart = 'TestOnStart()'; //enables a script to run before the request is made. e.g. change pointer/icon/loading section of page.
sal2.OnEnd = 'TestOnEnd()'; //enables a script to run after the request is returned. e.g. change pointer/icon/loading section of page.
sal2.PresendHtml = '<img border="0" src="/images/24-1.gif" alt="Loading..." align="center" />';
sal2.OnError = 'DefaultOnError()';//set a function to pass to if there is an error.
sal2.OnErrorHtml = '<img border="0" src="/images/error_icon.gif" alt="Error!" /><font color="red">Error!</font>'; //When calling  etInnerHTMLFromAjaxResponse and there is an error, this will be displayed.
sal2.EvalScripts = true; //if set to true, will evaluate any javascript in the responseText.
                         //NOTE: to use functions returned in your responseText you must declare the functions in your ajax response like this:
                         //         var FunctionToChange = function(var1,var2)
                         //         {
                         //             //do stuff
                         //         }
                         //
this.KeepDotNetViewState = false; //if set to true will post the current viewstate when using .NET
//end setting the salajax settings.



//set up the salajax settings.
var sal3 = new salajax();
sal3.Debug = 1;
sal3.EnableBackButton(false); //turns on the back buttons.
sal3.EnableBookmarks(false); //saves state in the clients cookies so bookmarks will work provided they havn't deleted their cookies.
sal3.OnStart = 'TestOnStart()'; //enables a script to run before the request is made. e.g. change pointer/icon/loading section of page.
sal3.OnEnd = 'TestOnEnd()'; //enables a script to run after the request is returned. e.g. change pointer/icon/loading section of page.
sal3.PresendHtml = '<img border="0" src="/images/24-1.gif" alt="Loading..." align="center" />';
sal3.OnError = 'DefaultOnError()';//set a function to pass to if there is an error.
sal3.OnErrorHtml = '<img border="0" src="/images/error_icon.gif" alt="Error!" /><font color="red">Error!</font>'; //When calling  etInnerHTMLFromAjaxResponse and there is an error, this will be displayed.
sal3.EvalScripts = true; //if set to true, will evaluate any javascript in the responseText.
                         //NOTE: to use functions returned in your responseText you must declare the functions in your ajax response like this:
                         //         var FunctionToChange = function(var1,var2)
                         //         {
                         //             //do stuff
                         //         }
                         //
this.KeepDotNetViewState = false; //if set to true will post the current viewstate when using .NET
//end setting the salajax settings.



var TestOnStart = function()
{
    if(sal.Debug >= 2)
    {
        alert("OnStart triggered");
    }
}



var TestOnEnd = function()
{
    if(sal.Debug >= 2)
    {
        alert("OnEnd triggered");
    }
}



// Get new info for content div
function getContentsDiv(page, filter) {
    scroll(0,0);
    sal.SetInnerHTMLFromAjaxResponse('getcontents.php?p='+page+'&s='+filter, 'content');
    sal.SetInnerHTMLFromAjaxResponse('getlinks.php?p='+page, 'links');
}



// Submit form, load response in content div
function getFormContentsDiv(formid) {
    scroll(0,0);
    sal3.SetInnerHTMLFromAjaxResponse(formid, 'content');
}



// Get picture for floating picture div
function getPicPopupC(img, txt) {
    sal2.SetInnerHTMLFromAjaxResponse('getpicpopup.php?img='+img+'&txt='+txt+'&dType=C', 'picPopup');
    ShowContent('picPopup');
}



// Get picture for static picture div
function getPicPopupL(img, txt) {
    sal2.SetInnerHTMLFromAjaxResponse('getpicpopup.php?img='+img+'&txt='+txt+'&dType=L', 'picPopup');
    ShowLayer('picPopup');
}



// Get species summery details
function getFactSheet(recno) {
    sal.SetInnerHTMLFromAjaxResponse('/summeries/nis_factsheet.php?toc_id='+recno, 'content');
}



// Get species summery add protos
function getAddPhotos(recno) {
    sal.SetInnerHTMLFromAjaxResponse('/summeries/nis_fs_photos.php?toc_id='+recno, 'content');
}



// Get species summery collection records
function getCollRecs(recno) {
    sal.SetInnerHTMLFromAjaxResponse('/summeries/nis_records.php?gss_id='+recno, 'content');
}



// Get collection record institution info
function getInstInfo(recno) {
    sal.SetInnerHTMLFromAjaxResponse('/summeries/nis_instinfo.php?instcode='+recno, 'content');
}



// Get collection record detail info
function getCollData(recno) {
    sal.SetInnerHTMLFromAjaxResponse('/summeries/nis_colldata.php?coll_id='+recno, 'content');
}



// Get webposter details
function getWPDetail(table, recno) {
    sal2.SetInnerHTMLFromAjaxResponse('wpdetails.php?table='+table+'&recno='+recno, 'detailsData');
    ShowLayer('detailsData');
}



// Cross-browser code for IE/Mozilla
// var bookmarkurl="Add full URI here"
// var bookmarktitle="Add your title here"

function addbookmark(bookmarkurl,bookmarktitle){
if (document.all)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)       //IE
    window.sidebar.addPanel( bookmarktitle, bookmarkurl, '' );   //Moz
}
//add javascript:addbookmark(); to the HTML to call the function


function FP_swapImg() {//v1.0
    var doc=document,args=arguments,elm,n;
    doc.$imgSwaps=new Array();
    for(n=2; n<args.length; n+=2) { 
        elm=FP_getObjectByID(args[n]);
        if(elm) {
            doc.$imgSwaps[doc.$imgSwaps.length]=elm;
            elm.$src=elm.src;
            elm.src=args[n+1];
        }
    }
}

function FP_preloadImgs() {//v1.0
    var d=document,a=arguments;
    if(!d.FP_imgs) d.FP_imgs=new Array();
    for(var i=0; i<a.length; i++) {
        d.FP_imgs[i]=new Image;
        d.FP_imgs[i].src=a[i];
    }
}

function FP_getObjectByID(id,o) {//v1.0
    var c,el,els,f,m,n;
    if(!o) o=document;
    if(o.getElementById) el=o.getElementById(id);
    else if(o.layers) c=o.layers;
    else if(o.all) el=o.all[id];
    if(el) return el;
    if(o.id==id || o.name==id) return o;
    if(o.childNodes) c=o.childNodes;
    if(c) for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
    f=o.forms;
    if(f) for(n=0; n<f.length; n++) { els=f[n].elements; for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
    return null;
}

