var cookieName = "VisitCount";
function Behaviour(_id, _playerStatus, _visitCount, _repeatCount, _isAutoPlay, _idleLoop, _isDisappear, _delay, _playCount, _frontEndLoop, _backEndLoop, _idleLoopCount, _isShowControls, _playIndex,_presentationFile, _brandLogo, _brandURL, _isBrand)
{
	this.id = _id;
	this.playerStatus = _playerStatus;
	this.visitCount = _visitCount;	
	this.repeatCount = _repeatCount;
	this.isAutoPlay = _isAutoPlay;
	this.idleLoop = _idleLoop;
	this.isDisappear = _isDisappear;
	this.delay = _delay;	
	this.playCount = _playCount;
	this.frontEndLoop = _frontEndLoop;
	this.backEndLoop = _backEndLoop;
	this.idleLoopCount = _idleLoopCount;	
	this.isShowControls = _isShowControls;	
	//Presentation
	this.playIndex = _playIndex;
	this.presentationFiles = _presentationFile;
	//Brand Configuration
	this.brandLogo = _brandLogo;
	this.brandURL = _brandURL;
	this.isBrand = _isBrand;
}

function PageStat(_pageId, _flId, _visitCount)
{
	this.pageId = _pageId;
	this.flId = _flId;
	this.visitCount = _visitCount;
}

function setPageEmbeddedFLCookie(domain, path,file)
{
  var pageStat = getPageEmbeddedFLCookie(file);
  if(pageStat.visitCount == 0)
  {
    pageStat.visitCount = 1;
  }
  else
  {
    pageStat.visitCount = pageStat.visitCount + 1;
  }  
  setCookie(cookieName, pageStat.visitCount, 10000, domain, path, file);      
  return pageStat.visitCount;
}

function getPageEmbeddedFLCookie(file)
{
  pageStat = new PageStat();
  var count = getCookie(cookieName,file);
  if(count == null || count == "")
  {
    pageStat.visitCount = 0;
  }
  else
  {
    pageStat.visitCount = parseInt(count);
  }
  return pageStat;
}

function getCookie(c_name,file)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name+ "_" + file + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + (c_name+ "_" + file).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(c_name,value,expiredays, domain, path,file)
{
    
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name + "_" + file + "=" +escape(value)+
  ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) + ( (path != null ) ? ";path=" + path : "") + ( (domain != null) ? ";domain=" + domain : "");      
    
}