// JavaScript Document
// declare sitewide variables
var depth = (typeof(fd) == 'undefined')? 0 : fd ; // folder depth
var path = (!depth)? '.' : '..' ;
var bannerDiv = '#banner',
	bodyDiv = '#body',
	rightpaneDiv = '#right-pane',
	footerDiv = '#footer',
	html = '';
var bannerUrl = path + '/utils/banner.php?p=' + path,
	rightpaneUrl = path + '/utils/right-pane.php?pg=' + pg + '&p=' + path,
	footerUrl = path + '/utils/footer.php?p=' + path;

// initiate startup elements and event handlers and load page sections
$(document).ready(function(){	
	$.ajax({
		   success: function(d){
			   	$(bannerDiv).empty().append(d);
				if(pg != 'index') getPage(rightpaneUrl,rightpaneDiv);
				if(getPage(footerUrl,footerDiv)){
					var hidden = bodyDiv + ',' + footerDiv;
					$(hidden).show();
					$('#qstr').click(function(){
									if($(this).val() == 'Search') $(this).val('') })
							  .blur(function(){
									if($(this).val() == '') $(this).val('Search') });
					}
			   	},
			url: bannerUrl, cache: false
			});
	});

// get pager using AJAX
function getPage(url, div)
	{
	// jquery ajax
	$.ajax({
		   success: function(d){
			   $(div).empty().append(d);
			   },
		   url: url,
		   cache: false
		   });
	return true;
	}

// show ajax error
function ajaxerror( objAJAXRequest, strError ){
	var errmsg = '';
	switch(strError){
		case "timeout":
			errmsg = "Connection to the server has been lost. Try resending the information" ;
		break;
		case "parsererror":
			errmsg = "The system experienced problems processing your request. Results Unknown." ;
		break;
		default:
			errmsg = strError;
		}
	alert("ERROR: " + errmsg);
	}