// when the document is loaded
$(document).ready(function() {

 //jQuery functions
	fnAssignGallery();
});

/********************************************************************************

Name: 					Flash detect.
Description:			boolean true/false if installed and version number 
						accessed via flash.version
@var flash.installed	true is flash is installed
@var flash.version		flash player version
*********************************************************************************/

var flash = new Object();	
flash.installed = false;

if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {		
			flash.installed = true;					
			flash.version = eval(navigator.plugins[x].description.split('Shockwave Flash ')[1].split('.')[0]);					
			break;
		}
	}
}
else if (window.ActiveXObject) {
	for (x = 2; x <= 20; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {		
				flash.installed = true;	
				flash.version = x;
			}
		}
		catch(e) {}
	}
}



	
/********************************************************************************

Name: 				Flash embed
Description:		Writeout flash code. Fixes Eolas update for IE as well.
@param	swf			String path to swf file
@param	width		Number value of movie width
@param	height		Number value of movie height
@param	minVersion	minimum required version of flash for swf. defaults to 6
@param 	nonFlashId	the id of the container for non-flash content. 

*********************************************************************************/

flash.insert = function(swf,width,height,minVersion,nonFlashId) {		
	swf = swf.replace(/\./g,"%2E") // encode periods as %2e	

	if(!minVersion){minVersion = 6;}	
	if (flash.installed) {
		if(flash.version > minVersion) {		
			flashObject = '<embed src="'+swf+'" menu="false" width="'+width+'" height="'+height+'" scale="noscale" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" salign="T" />';	
			fnHide(nonFlashId);
			document.write(flashObject);	
		}
		else {
			fnShow(nonFlashId);
		}	
	}
}


function fnHide(id) {
	if(!document.getElementById(id)){return false};
	var oTarg = document.getElementById(id).style;
	oTarg.position = "absolute";
	oTarg.top = "-5000px";
	oTarg.left = "0";
}

function fnShow(id) {
	if(!document.getElementById(id)){return false};
	var oTarg = document.getElementById(id).style;
	oTarg.position = "static";
	oTarg.top = "";
	oTarg.left = "";
}


function fnAssignGallery(){
	if($('#gallery .picture').length >0){
		$('#gallery .picture a').lightBox({imageLoading: '/healthyBonesAssets/images/lightbox-loader.gif',
	imageBtnClose: '/healthyBonesAssets/images/lightbox-close.gif',
	imageBtnPrev: '/healthyBonesAssets/images/lightbox-prev.gif',
	imageBtnNext: '/healthyBonesAssets/images/lightbox-next.gif'});
	}
}
