function getCookie(welcomeVideo_Cookie)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(welcomeVideo_Cookie + "=");
  if (c_start!=-1)
    {
    c_start=c_start + welcomeVideo_Cookie.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setCookie(welcomeVideo_Cookie,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=welcomeVideo_Cookie+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkTHECookie()
{
returningUSER09=getCookie('returningUSER09');
if (returningUSER09!=null && returningUSER09!="")
  {  //returning user; display welcome back
  //alert('Welcome again '+returningUSER09+'!');
  return true;
  }
else
  { // new user or cleared cookie user display first msg
  returningUSER09 = new Date(); //set cookie NOW
  if (returningUSER09!=null && returningUSER09!="")
    {
    setCookie('returningUSER09',returningUSER09,365);
    return false;
    }
  }
}


function shouldFirstVisitVideoDisplay()
{
	if (getCookie('hasFirstVideoEverDisplayed') != 'yes')
		if (getCookie('lastVisitWasToday') != "true")
			{
				setCookie('hasFirstVideoEverDisplayed','yes',365);
				setCookie('firstVideoPlayedToday',"true",1);
				return true;
			}
	return false;
}

function shouldReturnVisitVideoDisplay()
{
	if (getCookie('hasFirstVideoEverDisplayed') == 'yes')
		if (getCookie('firstVideoPlayedToday') != "true") //its been mroe than a day since video1 played
			if (getCookie('hasSecondVideoEverDisplayed') != 'yes')
			{
				setCookie('hasSecondVideoEverDisplayed','yes',365);
				return true;
			}
	return false;
}