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;
}

 var landingPageUrl;

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);
	
	//Added for GACC-1101 to get ghosted background. 'surround' div height set by the line above is not honored by 
	//FF in one scenario (pop-up on page load).so setting height again using the code below.
	
	objSurround.style.height=curHeight+'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')
	
	//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("?");
	
	var ssoTargetVars = currentURL.split("#");
	//Initialize the global variable
	landingPageUrl= ssoTargetVars[0]+"#nopopup";
	//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 currentURL = window.location.href;
	var ssoTargetVars = currentURL.split("#");
	//Initialize the global variable
	landingPageUrl= ssoTargetVars[0]+"#nopopup";
	
	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://vusjadwdevel.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";
	
	// Keep this commented code.Will be made visible shortly.
       //Added for GACC CR# 375 (Single sign on) by Suresh
	//var data = readCookie('MYACU_ID');
	//if( data!= null) {
	//    objConfirm.innerHTML="<h3>You are still logged into MyAcuvue.<br><br>Please close the browser if you<br>are on a public computer.</h3><input type='button' value='CANCEL' class='get-started' onClick='hideConfirm();' /><input type='button' value='CLOSE POP-UP' class='get-started' onClick='closeEmUpToo();redirect(landingPageUrl);' /><input type='button' value='SIGN OUT' class='get-started' onClick='closeEmUpToo();signOut();redirectForSignOut(landingPageUrl);' />";
	//}else{
	  objConfirm.innerHTML="<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();' />";
	//}
}

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,nv,privacypolicy, e){
	
	//Regular expression used to check for url addresses that don't need a disclaimer
  var disclaimerRe = new RegExp(/^((http|https)(:\/\/))?(www\.)?(((order|m)\.)?acuvue|jnjvisioncare|everybodygetsit)\.com(?!\.)/i); 
  if(disclaimerRe.test(redirect)) {
    window.open(redirect);
    return;
  }

	/* 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();
		/* Webtrends Tracking -2010 - This sets a parameter value of 24 for all external link clicks*/
		_tag.WT.dl = 24;
		/* Webtrends Tracking -2010 - This sets the current tags to 'Null' value, so that there is no duplicate entry in 
		   Webtrends report for each 'External Link' click 
		*/
		_tag.WT.cg_n='';
		_tag.WT.cg_s='';
		_tag.WT.z_rebate='';
        _tag.WT.pi='';
		_tag.WT.z_at ='';
		_tag.WT.z_ad ='';
		_tag.WT.z_media ='';
		_tag.WT.z_mediaStart ='';
		_tag.WT.z_mediaEnd ='';
		_tag.WT.z_amAction ='';
		_tag.WT.si_n ='';
		_tag.WT.si_x ='';
		_tag.WT.si_cs ='';
		_tag.WT.oss ='';
		_tag.WT.oss_r ='';
		_tag.WT.oss_r ='';
		_tag.WT.z_afWant='';
		_tag.WT.z_afItems='';
		_tag.WT.z_afHave='';
		_tag.WT.z_afResult='';
		_tag.WT.z_zip='';
		_tag.WT.z_range='';
		//alert("_tag.WT.nv"+nv);
		//_tag.dcsMultiTrack();
		if(nv !='')
		{
			_tag.WT.nv=nv;
		}
		else{
			_tag.WT.nv='';
			_tag.WT.ti='Offsite: '+redirect;
			_tag.dcsMultiTrack("DCS.dcsuri",redirect);
		}
		
	});

	//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.substr(0,45)+" ...</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='javascript:window.open(\""+redirect+"\");javascript:clearTimeout(t);closeEmUpToo();')>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
	var redirURL = 'window.open("'+redirect+'");closeEmUpToo();';
	t = setTimeout(html_entity_decode(redirURL), 8000);
	
	scroll(0,0);
	if(e){
	return false;
   }

}

//Converts HTML entities in a string to the respective character
function html_entity_decode(str) {
	var ta=document.createElement("textarea");
	ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
	return ta.value;
}

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 FOR 1DAY Astig(1MA)
function build1DayAstigReviews(urlPath){

	
//	var ssoTargetVars = currentURL.split("#");
	//Initialize the global variable
	//= currentURL;
	
	//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 = '30px';
	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(true);' /></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 */
	landingPageUrl = "http://www.acuvue.com";
	var objCLOSEdiv = document.getElementById('closeDIV');
	var objCLOSElink = document.createElement('a');
		objCLOSElink.setAttribute('id','closeApp');
		objCLOSElink.setAttribute('href', 'javascript:show1DayAstigReviewsConfirm();');
		objCLOSElink.innerHTML += '';
	objCLOSEdiv.appendChild(objCLOSElink);

	scroll(0,0);
	return false;
}
function show1DayAstigReviewsConfirm(){
	var objConfirm = document.getElementById('verifyDIV');
	objConfirm.style.left = '200px';
	objConfirm.style.display="block";
	   //Added for GACC-CR # 375(Single sign on implementation) by Suresh
		var data = readCookie('MYACU_ID');
		if( data!= null) {
		    objConfirm.innerHTML="<h3>You are still logged into MyAcuvue.<br><br>Please close the browser if you<br>are on a public computer.</h3><input type='button' value='CANCEL' class='get-started' onClick='hideConfirm();' /><input type='button' value='CLOSE POP-UP' class='get-started' onClick='closeEmUpToo(true);' /><input type='button' value='SIGN OUT' class='get-started' onClick='signOut();closeEmUpToo();' />";
		}else{
		  objConfirm.innerHTML="<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(true);' />";
	}
	
}
// ####################################################### //
//BELOW IS THE FUNCTION THAT BUILDS OUT THE RATINGS AND REVIEWS FLYOUT
function buildReviews(urlPath){

	var currentURL = window.location.href;
	var ssoTargetVars = currentURL.split("#");
	//Initialize the global variable
	landingPageUrl= ssoTargetVars[0]+"#nopopup";
	
	//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 = '30px';
	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 = '200px';
	objConfirm.style.display="block";
	   //Added for GACC-CR # 375(Single sign on implementation) by Suresh
		var data = readCookie('MYACU_ID');
		if( data!= null) {
		    objConfirm.innerHTML="<h3>You are still logged into MyAcuvue.<br><br>Please close the browser if you<br>are on a public computer.</h3><input type='button' value='CANCEL' class='get-started' onClick='hideConfirm();' /><input type='button' value='CLOSE POP-UP' class='get-started' onClick='closeEmUpToo();redirect(landingPageUrl);' /><input type='button' value='SIGN OUT' class='get-started' onClick='closeEmUpToo();signOut();redirectForSignOut(landingPageUrl);' />";
		}else{
		  objConfirm.innerHTML="<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();' />";
	}
	
}

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;width:53px !important;margin-left:-33px !important;'></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 IN THE URL WERE FOR EXECUTING A FORGOT PASSWORD FLYOUT
		$.extend({
		  getUrlVars: function(){
			var vars = [], hash;
			var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
			for(var i = 0; i < hashes.length; i++)
			{
			  hash = hashes[i].split('=');
			  vars.push(hash[0]);
			  vars[hash[0]] = hash[1];
			}
			return vars;
		  },
		  getUrlVar: function(name){
			return $.getUrlVars()[name];
		  }
		});
		
		var IDbyName = $.getUrlVar('c');

	if (IDbyName != null && IDbyName.length > 0) {
		
		var targetURL = "/myacuvue/forgotPassword.do?c="+IDbyName;
	}
	else 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);

}

function signOut(){
var data = readCookie('MYACU_ID');
if( data!= null) {
     data = 'cookieId='+ encodeURIComponent(data);
 	$.post("/myacuvue/cleanup",data, function(response){
		if( response == "success"){
			//alert("success");
		}else if( response == "failure"){
			//alert( "failure");
		}
		else if( response == "error"){
			//alert("error");
		}
	});

      eraseCookie('MYACU_ID');
   }else{
   	//alert('Cookie not found'); 
   }
  
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function  redirect(path){
  if(path!= null){
	window.location= path;
	window.location.reload();
    }
}

//If the landing (Current) page is MyAcuvue page, then redirect to site home page after user signs out from pop-up.

function  redirectForSignOut(path){
  if(path!= null){
  	var v1= path.indexOf("/myacuvue/");
  	var v2= path.indexOf("/acuvueRebate/");
       
       if( v1 == -1 && v2 == -1){
          window.location= path;
          window.location.reload();
       }else{
          var temp;
       	  if(v1 != -1){
              temp = path.split("/myacuvue/");
           }
          if(v2!= -1){
              temp = path.split("/acuvueRebate/");
            }
          if(temp == null){
              window.location= "http://www.acuvue.com";
            }else{
              window.location = temp[0];
            }
       }
    }

}


/**
 * Duplicated & modified newAppWindow since that one has issues with close btn - N.Y 09/09/2010
 *
 */
function GenericAppWindow(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('div');
		objClose.setAttribute('id','closeEm');
		objClose.style.backgroundImage='none';
		objClose.innerHTML = "<a href='javascript:closeEmUpToo(false);' style='position: relative; width: 65px;'></a>";
	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';
	
	//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
	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 that shows the welcome survey and control the exit survey popup.
	  *welcome survey:overlay window with options to participate or not the exit survey
		will show for 10% of the users.
		
		*exit survey:popup that shows if user clicks on "Take Survey" link in the welcome survey	
	
	- Check if the overlay(#surround) is not visible to show the welcome survey, preventing
	  conflicts with other apps.
	- The welcome survey will show for users that did not have completed the exit survey.
	- If user recuse to answer the exit survey, set a session cookie to prevent the welcome 
	  survey from showng again.
	- the welcome survey will only show for 10% of the users.
*/
function showWelcomeSurvey() {
	if($("div#surround").length > 0 && !$('div#surround').is(':visible')){
		if($.cookie('vis_survey') == 'completed' || $.cookie('vis_survey_session') != null) {
			return false;
		}else{
		  //Set the session control cookie
		  $.cookie('vis_survey_session', '1');
		
			var randomUser = Math.floor(Math.random()*10)+1;			
			
			if(randomUser == 1){			
				$("div#surround").remove();
				$('body').append('<div id="survey-surround" style="position:absolute;z-index:700;width:100%;top:0;left:0;height:'+ $('body').height() +'px"></div>')
				$('div#survey-surround').append('<div id="surround" style="position:static;padding-top:200px;height:' + ($('body').height() - 200) + 'px"></div>')
				$('div#surround').append('<div id="welcome-survey"></div>');
				$('div#welcome-survey').append("Welcome! Thank you for visiting Acuvue.com. We'd like to hear your feedback on how we can make the site more useful and convenient for you. The survey takes 1-3 minutes to complete and will begin as you exit the site.");
				$('div#welcome-survey').append('<br /><br /><a href="http://www.acuvue.com/privacy_policy.htm" target="_blank">We take your privacy and security seriously. Please view our Privacy Policy.</a>');
				$('div#welcome-survey').append('<br /><br /><a href="#" id="accept-survey">Take Survey</a>');
				$('div#welcome-survey').append('<br /><a href="#" id="recuse-survey">No Thank You</a>');				
				$('div#surround').show();
				
				$('a#accept-survey').bind('click', function(ev){
					ev.preventDefault();
					$("div#survey-surround").remove();
					$('body').append('<div id="surround"></div>');
					
					//Seting the main window name, needed by the popup to check main window changes/close
					window.name = 'acuvueMain';
					
					//Seting persistent cookie
					$.cookie('vis_survey', 'completed', {expires:2000});					
					var windowHandle  = window.open('survey-popup.htm','survey','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=990,height=559');
					window.focus();
				});

				$('a#recuse-survey').bind('click', function(ev){
					ev.preventDefault();
					$("div#survey-surround").remove();
					$('body').append('<div id="surround"></div>');
				});
			}
		}
	}
}
