function getFlashVersion(){
	// ie 
	try {
		try {
		// avoid fp6 minor version lookup issues
			var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
				try { axo.AllowScriptAccess = 'always'; }
				catch(e) { return '6,0,0'; }
		} catch(e) {}
			return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];

		// other browsers 
		} catch(e) {
			try {
				if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
					return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
				}
		} catch(e) {}
	}
		return '0,0,0';
	}

var version = getFlashVersion().split(',').shift();
var cookie = $.cookie('acuvueflashdetection');
if (cookie != '1' && version < 9){
	//build the objects on the page
	var objSurround = document.createElement('div');
		objSurround.setAttribute('id','surround');
		objSurround.style.display = 'inline';
	document.body.appendChild(objSurround);
	
	var objApp = document.createElement('div');
		objApp.setAttribute('id','app');
		objApp.style.width = '800px';
		objApp.style.height = '560px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);
	
	var objWarn = document.createElement('div');
		objWarn.setAttribute('id','flashdetection');
		objWarn.innerHTML = "<h4>Install Adobe&reg; Flash Player</h4>";
		objWarn.innerHTML += "<p>This site uses <strong>Adobe&reg; Flash technology</strong>, so please ensure that you have the Adobe Flash Player installed and JavaScript enabled in your web browser. You may download the <strong>Adobe&reg; Flash Player</strong> for FREE.</p>";
		objWarn.innerHTML += "<div class='info'><p><strong>You are leaving Acuvue.com and are being automatically redirected to:</strong></p><a href='http://get.adobe.com/flashplayer/' class='link-flashdetection'>http://get.adobe.com/flashplayer/</a></div>";
		objWarn.innerHTML += "<p>This link will take you to a website to where our <a href='/privacy_policy.htm' class='underline' target='_blank'>Privacy Policy</a> does not apply. You are solely responsible for your interactions with that website. We encourage you to read the Privacy Policy of every website you visit.</p>";
		objWarn.innerHTML += "<div class='confirm'><input type='button' onclick='openURL(); closeFlashDetection();' class='get-started' value='CONTINUE'/><input type='button' onclick='closeFlashDetection(); setDetectionOff();' class='get-started' value='CLOSE'/></div>";
	objApp.appendChild(objWarn);
	
	//grab the current window height
	var arrayPageSize = getTheWindowSize();
	
	//size the ghosted BG to the window height
	objSurround.style.height = (arrayPageSize[1] + 'px');
	objSurround.style.display = 'block';
	
	//turn the mini app div on and center in the window
	objApp.style.display = 'block';
	objApp.style.left = (((arrayPageSize[0]/2)-400) + 'px');
	
	$('html').addClass('overflow');
	//set up a timer to call the new page
	t = setTimeout('window.open("http://get.adobe.com/flashplayer/");closeFlashDetection();', 8000);
	
	//// DOCUMENT RESIZE
	window.onresize = function(){
		var arrayPageSize = getTheWindowSize();
		
		//size the ghosted BG to the window height
		objSurround.style.height = (arrayPageSize[1] + 'px');
		objSurround.style.display = 'inline';
		
		//turn the mini app div on and center in the window
		objApp.style.display = 'block';
		objApp.style.left = (((arrayPageSize[0]/2)-400) + 'px');
	}
}
// SET THE COOKIE TO DONT SHOW THE FLASH DETECTION FEATURE	
function setDetectionOff(){ $.cookie('acuvueflashdetection','1'); }

// OPEN THE URL TO DOWNLOAD THE PLAYER
function openURL(){ window.open("http://get.adobe.com/flashplayer/"); }

// CLOSE THE FLASH DETECTION FEATURE
function closeFlashDetection(){
	var objSurround = document.getElementById('surround');
	var objApp = document.getElementById('app');
	var objAppContentBG = document.getElementById('appExtraContentBG');
	var objAppContent = document.getElementById('appExtraContent');
	var objClose = document.getElementById('closeDIV');

	if(objSurround!=null){document.body.removeChild(objSurround)};
	if(objApp!=null){document.body.removeChild(objApp)};
	if(objAppContentBG!=null){document.body.removeChild(objAppContentBG)};
	if(objAppContent!=null){document.body.removeChild(objAppContent)};
	if(objClose!=null){objClose.parentNode.removeChild(objClose)};

	$("#surround").remove();
	$("#app").remove();
	$('html').removeClass('overflow');
}
