function getTheWindowSize(){
	var myXscroll;
	var myYscroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		myXscroll = document.body.scrollWidth;
		myYscroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		myXscroll = document.body.scrollWidth;
		myYscroll = document.body.scrollHeight;
	} else { // code for Mac IE... but also works in Explorer 6 Strict, Mozilla and Safari
		myXscroll = document.body.offsetWidth;
		myYscroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		currentWindowWidth = self.innerWidth;
		currentWindowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		currentWindowWidth = document.documentElement.clientWidth;
		currentWindowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		currentWindowWidth = document.body.clientWidth;
		currentWindowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(myYscroll < windowHeight){
		currentPageHeight = windowHeight;
	} else { 
		currentPageHeight = myYscroll;
	}

	// for small pages with total width less then width of the viewport
	if(myXscroll < windowWidth){	
		currentPageWidth = windowWidth;
	} else {
		currentPageWidth = myXscroll;
	}

	arrayWindowSize = new Array(currentPageWidth,currentPageHeight,currentWindowWidth,currentWindowHeight) 
	return arrayWindowSize;
}

function buildAppWindow(urlExtras){
	var appwidth=878;
	var appheight=559;
	
	/* REMOVE ANY EXISTING DIVs FROM THE STAGE TO START A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});
	
	var objSurround = document.createElement('div');
		objSurround.setAttribute('id','surround');
		objSurround.style.display = 'inline';
	document.body.appendChild(objSurround);

	var objAppBG = document.createElement('div');
		objAppBG.setAttribute('id','appBG');
		objSurround.appendChild(objAppBG);

	var objApp = document.createElement('div');
		objApp.setAttribute('id','app');
		objApp.style.width = appwidth+'px';
		objApp.style.height = appheight+'px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);

	//grab the current window height
	var arrayPageSize = getTheWindowSize();
	
	//size the ghosted BG to the window height
	var curHeight = $(document).height();
	//alert(curHeight);
	$("#surround").height(curHeight);
	objSurround.style.display = 'block';
	
	//turn the app and sppBG div on and center in the window
	objApp.style.display = 'block';
	objApp.style.left = (((arrayPageSize[0]/2)-437) + 'px')
	objAppBG.style.left = (((arrayPageSize[0]/2)-437) + 'px')
	
	//GRAB THE GLOBAL VARIABLE SET BY /js/serverPath.js
	//WHICH SHOULD BE VISUSJAWEB ON STAGE AND QA AND 
	//HTTPS://JNJVISION.COM ON PROD. PROD SHOULD NEVER CHANGE
	var baseDomain = serverPath;
	
	///////////////////////////////////////
	///////////////////////////////////////
	//GRAB ANY PARAMS PASSED TO THE CURRENT PAGE
	var currentURL = location.href;
	//SPLIT THE PARAMS INTO AN ARRAY, THE 2ND PART (targetVars[1]) BEING THE ACTUAL PARAMS
	var targetVars = currentURL.split("?");
	//CHECK TO SEE IF PARAMS WERE PASSED VIA URL OR MANUALLY (VIA FUNCTION)
	//PARAMS FROM THE URL WILL ALWAYS TAKE PRECEDENCE OVER MANUALLY PASSED PARAMS
	if (targetVars[1] != null && targetVars[1].length>2 && targetVars[1].indexOf('flowId')>-1){
		//LOAD UP THE FREE TRIAL APP WITH THE PARAMS PASSED TO THE PAGE
		//alert("loading custom free trial app: "+targetVars[1]);
		var targetURL = baseDomain+"/ftpc/Acuvue.do?"+targetVars[1];
	} else if(urlExtras != null && urlExtras.length>2){
		/* VARS PASSED MANUALLY TO FUNCTION - LOAD SPECIFIC CONTENT */
		//alert("loading default CC free trial app: "+urlExtras);
		var targetURL = baseDomain+"/ftpc/Acuvue.do?"+urlExtras;
	} else {
		/* NO EXTRAS PASSED VIA URL OR MANUALLY, USE DEFAULT CONTENT */
		var targetURL = baseDomain+"/ftpc/Acuvue.do?flowId=1&rc=S25&skinId=S101&promoId=102";
		//var targetURL = "https://visusjawebdevel.na.jnj.com/ftpc/Acuvue.do?flowId=1&rc=S25&skinId=S101&promoId=102";
	}
	/* BUILD OUT THE INNER PARTS OF THE APP */
	objApp.innerHTML="<div id='closeEmUp'></div>";
	objApp.innerHTML+="<div id='closeDIV'></div>";
	objApp.innerHTML+="<div id='verifyDIV'><h3>Are you sure you want to quit?</h3><input type='button' value='NO' class='get-started' onClick='hideConfirm();' /><input type='button' value='YES' class='get-started' onClick='closeEmUpToo();' /></div>";
	objApp.innerHTML+="<iframe id='FTCapp' src='"+targetURL+"' frameborder='0' name='FTCapp' scrolling='no' scrolling='false' width='877' height='620' allowtransparency='true'></iframe>";
	/* EOF INNER PARTS OF THE APP */
	
	var objCLOSEdiv = document.getElementById('closeDIV');
		var objCLOSElink = document.createElement('a');
			objCLOSElink.setAttribute('id','closeApp');
			objCLOSElink.setAttribute('href', 'javascript:showConfirm();');
			objCLOSElink.innerHTML += '';
		objCLOSEdiv.appendChild(objCLOSElink);
	scroll(0,0);
}

function buildLensAdvisorApp(){
	var appwidth=878;
	var appheight=559;

	/* REMOVE ANY EXISTING DIVs FROM THE STAGE TO START A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});
	
	var objSurround = document.createElement('div');
		objSurround.setAttribute('id','surround');
		objSurround.style.display = 'inline';
	document.body.appendChild(objSurround);

	var objAppBG = document.createElement('div');
		objAppBG.setAttribute('id','appBG');
	objSurround.appendChild(objAppBG);

	var objApp = document.createElement('div');
		objApp.setAttribute('id','app');
		objApp.style.width = appwidth+'px';
		objApp.style.height = appheight+'px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);

	//grab the current window height
	var arrayPageSize = getTheWindowSize();
	
	//size the ghosted BG to the window height
	var curHeight = $(document).height();
	//alert(curHeight);
	$("#surround").height(curHeight);
	objSurround.style.display = 'block';
	
	//turn the app and sppBG div on and center in the window
	objApp.style.display = 'block';
	objApp.style.left = (((arrayPageSize[0]/2)-437) + 'px')
	objAppBG.style.left = (((arrayPageSize[0]/2)-437) + 'px')
	
	//var targetURL = "http://visusjawebdevel.na.jnj.com/ftpc/LensAction.do?parameter=start&flowId=1&rc=S25&skinId=S101&promoId=102";	
	var targetURL = "https://www.jnjvision.com/ftpc/LensAction.do?parameter=start&flowId=1&rc=S25&skinId=S101&promoId=102";	

	/* BUILD OUT THE INNER PARTS OF THE APP */
	objApp.innerHTML="<div id='closeEmUp'></div>";
	objApp.innerHTML+="<div id='closeDIV'></div>";
	objApp.innerHTML+="<div id='verifyDIV'><h3>Are you sure you want to quit?</h3><input type='button' value='NO' class='get-started' onClick='hideConfirm();' /><input type='button' value='YES' class='get-started' onClick='closeEmUpToo();' /></div>";
	objApp.innerHTML+="<iframe id='FTCapp' src='"+targetURL+"' frameborder='0' name='FTCapp' scrolling='no' scrolling='false' width='877' height='557' allowtransparency='true'></iframe>";
	/* EOF INNER PARTS OF THE APP */
	
	var objCLOSEdiv = document.getElementById('closeDIV');
	var objCLOSElink = document.createElement('a');
		objCLOSElink.setAttribute('id','closeApp');
		objCLOSElink.setAttribute('href', 'javascript:showConfirm();');
		objCLOSElink.innerHTML += '';
		objCLOSEdiv.appendChild(objCLOSElink);

	scroll(0,0);
}

function buildAcuminderApp(){
	var appwidth=878;
	var appheight=559;

	/* REMOVE ANY EXISTING DIVs FROM THE STAGE TO START A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});
	
	var objSurround = document.createElement('div');
		objSurround.setAttribute('id','surround');
		objSurround.style.display = 'inline';
	document.body.appendChild(objSurround);

	var objAppBG = document.createElement('div');
		objAppBG.setAttribute('id','appBG');
	objSurround.appendChild(objAppBG);

	var objApp = document.createElement('div');
		objApp.setAttribute('id','app');
		objApp.style.width = appwidth+'px';
		objApp.style.height = appheight+'px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);
	objApp.className = "acuminder";

	//grab the current window height
	var arrayPageSize = getTheWindowSize();
	
	//size the ghosted BG to the window height
	var curHeight = $(document).height();
	//alert(curHeight);
	$("#surround").height(curHeight);
	objSurround.style.display = 'block';
	
	//turn the app and sppBG div on and center in the window
	objApp.style.width = "800px";
	objApp.style.height = "600px";
	objApp.style.display = "block";
	objApp.style.backgroundColor = "#FFF";
	objApp.style.left = (((arrayPageSize[0]/2)-400) + 'px');
	
	/*var targetURL = "https://www.acuvue.com/acuminder/main.jsp";*/
	var targetURL = "https://www.jnjvision.com/acuminder/main.jsp";
	
	/* BUILD OUT THE INNER PARTS OF THE APP */
	objApp.innerHTML="<div id='closeEmUp'></div>";
	objApp.innerHTML+="<div id='closeDIV'></div>";
	objApp.innerHTML+="<iframe id='Acuminder' src='"+targetURL+"' frameborder='0' name='Acuminder' scrolling='true' style='width:800px;height:600px;margin:0;background:#FFF;'></iframe>";
	/* EOF INNER PARTS OF THE APP */
	
	var objCLOSEdiv = document.getElementById('closeDIV');
	var objCLOSEemUp = document.getElementById('closeEmUp');
	objCLOSEdiv.style.marginLeft = '730px';
	objCLOSEdiv.style.marginTop = '-20px';
	objCLOSEemUp.style.marginLeft = '730px';
	objCLOSEemUp.style.marginTop = '-20px';
		var objCLOSElink = document.createElement('a');
			objCLOSElink.setAttribute('id','closeApp');
			objCLOSElink.setAttribute('href', 'javascript:closeEmUpToo();');
			objCLOSElink.innerHTML += '';
		objCLOSEdiv.appendChild(objCLOSElink);

	scroll(0,0);
}

function buildRebatesApp(URLpath){
	var appwidth=878;
	var appheight=559;

	/* REMOVE ANY EXISTING DIVs FROM THE STAGE TO START A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});
	
	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 = appwidth+'px';
		objApp.style.height = appheight+'px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);

	//grab the current window height
	var arrayPageSize = getTheWindowSize();
	
	//size the ghosted BG to the window height
	var curHeight = $(document).height();
	//alert(curHeight);
	$("#surround").height(curHeight);
	objSurround.style.display = 'block';
	
	//turn the app and sppBG div on and center in the window
	objApp.style.width = "800px";
	objApp.style.height = "600px";
	objApp.style.display = "block";
	objApp.style.backgroundColor = "#FFF";
	objApp.style.left = (((arrayPageSize[0]/2)-400) + 'px')
		
	/* BUILD OUT THE INNER PARTS OF THE APP */
	objApp.innerHTML="<div id='closeEmUp'></div>";
	objApp.innerHTML+="<div id='closeDIV'></div>";
	objApp.innerHTML+="<iframe id='Rebates' src='"+URLpath+"' frameborder='0' name='Rebates' scrolling='true' style='width:800px;height:600px;margin:0;background:#FFF;'></iframe>";
	/* EOF INNER PARTS OF THE APP */
	
	var objCLOSEdiv = document.getElementById('closeDIV');
	var objCLOSEemUp = document.getElementById('closeEmUp');
	objCLOSEdiv.style.marginLeft = '730px';
	objCLOSEdiv.style.marginTop = '-20px';
	objCLOSEemUp.style.marginLeft = '730px';
	objCLOSEemUp.style.marginTop = '-20px';
		var objCLOSElink = document.createElement('a');
			objCLOSElink.setAttribute('id','closeApp');
			objCLOSElink.setAttribute('href', 'javascript:closeEmUpToo();');
			objCLOSElink.innerHTML += '';
		objCLOSEdiv.appendChild(objCLOSElink);

	scroll(0,0);
}

function closeEmUp(){
	//target the application on the page
	var objSurround = document.getElementById('surround');
	var objAppBG = document.getElementById('appBG');
	var objApp = document.getElementById('app');
	var objRedirect = document.getElementById('redirectWarning');
	objSurround.style.display="none";
	objApp.style.display="none";
	objApp.className='';
	objSurround.innerHTML='';
	objApp.innerHTML='';
	if(objApp != null){
		objApp.style.display="none";
	}
	if(objRedirect != null){
		objRedirect.style.display="none";
	}
	//alert(removeThis);
	//window.location="http://experience.acuvue.com";
}

function hideConfirm(){
	document.getElementById('verifyDIV').style.display="none";
}

function showConfirm(){
	var objApp = document.getElementById('app');
	var objConfirm = document.getElementById('verifyDIV');
	objConfirm.style.left = (objApp.offsetWidth/2)-150 + 'px';
	objConfirm.style.display="block";
}

function reposition(){
	//target the application on the page
	/* OLD CODE - REPLACED WITH CLEANER JQUERY STATENTS
	var objAppBG = document.getElementById('appBG');
	var objApp = document.getElementById('app');
	*/
	
	//grab the current window height
	var arrayPageSize = getTheWindowSize();
		
	//set the app to float in the middle of the current window
	$("#app").css("left", ((arrayPageSize[0]/2)-437) + 'px');
	$("#appBG").css("left", ((arrayPageSize[0]/2)-437) + 'px');
	
}

function externalLink(redirect,privacypolicy){

	/* STRIP ALL EXISITNG SURROUND, APP, APPBG */
	/* and SUPPORTING OBJECTS FROM THE DOM */
	/* TO GET A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});

	//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 = '878px';
		objApp.style.height = '200px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);

	if(privacypolicy==null || privacypolicy.length<1){
		var privacypolicy =	"privacy_policy.htm";
	}
	
	var objWarn = document.createElement('div');
		objWarn.setAttribute('id','redirectWarning');
		objWarn.innerHTML = "<h4>You are leaving Acuvue.com and are being automatically redirected to: </h4><h3>"+redirect+"</h3>";
		objWarn.innerHTML += "<p>This link will take you to a Web site to where our <a href='/"+privacypolicy+"'>Privacy Policy</a> does not apply. You are solely responsible for your interactions with that Web site. We encourage you to read the privacy policy of every Web site you visit.</p>";
		objWarn.innerHTML += "<p>If your browser does not take you there in a few moments, please click [<a href='"+redirect+"' target='_blank'>HERE</a>] or you may [<a href='javascript:clearTimeout(t);closeEmUpToo();void(0);'>RETURN</a>] to the Acuvue&reg; site.</p>";
	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)-437) + 'px')

	//set up a timer to call the new page
	t = setTimeout('window.open("'+redirect+'");closeEmUpToo();', 8000);
	
	scroll(0,0);
}

function buyingFreeTrial(){
	//alert('popping free trial up!');
	var objApp = document.getElementById('app');
	var buyingFreeTrial = document.createElement('div');
		buyingFreeTrial.setAttribute('id','buyingFreeTrial');
		buyingFreeTrial.setAttribute('href','javascript:alert(\"clicked!\");');
		var objLink = document.createElement('a');
			objLink.setAttribute('id','link');
			objLink.setAttribute('href','javascript:alert(\"you clicked me!\");');
		buyingFreeTrial.appendChild(objLink);
	objApp.appendChild(buyingFreeTrial);
	
	//turn the mini app div on and center in the window
	objApp.style.width='517px';
	objApp.style.display = 'block';

	//grab the current window height
	var arrayPageSize = getTheWindowSize();
	objApp.style.left = (((arrayPageSize[0]/2)-175) + 'px')
}

/* /////////////////////////////////////////////////////// */
/* BELOW ARE REVISED FUNCTIONS ALLOWING DYNAMIC APP BUILDS */
/* /////////////////////////////////////////////////////// */

function newAppWindow(targetURL,appwidth,appheight,tracked){
	
	/* STRIP ALL EXISITNG SURROUND, APP, APPBG */
	/* and SUPPORTING OBJECTS FROM THE DOM */
	/* TO GET A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});

	/* BUILD OUT NEW OBJECTS */
	var objSurround = document.createElement('div');
		objSurround.setAttribute('id','surround');
		objSurround.style.display = 'inline';
	document.body.appendChild(objSurround);
	
	var objAppBG = document.createElement('div');
		objAppBG.setAttribute('id','appBG');
		objAppBG.style.width = appwidth+'px';
		objAppBG.style.height = appheight+'px';
		objAppBG.style.display = 'block';
	document.body.appendChild(objAppBG);

	var objApp = document.createElement('div');
		objApp.setAttribute('id','app');
		objApp.style.width = appwidth+'px';
		objApp.style.height = appheight+'px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);

	var objClose = document.createElement('a');
		objClose.setAttribute('id','closeDIV');
		objClose.setAttribute('href', 'javascript:closeEmUpToo();');
	document.body.appendChild(objClose);
	
	//grab the current window height
	var arrayPageSize = getTheWindowSize();
	
	var curWidth = document.body.offsetWidth;
	var curHeight = document.documentElement.clientHeight-2;
	//size the ghosted BG to the window height
	//alert('width is '+curWidth+'px');
	//objSurround.style.width = curWidth+'px';
	//alert('height is '+curHeight+'px');
	objSurround.style.height = curHeight + 'px';
	
	//turn the app and sppBG div on and center in the window
	objAppBG.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	objApp.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	objClose.style.left = (((arrayPageSize[0]/2)+((appwidth/2)-70)) + 'px');
	
	if(tracked == true){
		var currentURL = location.href;
		var targetVars = currentURL.split("?");
		/*alert(targetVars[1]);*/
		var targetURL = targetURL+"?"+targetVars[1];
		/*var targetURL = "https://www.jnjvision.com/ftpc/Acuvue.do?"+targetVars[1];
		/* alert(targetURL); */	
	}
	/* BUILD OUT THE INNER PARTS OF THE APP */
	objApp.innerHTML="<iframe id='survey' src='"+targetURL+"' frameborder='0' name='microsite' scrolling='no' scrolling='false' width='"+appwidth+"' height='"+appheight+"' allowtransparency='true'></iframe>";		
		
	scroll(0,0);
}

function repositionApp(appwidth){
	
	//target the application on the page
	var objSurround = document.getElementById('surround');
	var objAppBG = document.getElementById('appBG');
	var objApp = document.getElementById('app');
	var objAppContent = document.getElementById('appExtraContent');
	var objAppContentBG = document.getElementById('appExtraContentBG');
	var objClose = document.getElementById('closeDIV');
	
	//grab the current window height
	//grab the current window height
	var arrayPageSize = getTheWindowSize();

	var pageWidth = document.documentElement.clientWidth;
	var pageHeight = document.documentElement.clientHeight;
	//objSurround.style.width = pageWidth+'px';
	objSurround.style.height = pageHeight + 'px';
		
	//set the app to float in the middle of the current window
	if(objAppBG) objAppBG.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	if(objApp) objApp.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	if(objAppContent) objAppContent.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	if(objAppContentBG) objAppContentBG.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	if(objClose) objClose.style.left = (((arrayPageSize[0]/2)+((appwidth/2)-70)) + 'px');
}

function closeEmUpToo(redirect){
	/*
	//target the application on the page
	var objSurround = document.getElementById('surround');
		if(objSurround!=null){objSurround.style.display="none";document.body.removeChild(objSurround)};
	var objApp = document.getElementById('app');
		if(objApp!=null){objApp.style.display="none";document.body.removeChild(objApp)};
	/*
	var objAppBG = document.getElementById('appBG');
		if(objAppBG!=null){objAppBG.parentNode.removeChild(objAppBG)};
		
	var objAppContentBG = document.getElementById('appExtraContentBG');
		if(objAppContentBG!=null){objAppContentBG.style.display="none";document.body.removeChild(objAppContentBG)};
	var objAppContent = document.getElementById('appExtraContent');
		if(objAppContent!=null){objAppContent.style.display="none";document.body.removeChild(objAppContent)};
	var objClose = document.getElementById('closeEm');
		if(objClose!=null){objClose.style.display="none";objClose.parentNode.removeChild(objClose)};
	
	*/
	/* NEW JQUERY DRIVEN CODE BELOW ADDED BY T. MARONEY OF VISTAKON IT */
	$(document).ready(function(){
		/* BELOW CHANGED TO ACCOMODATE OLD METHODS OF FLYOUT FUNCTION.
		/* DON'T PHYSICALLY REMOVE THE OBJECTS FROM DOM, BUT RATHER SET THEM
		/* TO DISPLAY: NONE SO THAT THEY REMAIN IN THE PAGE SO THAT LEGACY
		/* METHODS OF THE FLYOUT FUNCTION CAN STILL HOOK INTO THEM
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		*/
		$("#surround").css("display","none");
		$("#app").css("display","none");
		$("#appBG").css("display","none"); 
		
		/* GO HEAD AND REMOVE THE REST< AS THEY WILL BE REBUILT */
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});
	
	if (redirect != null && redirect==true){
		//ELSE, put them back home
		window.location="http://www.acuvue.com";
	}
}

/////////////// FUNCTION SPECIFIC TO THE SURVEY LANDING PAGE, WHEREIN //////////////////////////
/////////////// WE HAD TO BUILD THE YES/NO SCREEN INTO THIS DUE TO /////////////////////////////
/////////////// THE JAVASCRIPT SANDBOX, DISALLOWING CROSS DOMAIN CALLS /////////////////////////

function newSurveyApp(targetURL,appwidth,appheight,tracked){

	/* STRIP ALL EXISITNG SURROUND, APP, APPBG */
	/* and SUPPORTING OBJECTS FROM THE DOM */
	/* TO GET A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});

	/* NOW BUILD OUT THE OJECTS AGAIN */
	var objSurround = document.createElement('div');
		objSurround.setAttribute('id','surround');
		objSurround.style.display = 'inline';
	document.body.appendChild(objSurround);
	
	var objAppBG = document.createElement('div');
		objAppBG.setAttribute('id','appBG');
		objAppBG.style.width = appwidth+'px';
		objAppBG.style.height = appheight+'px';
		objAppBG.style.display = 'block';
	document.body.appendChild(objAppBG);

	var objApp = document.createElement('div');
		objApp.setAttribute('id','app');
		objApp.style.width = appwidth+'px';
		objApp.style.height = appheight+'px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);

	/*
	var objAppContentBG = document.createElement('div');
		objAppContentBG.setAttribute('id','appExtraContentBG');
		objAppContentBG.style.width = appwidth+'px';
		objAppContentBG.style.height = appheight+'px';
	document.body.appendChild(objAppContentBG);
	

	var objAppContent = document.createElement('div');
		objAppContent.setAttribute('id','appExtraContent');
		objAppContent.style.display = 'block';
	document.body.appendChild(objAppContent);
		objAppContent.innerHTML = "<h1></h1><h3>Thank you for recently downloading your FREE* Trial Pair Certificate from Acuvue.com.</h3><p>Based on your responses, you may qualify to participate in a research study.</p><p><b>If you qualify, may we contact you to give you more information on the study and see if you would be interested in participating?</b></p><div class='yesno'><p><b><input type='radio' name='participate' id='yesRadio' onclick='closeIt(\"appExtraContentBG\");closeIt(\"appExtraContent\");' /> YES</b></p></div><div class='yesno'><p><b><input type='radio' name='participate' id='noRadio' onclick='closeEmUpToo();' /> NO</b></p></div>";
	
	*/
	
	var objClose = document.createElement('a');
		objClose.setAttribute('id','closeDIV');
		objClose.setAttribute('href', 'javascript:closeEmUpToo();');
	document.body.appendChild(objClose);
	
	//grab the current window height
	var arrayPageSize = getTheWindowSize();
	
	var curWidth = document.body.offsetWidth;
	var curHeight = document.documentElement.clientHeight-2;
	//size the ghosted BG to the window height
	//alert('width is '+curWidth+'px');
	//objSurround.style.width = curWidth+'px';
	//alert('height is '+curHeight+'px');
	objSurround.style.height = curHeight + 'px';
	
	//turn the app and sppBG div on and center in the window
	objAppBG.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	objApp.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	//objAppContentBG.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	//objAppContent.style.left = (((arrayPageSize[0]/2)-(appwidth/2)) + 'px');
	objClose.style.left = (((arrayPageSize[0]/2)+((appwidth/2)-70)) + 'px');
	
	if(tracked == true){
		var currentURL = location.href;
		var targetVars = currentURL.split("?");
		/*alert(targetVars[1]);*/
		var targetURL = targetURL+"?"+targetVars[1];
		/*var targetURL = "https://www.jnjvision.com/ftpc/Acuvue.do?"+targetVars[1];
		/* alert(targetURL); */	
	}
	/* BUILD OUT THE INNER PARTS OF THE APP */
	objApp.innerHTML="<iframe id='survey' src='"+targetURL+"' frameborder='0' name='microsite' scrolling='no' scrolling='false' width='"+appwidth+"' height='"+appheight+"' allowtransparency='true'></iframe>";
	
	scroll(0,0);
}

function closeIt(target){
	//alert("closing "+target);
	objAppIframe = document.getElementById("survey");
	objTarget = document.getElementById(target);
	if(objTarget) document.body.removeChild(objTarget);
	if(objAppIframe) objAppIframe.style.display="block";
}

function doSomething(){
	alert("clicked!");
}

// ####################################################### //
//BELOW IS THE FUNCTION THAT BUILDS OUT THE RATINGS AND REVIEWS FLYOUT
function buildReviews(urlPath){
	//alert("building reviews flyout!");
	
	/* STRIP ALL EXISITNG SURROUND, APP, APPBG */
	/* and SUPPORTING OBJECTS FROM THE DOM */
	/* TO GET A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});

	//BUILD THE APPLICATION OBJECTS OUT ONTO THE SCREEN
	var objSurround = document.createElement('div');
		objSurround.setAttribute('id','surround');
	document.body.appendChild(objSurround);
	
	var objAppBG = document.createElement('div');
		objAppBG.setAttribute('id','appBG');
		objAppBG.style.width = '878px';
		objAppBG.style.height = '559px';
	objSurround.appendChild(objAppBG);

	var objApp = document.createElement('div');
		objApp.setAttribute('id','app');
		objApp.style.width = '878px';
		objApp.style.height = '559px';
		objApp.style.top = '0';
	document.body.appendChild(objApp);
	
	//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 app and sppBG div on and center in the window
	objApp.style.display = 'block';
	objApp.style.left = (((arrayPageSize[0]/2)-437) + 'px')
	objAppBG.style.left = (((arrayPageSize[0]/2)-437) + 'px')
		
	/* BUILD OUT THE INNER PARTS OF THE APP */
	objApp.innerHTML="<div id='closeEmUp'></div>";
	objApp.innerHTML+="<div id='closeDIV'></div>";
	objApp.innerHTML+="<div id='verifyDIV'><h3>Are you sure you want to quit?</h3><input type='button' value='NO' class='get-started' onClick='hideConfirm();' /><input type='button' value='YES' class='get-started' onClick='closeEmUpToo(false);' /></div>";
	objApp.innerHTML+="<iframe id='ReviewsApp' src='"+urlPath+"' frameborder='0' name='ReviewsApp' scrolling='auto' scrolling='false' width='878' height='559' allowtransparency='true'></iframe>";
	var objConfirm = document.getElementById('verifyDIV');
	objConfirm.marginLeft = '250px';
	/* EOF INNER PARTS OF THE APP */
	
	var objCLOSEdiv = document.getElementById('closeDIV');
	var objCLOSElink = document.createElement('a');
		objCLOSElink.setAttribute('id','closeApp');
		objCLOSElink.setAttribute('href', 'javascript:showReviewsConfirm();');
		objCLOSElink.innerHTML += '';
	objCLOSEdiv.appendChild(objCLOSElink);

	scroll(0,0);
	return false;
}

function showReviewsConfirm(){
	var objConfirm = document.getElementById('verifyDIV');
	objConfirm.style.left = '300px';
	objConfirm.style.display="block";
}

function BVRROnSubmit(link) { buildReviews(link);return false; }
function BVQAOnSubmit(link,var2) { buildReviews(link);return false; }

/* ######################################################## */
/* ### SPECIFICS TO MYACUVUE LOGIN FLYOUT FUNCTIONALITY ### */

function buildMyAcuvue(){
	
	var appwidth=878;
	var appheight=559;

	/* REMOVE ANY EXISTING DIVs FROM THE STAGE TO START A CLEAN SLATE */
	$(document).ready(function(){
		$("#surround").remove();
		$("#app").remove();
		$("#appBG").remove();
		$("#appExtraContentBG").remove();
		$("#appExtraContent").remove();
		$("#closeEm").remove();
		$("#closeEmToo").remove();
	});
	
	/* BELOW IS GRABBED FROM /js/serverpath.js GLOBAL VARIABLE */
	var baseDomain = serverPath;
	
	var objSurround = document.createElement('div');
		objSurround.setAttribute('id','surround');
		objSurround.style.display = 'inline';
	document.body.appendChild(objSurround);
	
	var objAppBG = document.createElement('div');
		objAppBG.setAttribute('id','appBG');
		objAppBG.style.width = appwidth+'px';
		objAppBG.style.height = appheight+'px';
		objAppBG.style.display = 'block';
	document.body.appendChild(objAppBG);

	var objApp = document.createElement('div');
		objApp.setAttribute('id','app');
		objApp.style.width = appwidth+'px';
		objApp.style.height = appheight+'px';
		objApp.style.display = 'block';
	document.body.appendChild(objApp);

	var objClose = document.createElement('div');
		objClose.setAttribute('id','closeEm');
		objClose.style.backgroundImage='none';
		objClose.innerHTML = "<a href='javascript:closeEmUpToo(false);' style='position:relative;'></a>";
	document.body.appendChild(objClose);
	
	var curHeight = $(document).height();
	//alert(curHeight);
	$("#surround").height(curHeight);
	
	//turn the app and sppBG div on and center in the window
	objAppBG.style.left = ((($(document).width()/2)-(appwidth/2)) + 'px');
	objApp.style.left = ((($(document).width()/2)-(appwidth/2)) + 'px');
	objClose.style.left = ((($(document).width()/2)+410) + 'px');

	///////////////////////////////////////
	///////////////////////////////////////
	//GRAB ANY PARAMS PASSED TO THE CURRENT PAGE
	var currentURL = location.href;
	//SPLIT THE PARAMS INTO AN ARRAY, THE 2ND PART (targetVars[1]) BEING THE ACTUAL PARAMS
	var targetVars = currentURL.split("?");
	//CHECK TO SEE IF PARAMS WERE PASSED VIA URL OR MANUALLY (VIA FUNCTION)
	//PARAMS FROM THE URL WILL ALWAYS TAKE PRECEDENCE OVER MANUALLY PASSED PARAMS
	if (targetVars[1] != null && targetVars[1].length>1 && targetVars[1].indexOf('rc')>-1){
		//LOAD UP MYACUVUE WITH THE PARAMS PASSED TO THE PAGE
		//alert("loading custom free trial app: "+targetVars[1]);
		var targetURL = baseDomain+"myacuvue/loginPage.do?"+targetVars[1];
	} else {
		/* NO EXTRAS PASSED VIA URL, USE DEFAULT CONTENT */
		var targetURL = baseDomain+"myacuvue/loginPage.do";
	}
	
	/* BUILD OUT THE INNER PARTS OF THE APP */
	objApp.innerHTML="<iframe id='my-acuvue-app' src='"+targetURL+"' frameborder='0' name='my-acuvue-app' scrolling='no' scrolling='false' width='878' height='559' allowtransparency='true'></iframe>";
	
	scroll(0,0);

}
