function moveSlideSurvey(){
	if (parseInt(document.getElementById('divSlideSurvey').style.left) < 262){
		var curLeft = parseInt(document.getElementById('divSlideSurvey').style.left);
		var newLeft = curLeft + 4;
		document.getElementById('divSlideSurvey').style.left = newLeft + "px";
	} else {
		setTimeout('hideSlideSurvey()',20000);
	}
}

function hideSlideSurvey(){
	document.getElementById('divSlideSurvey').style.visibility = "hidden";
}

function globalSurvey(){
	//alert('globalSurvey()');
	var showSurvey = false;
	var processPage = false;
	if(isCookieEnabled())
	{		
		
		var currentDate = new Date();
		var currentPeriod = currentDate.getMonth();
		var surveyTaken = parseInt(Get_Cookie('surveyTaken'));
		var promptCount = parseInt(Get_Cookie('promptCount'));
		var promptPeriod = parseInt(Get_Cookie('promptPeriod'));
		if(isNaN(promptCount))
		{
			promptCount = 0;
			promptPeriod = currentPeriod;
			Set_Cookie( 'promptCount', promptCount, '365', '/', '', '' );
			Set_Cookie( 'promptPeriod', promptPeriod, '365', '/', '', '' );
		}
		if(isNaN(promptPeriod))
		{
			promptCount = 0;
			promptPeriod = currentPeriod;
			Set_Cookie( 'promptCount', promptCount, '365', '/', '', '' );
			Set_Cookie( 'promptPeriod', promptPeriod, '365', '/', '', '' );			
		}
		var pageCount=parseInt(Get_Cookie('pageCount'));
		if(isNaN(pageCount))
		{
			pageCount = 0;
			Set_Cookie( 'pageCount', pageCount, '', '/', '', '' );			
		}
		pageCount = pageCount + 1;
		Set_Cookie( 'pageCount', pageCount, '', '/', '', '' );
		//alert('pageCount' + pageCount);
		
		if(isNaN(surveyTaken))
		{
			//alert('survey is not taken');
			if (promptCount < 2)
			{
				//alert('promptCount < 2');
				processPage = true;
			}
			else
			{
				//alert('promptCount >= 2');
				if (promptPeriod != currentPeriod)
				{
					//alert('promptPeriod != currentPeriod');
					processPage = true;					
				}
				else
				{
					//alert('promptPeriod == currentPeriod');
					processPage = false;
				}
			}
		}
		else
		{
			//alert('survey taken');
			if (surveyTaken != currentPeriod)
			{
				//alert('promptPeriod != currentPeriod');
				processPage = true;
			}
			else
			{
				//alert('promptPeriod == currentPeriod');
				processPage = false;
				Delete_Cookie('pageCount', '/', '');
			}			
		}
		
		if(processPage)
		{
			//alert('processPage=true');			
			var randomNumber = Math.random();
			//alert('randomNumber' + randomNumber);
			//alert('pageCount' + pageCount);
			if(pageCount == 1 )
			{
				//alert('pageCount == 1');	
				if (randomNumber < 0.25)
				{
					showSurvey = true;
				}
			}
			else if (pageCount == 2 )
			{
				//alert('pageCount == 2');
				if (randomNumber < 0.50)
				{
					showSurvey = true;
				}			
			}
			else if (pageCount == 3 )
			{
				//alert('pageCount == 3');
				if (randomNumber < 0.75)
				{
					showSurvey = true;
				}
			}
			else
			{
				showSurvey = true;			
			}		
		
		}
		else
		{
			//alert('processPage=false');
			showSurvey = false;
		}	
		
	}
	//alert('showSurvey' + showSurvey);
	if (showSurvey)
	{
        document.getElementById('divSlideSurvey').style.left = "-253px";
        document.getElementById('divSlideSurvey').style.visibility = "visible";        
		moveSlideSurvey();
		setInterval('moveSlideSurvey()',1);
	}
	else
	{
		hideSlideSurvey();
	}
}

function notoSurvey(){
	//alert('notoSurvey()');
	var currentDate = new Date();
	var currentPeriod = currentDate.getMonth();
	var promptCount=parseInt(Get_Cookie('promptCount'));
	if(isNaN(promptCount))
	{
		promptCount = 1;
	}
	else
	{
		promptCount= promptCount + 1;
	}
	promptPeriod = currentPeriod;
	Set_Cookie( 'promptCount', promptCount, '365', '/', '', '' );
	Set_Cookie( 'promptPeriod', promptPeriod, '365', '/', '', '' );
}

function yestoSurvey(){
	//alert('yestoSurvey()');
	var currentDate = new Date();
	var currentPeriod = currentDate.getMonth();
	var surveyTaken = currentPeriod;
	Set_Cookie( 'surveyTaken', surveyTaken, '365', '/', '', '' );
	Delete_Cookie('promptCount', '/', '');
	Delete_Cookie('promptPeriod', '/', '');
	Delete_Cookie('pageCount', '/', '');
}

function isCookieEnabled(){	
	var cookieEnabled=false;	
	Set_Cookie( 'tylenolcookietest', 'it works', '', '/', '', '' );	
	if ( Get_Cookie( 'tylenolcookietest' ) )
	{
		cookieEnabled = true;
	}
	Delete_Cookie('tylenolcookietest', '/', '');
	return cookieEnabled;
}

function addSurveyLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}