// JavaScript Document

var slideshowOptions = {

/* these options DO NOT work as slideshow options
,	outlineType:		'glossy-dark'
,	wrapperClassName:	'dark'
,	fadeInOut:			true		// not sure???
,	numberPosition:		'caption'	// not sure???
*/

	captionTitleDivider:	' &nbsp;&mdash;&nbsp; '

,	autoplay:			true
,	interval: 			4000
,	repeat:				false

,	useControls: 		true
//,	fixedControls:		'fit'	// only good when controls 'centered' OR images are all the same size

//,	captionEval:		'this.a.title'

,	overlayOptions: {
		position:		'bottom center',
		relativeTo:		'viewport'
	}
	//	move controls into caption-bar (down/left) and align nicely in bottom-right corner
	/* WHITE Controlbar 
		position:		'bottom right'
	,	offsetY:		46
	,	offsetX:		19
	*/
	/* BLACK Controlbar
		position:		'bottom right'
	,	offsetY:		49
	,	offsetX:		19
	*/

,	thumbstrip: {
		mode:			'horizontal'
	,	position:		'above'
	,	relativeTo:		'expander'
	}

}; // slideshowOptions


var highslideOptions = {

	// image & outline display
	outlineType_html:			'rounded-white'
,	outlineType_image:			'rounded-white' // glossy-dark 

,	overlayList: [
	//	The mac-style close button - for HTML popups
		{	overlayId:		'closebuttonHTML'
		,	position:		'top right'
		,	useOnHtml:		true
		//,	fade:			2	// fading the semi-transparent overlay looks bad in IE
		}
	/*	The X-style close button - for image popups
	,	{	overlayId:		'closebuttonImage'
		,	position:		'bottom right'
		,	useOnHtml:		false
		}
	*/
	//	the controlbar overlay loads automatically - use CSS to set the background image
	]

/*
,	useBox:				true
,	width:				1100
,	height:				600
*/

	// Credits appear at upper-left - ALWAYS a hyperlink
,	showCredits:				false
,	blockRightClick:			false

	//outlineStartOffset:		3	// ends at 10
	//padToMinWidth:			false // pad the popup width to make room for wide caption

	// Full Expand icon appears when full-size image cannot fit onscreen
,	showFullExpandIcon:			true
,	fullExpandPosition:			'bottom right'
,	fullExpandOpacity:			0.7

	// Slideshow options
	//dynamicallyUpdateAnchors:	false // disable auto-checking anchors when starting a slideshow
,	transitions:				['expand', 'crossfade']
,	align:						'center' // center popup in window
,	fadeInOut:					true	// fade image when animating open/closed?

	// HTML popup widths (custom data)
,	width_normal:				600	// default
,	width_wide:					750

	// type-specific margins (custom data)
,	marginTop_image:			8
,	marginBottom_image:			8
,	marginTop_slideshow:		8
,	marginBottom_slideshow:		63	// 65
,	marginTop_html:				20
,	marginBottom_html:			20

};


$(document).ready(function(){

	Print.init();

	//fixBannerInPlace();
});

var Print = {

	init: function () {
		if (window.print)
			$('.btnPrint').click( Print.openDialog ).show().title('Print Page');
		$('.btnPrintPreview').click( Print.preview ).show().title('Toggle Print Preview');
	}

,	preview: function () {
		var path	= self.location.pathname
		,	SS		= Stylesheets.getSheet( 'layoutPrint' )
		,	DOM2	= !!SS && SS.media.mediaText
		,	mediaText;
		if (path.right(1) == '/')
			path = path.fromRight(1);
		if (SS) {
			if (DOM2) {
				mediaText = SS.media.mediaText || $(SS).attr('media');
				if (!mediaText.contains('screen') && !mediaText.contains('all'))
					SS.media.mediaText = mediaText +',screen';
					//SS.media.appendMedia('screen');
				else
					SS.media.mediaText = 'print';
					//SS.media.deleteMedia('screen');
			} else {
				if (self.location.search.contains('preview'))
					self.location = path;
					//$(SS).attr( 'media', 'print' );
				else
					self.location = path +'?preview';
					//$(SS).attr( 'media', mediaText +',screen' );
			}
		}
	}

,	openDialog: function () {
		if (window.print)
			window.print();
	}
};


function fixBannerInPlace () {
	if (!$.browser.msie || $.browser.version > 6) {
		var $Header = $('#Layout-Header');
		$Header.css({ height: $Header.outerHeight() });
		// TODO: fixed Width prevents elasticity!
		$('#Banner').css({ position: 'fixed', width: $Header.outerWidth(), zIndex: 3 });
	}
};
