//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);
    if( empty( filter ) ) {
    	sal.SetInnerHTMLFromAjaxResponse('getcontents.php?p='+page, 'content');
	} else {
    	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 publication details
function getPubsCDetail(recno) {
    sal2.SetInnerHTMLFromAjaxResponse('pubs-Cdetail.php?recno='+recno, 'detailsData');
    ShowContent('detailsData');
}



// Get webposter details
function getWPDetail(table, recno) {
    sal2.SetInnerHTMLFromAjaxResponse('wpdetails.php?table='+table+'&recno='+recno, 'detailsData');
    ShowLayer('detailsData');
}



// Get gallery index
function getPgIndex(start, step, folder) {
	if( !empty(start) && !empty(step) ) {
		sal.SetInnerHTMLFromAjaxResponse(folder+'/../index.php?start='+start+'&step='+step+'&fldr='+folder, 'content');
	} else {
		sal.SetInnerHTMLFromAjaxResponse(folder+'/../index.php?fldr='+folder, 'content');
	}
}



// Get gallery picture
function getPgExpand(id, folder) {
    sal.SetInnerHTMLFromAjaxResponse(folder+'/../expand.php?index='+id+'&fldr='+folder, 'content');
}



// 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 empty(val){
  if(val) return false;
  else return true;
}
