// shared.js script, version 2.1, 08-13-03

// global vars ======================================================
var loc = location.pathname.split('/');
loc.length = loc.length - 1; // removes filename 

var d = location.pathname.replace(/\/[^\/]*/g,'../'); // return one depth too deep, see next line for fix
d = d.substring(0,(d.length-3)); // turns this: ../../ into this ../
// /global vars ======================================================

// img preloads =====================================================
/*
hh = new Image(); hh.src = "/pix/hh.gif"; hh_roll = new Image(); hh_roll.src = "/pix/hh_roll.gif";
*/	
// /img preloads =====================================================

// popup window functions ==========================================
function popflex(URL,winName,W,H,scroll) {
	if (scroll == "no")
		{scroll = "scrollbars=no";}
	else if (scroll == "yes")
		{scroll = "scrollbars";}
	var popwin = window.open(URL, winName,"top=0,left=30,width="+W+",height="+H+",resizable=no,"+scroll+"");
	popwin.focus();
	}	
// /popup window functions ==========================================

function showhide_v3() {
	divid = arguments[0];
	classes = arguments[1];
	onstate = arguments[2];
	force = ''; //stops toggling between on and off and forces either on or off whenever clicked 
	if (typeof arguments[3] != 'undefined') {force = arguments[3];}

	var state = 'none';
	if (document.getElementById(divid).className == classes+' none' || 
	document.getElementById(divid).className == 'none') {
		var state = onstate;
		}
	if (force != '') {state = force;}
	document.getElementById(divid).className = classes+' '+state;
	return divid;
	}

var n = 0;
function crossfade(speed) {
	dissolve(divs_to_fade[n],100,'up',speed);
	n++;
	if (n == divs_to_fade.length) {n = 0;}
	dissolve(divs_to_fade[n],1,'down',speed);
	}
function dissolve(obj_id,o_v,updown,speed) {
	var obj = document.getElementById(obj_id);
	if (obj == null) {return;}
	if (obj.filters) {obj.style.filter = 'alpha(opacity='+o_v+')';}
	obj.style.KHTMLOpacity = o_v/100;
	obj.style.MozOpacity = o_v/100;
	obj.style.opacity = o_v/100;
	if (updown == 'down') {
		if (o_v <= 100) {
			o_v += 5;
			window.setTimeout('dissolve("'+obj_id+'",'+(o_v)+',"'+updown+'","'+speed+'")',speed);
			}
		}
	if (updown == 'up') {
		if (o_v >= 0) {
			o_v -= 5;
			window.setTimeout('dissolve("'+obj_id+'",'+(o_v)+',"'+updown+'","'+speed+'")',speed);
			}
		}
	}


function load_functions() {
	/*
	NOTE: this function MUST be called from body onload, ex: <body onload="load_functions();">
	this avoids render timing issues in Safari
	*/
	// functions to be run on every page:
	set_height();

	// functions run on a per/page basis. loadfunctions is an array declared in /folder/pagescript.js, each array object represents a function declared either in /shared.js or /folder/pagescript.js
	if (typeof loadfunctions !== 'undefined') {
		for (var n=0; n < loadfunctions.length; n++) {
			eval(loadfunctions[n]+'();');
			}
		}
	}




function set_height() {
	var minheight = 400;
	var total = 20;
	
	function numberorder(a,b) {return a-b;}
	
	// page boxes =======================================================
	//var pagecontainer = document.getElementById('pagecontainer');
	var boxes = [];
	var i = -1;
	for (var n = 0; n < total; n++) {
		var box = document.getElementById('pagebox'+n);
		if (box == null) {continue;}
		i++;
		boxes[i] = parseInt(box.offsetHeight);
		}
	if (document.getElementById('pageboxfull') != null) {
		var box = document.getElementById('pageboxfull');
		boxes[(i+1)] = parseInt(box.offsetHeight);
		}
	
	// find out who's longest =====
	boxes.sort(numberorder);
	var longest = boxes[(boxes.length-1)];//alert(longest);
	if (longest < minheight) {longest = minheight;}
	// /find out who's longest =====
	
	// reset all containers to the longest value =====
	//pagecontainer.style.height = longest+'px';
	for (var n = 0; n < total; n++) {
		var box = document.getElementById('pagebox'+n);
		if (box == null) {continue;}
		box.style.height = longest+'px';
		box.style.MozBoxSizing = 'border-box';
		}
	if (document.getElementById('pageboxfull') != null) {
		var box = document.getElementById('pageboxfull');
		box.style.height = longest+'px';
		box.style.MozBoxSizing = 'border-box';
		}
	// /page boxes =======================================================
	
	// shell boxes =======================================================
	var shell_boxes = [];
	var i = -1;
	for (var n = 0; n < total; n++) {
		var box = document.getElementById('shellbox'+n);
		if (box == null) {continue;}
		i++;
		shell_boxes[i] = parseInt(box.offsetHeight);
		}
	
	// find out who's longest =====
	shell_boxes.sort(numberorder);
	var longest = shell_boxes[(shell_boxes.length-1)];//alert(longest);
	if (longest < minheight) {longest = minheight;}
	// /find out who's longest =====
	
	// reset all containers to the longest value =====
	for (var n = 0; n < total; n++) {
		var box = document.getElementById('shellbox'+n);
		if (box == null) {continue;}
		box.style.height = longest+'px';
		box.style.MozBoxSizing = 'border-box';
		}
	// /shell boxes =======================================================
	}

// jQuery functions ============================================================
// lightbox =====
//$(function() {
	/*
	// Use this example, or...
	$('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
	// This, or...
	$('#gallery a').lightBox(); // Select all links in object with gallery ID
	// This, or...
	$('a.lightbox').lightBox(); // Select all links with lightbox class
	// This, or...
	$('a').lightBox(); // Select all links in the page
	// ... The possibility are many. Use your creative or choose one in the examples above
	*/
//	$('.gallery a').lightBox(); // Select all links in object with gallery class
//	$('.gallery_2 a').lightBox(); // Select all links in object with gallery_2 class
//});
// /lightbox =====

// prettyPhoto lightbox =====
$(document).ready(function(){
	//$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',slideshow:2000, autoplay_slideshow: true});
	//$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000});
	
	//$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
	//	custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
	//	changepicturecallback: function(){ initialize(); }
	//});
	//$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
	//	custom_markup: '<div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
	//	changepicturecallback: function(){ _bsap.exec(); }
	//});
	
	$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',slideshow:4000, autoplay_slideshow: false,overlay_gallery: false});

});
// /prettyPhoto lightbox =====

// /jQuery functions ============================================================

