/*! *	Default CMS JS *//* insert image & steps through in order. */var t;var rnd = 0;function randomImg(){	rnd = rnd + 1;	$('img.random-image').each(function(e){		var imgSet = 'panoramic';		if ( $(this).hasClass('generic') ) {			imgSet = 'generic';			if (rnd > 3) { rnd = 1; }		} else if ( $(this).hasClass('wind') ) {			imgSet = 'wind';			if (rnd > 3) { rnd = 1; }		} else {			if (rnd > 15) { rnd = 1; }		}		var imgSrc = globalSettings.dbPath + 'image/' + imgSet + '-' + rnd + '.png';		if (t===undefined) {			$(this).hide(function(){				$(this).attr('src', imgSrc).fadeIn(3000);			});		} else {			$(this).fadeOut(1500, function(){				$(this).attr('src', imgSrc).fadeIn(1500);			});		}	});	t=setTimeout(function(){		randomImg();	},8000);}/* syntax: <div id="google-map">latitude,longitude[,zoom]</div> */function googleMap(){	var el = document.getElementById("google-map");	if (el) {		var coords = el.innerHTML.split(',');		if (coords.length >= 2) {			var lat = parseFloat(coords[0]);			var lon = parseFloat(coords[1]);			var zoom = 15;			if (coords.length >= 3) {				zoom = parseFloat(coords[2]);			}			el.innerHTML = "Loading Map...";			var map = new GMap2(el);			var loc = new GLatLng(lat, lon);			var pin = new GMarker(loc);			map.setCenter(loc, zoom);			map.addOverlay(pin);			map.setUIToDefault();			/*map.openInfoWindow(map.getCenter(), document.createTextNode( ));*/		}	}}/* tooltip binds */	var elements = $('img.tooltip, img.menu-toggle, #menu-expand-all');	elements.mousemove(		function(e){			showTooltip($(this), e );		}	);	elements.mouseout(function(){$("#tooltip-el").remove();});/* tooltip */function showTooltip(t, e) {	var x = e.pageX;	var y = e.pageY;	var el = $(t);	var tooltipText = el.attr('title');	if ( $('#tooltip-el').length === 0 ) {		$("body").append("<p id='tooltip-el'>" + tooltipText + "</p>");	}	var tt = $("#tooltip-el");	var ttOffsetX = 10;	tt		.css("top",( y + 10 ) + "px")		.css("left",( x + ttOffsetX ) + "px")		.fadeIn('slow');	/* fix screen overflow */	var ttTotal = parseInt(tt.css('left'), 10) + tt.width() + ttOffsetX;	if ( ttTotal  >= ($(window).width()) ) {		tt.css("left", ( x - tt.width() - ttOffsetX ) + "px");	}}/* random order fadeout - hidden because evaluating nested callbacks is a bit nasty. * SYNTAX: rFadeTo1('img.rFadeTo','slow','.2') */function rOrder() {return(Math.round(Math.random())-0.5);}function rFadeTo(e,s,o){	var $fade = $(e);	var code = "console.log('done');";	$fade = $fade.sort(rOrder);	$fade.each(function(){		code = "$('#" + $(this).attr('id') + "').fadeTo('"+s+"','"+o+"',function(){"+code+"});";	});	eval(code);}/* menu toggle */function menuToggle(e) {	$(e).each(function(){		$(this)			.next()			.slideToggle('fast');	});}function menuAllToggle() {	var mItems = $('#menu-left h2 img:not(img.menu-left-active)');	var mIcon = "icon/collapse.png";	if ( mItems.length > 0 ) {		$(mItems).parent().next().slideDown();		$(mItems).addClass('menu-left-active');	} else {		mItems = $('#menu-left h2 img.menu-left-active');		mIcon = "icon/expand-2.png";		$(mItems).parent().next().slideUp();		$(mItems).removeClass('menu-left-active');	}	$(mItems).attr('src', mIcon);}/* html submission */function doSubmit(v) {	$('#submit_value').val(v);	document.forms[0].submit();}/* domino search */function doDominoSearch() {	var searchStr = globalSettings.dbPath + "html_search?SearchView&Query=" + $('#filterInput').val();	window.location.href = searchStr;}/* ajax domino search */function ajaxDominoSearch(s) {	var startTime = new Date();	var loadingStr = "<img class=\"ajax-loading\" src=\"" + globalSettings.dbPath + "/image/ajax-loader.gif\"/>";	var searchStr = globalSettings.dbPath + "html_search?SearchView&Query=" + s + " #search-container";	$('#container').html( loadingStr );	$('#container').load( searchStr, function(){		var resultCount = $('#search-container div.search-result').length;		var endTime = new Date();		var elapsedTime = Number(endTime-startTime)/1000;		if ( resultCount >= 1 ) {			$('#search-container').append('<p>' + resultCount + ' results found in ' + elapsedTime + ' seconds</p>');		} else {			$('#search-container').append('<p>No matching documents found in ' + elapsedTime + ' seconds</p>');		}		/* fix back-link for search results */		$('#back-link').unbind('click').attr('href',window.location.href);	});}/* post pageload js */$(function(){	/* menu-top */	var topMenu = $('#menu-top').length;	if ( topMenu >= 1 ) {		var pageTitle = $('#page_title').val();		/* if ( pageTitle.indexOf('</') > -1 )			pageTitle = pageTitle.substr( pageTitle.lastIndexOf('>')+1 ) */		var cl = 'menu-top-current';		var a = pageTitle;		var a2 = $('#top_title').val();		$('#menu-top a').each(function(){			var e = $(this);			var b = e.html();			if ( a2 ) {				if (a == b) { 					cl = 'menu-top-active';				}				a = a2;			}			if (a == b) {				$('a.menu-top-active').removeClass(cl);				$(e).addClass(cl);								/* hilight current page in left menu */				$('#menu-left a').each(function(){					var i = $(this);					var linkTitle = i.html();					/*console.log("linktitle = " + linkTitle);					console.log("pagetitle = " + pageTitle);*/					if ( pageTitle.toLowerCase() == linkTitle.toLowerCase() ) {						$(i).addClass('menu-page-active');					}				});			}		});	}	/* menu-left */	var leftMenu = $('#menu-left').length;	if ( leftMenu >= 1 ) {		$('h2.menu-section-head img').bind('click', function() {			if ( $(this).hasClass('menu-left-active') ) {				$(this).removeClass('menu-left-active');				$(this).attr('src', 'icon/expand-2.png');			} else {				$(this).addClass('menu-left-active');				$(this).attr('src', 'icon/collapse.png');			}			menuToggle( $(this).parent() );			});		$('#menu-expand-all').bind('click', menuAllToggle);		/* handle sub menu content & headers */		var tmp = $('li a.menu-page-active').length;		var par = $('a.menu-page-active').parent();		if ( tmp >= 1 ){			$(par).parent().prev().find('img.menu-toggle').click();		}		tmp = $(par).next().hasClass('menu-section');		if (tmp >= 1) {			$(par).find('img.menu-toggle').click();		}	} else {		$('#container').css('background-image','none');	}	/* datepicker */	$('input.datepicker').datepicker();	/* back button */	$('#back-link').bind('click', function(e){		e.preventDefault();		history.go(-1);	});	/* search */	var sT;	$('#ajax-search').bind('keyup', function(e){		clearTimeout(sT);		var searchVal = escape( $(this).val() );		if ( ( e.keyCode == 13 ) | ( searchVal.length >= 3 ) ) {			sT = setTimeout( "ajaxDominoSearch(\""+searchVal+"\")", 500 );		} else {			return false;		}	});	/* action-buttons */	$('a.action-button').click(function(e){		e.preventDefault();		doSubmit( $(this).html() );	});	randomImg();	googleMap();		// Once the images have been inserted, call the slideshow function	$('.slideshow').cycle({		fx: 'fade',		height: '231px'	});});