//Overlay Flash v1.01 021010, deployed 021010

var parentSwf;
var photoId;
var globalphotoId;

if (parentSwf == "" || parentSwf == null) {
	parentSwf = "flashcontent";
}

embeddedSwf = "media/galleryOverlay.swf"

function loadOverlayFlash(swfcontrol) {
	var flashvars = {};
	
	var params = {
		base:"media",
		allowScriptAccess:"always",
		allowFullScreen:"true"
		};
		
	var attributes = {
		id:swfcontrol,
		name:swfcontrol,
		style:"outline:none;"
		}
	swfobject.embedSWF(embeddedSwf, swfcontrol, "100%", "100%", "9.0.115", "", flashvars, params, attributes);
}

/** jQuery Functions **/	
	$(document).ready(function(){

		/*Insert IDs and styles */
		$("body").prepend('<div id="flashOverlay"><div id="flashOverlayEmbed"><p> To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player. <a href="http://www.adobe.com/go/getflashplayer" rel="external">Get the free Adobe Flash Player.</a></p></div></div>');
	
		
		jQuery.each(jQuery.browser, function(i) {
			if ($.browser.msie && $.browser.version.substr(0,1)<8) {			 
				$("#flashOverlay").css({'display' : 'none', 'position' : 'absolute', 'z-index' : '100', 'width' : '100%', 'height' : '100%', 'background-color' : '#000', 'top' : '0', 'left' : '0', 'overflow' : 'hidden'});
			}
			
			else {
			
				$("#flashOverlay").css({'display' : 'none', 'position' : 'fixed', 'z-index' : '100', 'width' : '100%', 'background-color' : '#000', 'top' : '0', 'left' : '0', 'overflow' : 'hidden', 'outline' : 'none'});
			
			}
		});
	});


	
function openFlashGallery(photoId) {

	globalphotoId = photoId;
	
	loadOverlayFlash("flashOverlayEmbed");
	
	if ($("#flashOverlay").is(":hidden")) {
		
//alert('height:'+ $(document).height());
//alert('height ie6 method:'+ document.documentElement.clientHeight);


			//fix IE overlay sizing
			jQuery.each(jQuery.browser, function(i) {
				if ($.browser.msie && $.browser.version.substr(0,1)<8) {
					 window.scrollTo(0,0);
					 
					$("body").css("width","100%").css("height","100%").css("position","absolute");
					$("html").css("width","100%").css("height","100%").css("overflow","hidden");
					$("#flashOverlay").css("height",document.documentElement.clientHeight+"px");
					
				} else { //other browsers
					$("body").css("width","100%").css("height","100%").css("overflow","hidden");
					$("#flashOverlay").css("height","100%")
					$("select").css("visibility","hidden");	
				}
			}); 
					 
		
					
			$('#flashOverlay').css('display','block');
			
	}
}

//swf request for id
function returnPhotoId(){
	return globalphotoId;
}
	

function closeFlashGallery() {
var theParentSwf = document.getElementById(parentSwf);
	
	  if ($("#flashOverlay").is(":block")) {
		
		$("select").css("visibility","visible");
			
			$('#flashOverlay').fadeOut('fast', function() {
			$("body").css("width","auto").removeAttr("style");
			
				//fix IE overlay sizing
				jQuery.each(jQuery.browser, function(i) {
					if ($.browser.msie && $.browser.version.substr(0,1)<8) {
						$("body").css("width","auto").removeAttr("style");
						$("html").css("width","auto").removeAttr("style");
					}
				});
				
				//destroy swf embed (ff method)
				loadOverlayFlash();
							
				//resume parent swf activity
				//theParentSwf.closeFlashGallery();
				
			  });
      }
}