//---------------------------------------------------------------------------
//
//  textResizeBridge
//	v1.2
//
//  Created by: Bob Corporaal - reefscape.net on 23-09-2006.
//  Copyright (c) 2006 reefscape.net. All rights reserved.
//
//
//	Description:
//	
//	Functions as a bridge between actionscript and the TextResizeDetector.
//	This is the Javascript side of things.
//	For more info see: http://reefscape.net & http://alistapart.com/articles/fontresizing
//
//
//	Changes:
//
//	v1.2	2-10-06
//	- added MIT license
//
//	v1.1 	29-9-06
//	- added workaround for captured keystrokes (fontSizeUp & fontSizeDown)
//	- updated comments
//
//	v1		27-9-06
//	- initial release
//	
//
//	Usage:
//	
//	All calls are done from Flash. See included Application.as for example code
//
//
//	MIT / X11 License
//
//	Copyright (c) 2006 Bob Corporaal - reefscape.net
//	
//	Permission is hereby granted, free of charge, to any person obtaining a copy of 
//	this software and associated documentation files (the "Software"), to deal in 
//	the Software without restriction, including without limitation the rights to 
//	use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
//	of the Software, and to permit persons to whom the Software is furnished to do 
//	so, subject to the following conditions:
//	
//	The above copyright notice and this permission notice shall be included in all 
//	copies or substantial portions of the Software.
//	
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
//	SOFTWARE.
//---------------------------------------------------------------------------
//
var  fontSizes;
//
//	onFontResizeInit - called when the TextResizeDetector is inited
//
function onFontResizeInit()
{
	var iBase       = TextResizeDetector.addEventListener(onFontResize,null);
	flashBridge.onFontResizeInit(iBase);
	fontSizes       = new Object();
	fontSizes.iBase = iBase;
}

//
//	OnFontResize - called when the font size changes and passes it on to Flash
//
function onFontResize(e,args)
{
	fontSizes 			= new Object();
	fontSizes.iBase 	= args[0].iBase;
	fontSizes.iSize 	= args[0].iSize;
	fontSizes.iDelta 	= args[0].iDelta;
	flashBridge.onFontResize(fontSizes);
}
//
//	currentSize - get the current sizes
//
function getSize() {
	return {current:TextResizeDetector.getSize()};
}
//
//	id of element to check for and insert control
//
TextResizeDetector.TARGET_ELEMENT_ID = 'textResizeContent';
//
//	function to call once TextResizeDetector has init'd
//
TextResizeDetector.USER_INIT_FUNC = onFontResizeInit;
/*

	Scale fonts size up and down using different stylesheets. Used as an alternative
	to direct browser font size scale for Player / browser combinations that capture
	the resize keystrokes.

	concept by Bojan Mihelac 
	for more information see: http://alistapart.com/articles/relafont
	
*/
function fontsizeup() 
{	
	//
	//	get current style sheet
	//
	active = getActiveStyleSheet();
	//
	//	set new depending on current
	//
	switch (active) 
	{
		case 'A--' : 
			setActiveStyleSheet('A-');
		break;
		
		case 'A-' : 
			setActiveStyleSheet('A');
		break;
		
		case 'A' : 
			setActiveStyleSheet('A+');
		break;
		
		case 'A+' : 
			setActiveStyleSheet('A++');
		break;
		
		case 'A++' :
		break;
		
		default :
			setActiveStyleSheet('A');
		break;
	}
}

function fontsizedown() 
{
	//
	//	get current style sheet
	//
	active = getActiveStyleSheet();
	//
	//	set new depending on current
	//
	switch (active) 
	{
		case 'A++' : 
			setActiveStyleSheet('A+');
		break;

		case 'A+' : 
			setActiveStyleSheet('A');
		break;

		case 'A' : 
			setActiveStyleSheet('A-');
		break;

		case 'A-' : 
			setActiveStyleSheet('A--');
		break;

		case 'A--' : 
		break;

		default :
			setActiveStyleSheet('A--');
		break;
	}
}
