﻿/**
 * SWF Resizing Javascript Template
 * 
 * What it does:
 *		- Sets minimum width and height of the swf
 *		- Resizes swf size when user resizes the browser window
 *
 * Required Scripts:
 *		- common.js
 *		- swfobject2.js
 *
 * Notes:
 *		- The only thing you need to edit are the properties in the FLPROPS object and everything should work
 *		- If the page has HTML elements (ex. footer) below the swf, please set the heightOffset in FLPROPS
 *		- This script assumes that only ONE swf gets embeded into the HTML document. 
 *		- This script assumes that max width is 100%, and max height to be the height of browser window.
 */

/**** EDITABLE PROPERTIES BELOW ****/

var FLPROPS = {	
	// Editable properties/methods
	flashversion: '10',
	divId: 'flashcontent',
	minWidth: '980',
	minHeight: '695',	
	heightOffset: '',
	flashvars: {
		'sectionID': swfobject.getQueryParamValue("sectionID"), 
		'subSectionID': swfobject.getQueryParamValue("subSectionID"),
		'tertiaryID': swfobject.getQueryParamValue("tertiaryID")
	},
	params: {
		allowScriptAccess:'always'
	},
	attributes: {},
	path: 'main.swf',
	
	// Uneditable properties/methods
	getWidth: function() {
		var browserWidth = document.documentElement.clientWidth;
		if(this.minWidth != '' && this.minWidth != null) {
			if(browserWidth < this.minWidth) {
				return this.minWidth + 'px';
			} else {
				return '100%';
			}
		}
	},
	
	getHeight: function() {
		var browserHeight = document.documentElement.clientHeight;
		if(this.minHeight != '' && this.minHeight != null) {
			if(this.heightOffset != '' && this.heightOffset != null) {
				var newHeight = browserHeight - this.heightOffset;
				return (newHeight < FLPROPS.minHeight ? FLPROPS.minHeight : newHeight);
			} else {
				return (browserHeight < FLPROPS.minHeight ? FLPROPS.minHeight : browserHeight);
			}
		} else {
			return browserHeight;
		}
	}
}

/**** DO NOT EDIT BELOW ****/

/**
 * Gets rid of the the text content in the flash div
 * It assumes only h1 and/or p tags are included in the div
 */
var removeTextContent = (function() {
	if(typeof(swfobject) == 'object' && swfobject.hasFlashPlayerVersion(FLPROPS.flashversion)) {
		var head = document.getElementsByTagName('head');
		var flashstyle = document.createElement('style');
		var css = '#' + FLPROPS.divId + ' p, #' + FLPROPS.divId + ' h1 {display: none}';
		flashstyle.setAttribute('type','text/css');
		if(head[0]){
			if(flashstyle.styleSheet){
				flashstyle.styleSheet.cssText = css;
			}else{
				flashstyle.appendChild(document.createTextNode(css));
			}
			head[0].appendChild(flashstyle);
		}
	}
}());

/**
 * Resizes the swf upon resizing the browser window.
 * It also sets minimum width and height
 */
function swfResize(divId) {
	var width = FLPROPS.getWidth(),
		height = FLPROPS.getHeight();
		
	// set new width and height
	document.getElementById(divId).style.width = width;	
	document.getElementById(divId).style.height = height + 'px';
}

/*
// Initialize events
addLoadEvent(function() {
	swfobject.embedSWF(FLPROPS.path, FLPROPS.divId, FLPROPS.getWidth(), FLPROPS.getHeight(), FLPROPS.flashversion, "", FLPROPS.flashvars, FLPROPS.params, FLPROPS.attributes);
});

addResizeEvent(function() {
	swfResize(FLPROPS.divId);
});
*/
		var flashvars = {};			

		flashvars.sectionID = swfobject.getQueryParamValue("sectionID");
		flashvars.subSectionID = swfobject.getQueryParamValue("subSectionID");
		flashvars.tertiaryID = swfobject.getQueryParamValue("tertiaryID");

		var params = {
			allowscriptaccess:"always",
			menu:"false"
		};

		var attributes = {};

		swfobject.embedSWF("main.swf", "flashcontent", "100%", "790", "9.0.21.0", "", flashvars, params, attributes);
		swffit.fit("flashcontent",1000,695);

