	
	// video changing functions
	
function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.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 checkCookie() {
	pathToVideo = setPath();
	cookie = getCookie('celebritas');
	if(cookie != null && cookie !="") {
		newValue = parseInt(cookie) + 1;
		setCookie('celebritas', newValue, 365);
	} else {
		setCookie('celebritas', 1, 365);
	}
}


//--------------------------------------------------

function setPath() {
	cookie = getCookie('celebritas');

	if(cookie == null && cookie =="") {
		visits = 0;
	} else {
		visits = parseInt(cookie);
	}
	
	
	
	//---- no editing above this line *****************************
	
	
	
	if(visits == 0) { // this means the user is new
		pathToXML = "http://www.celebritas.com/ricky-ehost/cue_point.xml"; //here we set the path to the video
	}
	//----
	else if(visits == 1) { // this is the second visit for the user
		pathToXML = "http://www.celebritas.com/ricky-ehost/cue_point2.xml"; //we set another path
	}
	//----
	else if(visits == 2) { // this is the third visit for the user
		pathToXML = "http://www.celebritas.com/ricky-ehost/cue_point.xml"; //we set another path
	}
	//----
	
	// and we could go like this forever...
	
	//----
	else { // if the user has more than 3 visits we set another path
		pathToXML = "http://www.celebritas.com/ricky-ehost/cue_point2.xml";
	}
		
	return pathToXML;
}

pathToXML = setPath();

//---------------------------------------------------
	
	
function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else
      window.onload = fnc;
  }
}

addOnloadEvent(function(){ checkCookie(); });