
/**
 * Image src URLs
 **/
var imageList = [
				 "cinema7",
				 "local6",
				 "guatemala2",
				 "theatre6",
				 "insideout2",
				 "insideout3",
				 "lindsay1",
				 "lindsay2",
				 "local5",
                 "cinema5",
                 "cinema6",
				 "webisode2",
				 "guatemala1",
				 "webisode1",
                 "local4",
                 "local1",
                 "cinema1",
                 "cinema2",
                 "cinema3",
                 "cinema4",
                 "amped1",
                 "amped2",
                 "amped3",
                 "insideout1",
                 "medical1",
                 "medical2",
                 "theatre1",
                 "theatre2",
                 "theatre3",
                 "theatre4",
                 "theatre5",
				 "local2",
				 "local3",
				 "engineering1",
				 "fashion1",
				 "fashion2",
				 "dancemusic1",
				 "sculpture1",
				 "theatre7",
				 "frisbee1",
				 "webisode3",
				 "art1",
				 "webisode4",
				 "theatre8",
				 "theatre9",
				 "local7",
				 "cinema8",
				 "amped4",
				 "amped5",
				 "amped6",
				 "engineering2",
				 "medical3",
				 "cinema9",
				 "medical4",
				 "sange",
				 "directors",
				 "art2",
				 "qatar",
				 "abbeyroad",
				 "lens2",
				 "palominos",
				 "foolsdeux",
				 "mercy",
				 "chop",
				 "ess",
				 "toast",
				 "uesbb",
				 "johnston",
				 "guadalajara",
				 "shadowplay",
				 "rockvote",
				 "performance",
				 "emmy",
				 "ki",
				 "lens3",
				 "art3",
				 "fortieth",
				 "beck",
				 "nicu",
				 "massey",
				 "hartert",
				 "animalbeat",
				 "art4",
				 "cameratruck"
                 ];

var urlList = [
			     "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/byrd.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/rollergirls.html",
				 "http://www.vcutvhd.vcu.edu/shows/studyabroad/guatemala2.html",
				 "http://www.vcutvhd.vcu.edu/shows/dracula/dracula1.html",
				 "http://www.vcutvhd.vcu.edu/shows/insideout/locker50b.html",
				 "http://www.vcutvhd.vcu.edu/shows/insideout/bonnie.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/lindsay1.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/lindsay2.html",
			   	 "http://www.vcutvhd.vcu.edu/shows/local/jiujitsu.html",
			     "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/48hrs1.html",
				 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/48hrs2.html",
				 "http://www.vcutvhd.vcu.edu/shows/webisodes/alexvsnick.html",
			     "http://www.vcutvhd.vcu.edu/shows/studyabroad/guatemala1.html",
				 "http://www.vcutvhd.vcu.edu/shows/webisodes/newboss.html",
			   	 "http://www.vcutvhd.vcu.edu/shows/local/comics.html",
                 "http://www.vcutvhd.vcu.edu/shows/local/bottomsup.html",
                 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/carabeo.html",
                 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/germanotta.html",
                 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/harris.html",
                 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/west.html",
                 "http://www.vcutvhd.vcu.edu/shows/amped/dropouts.html",
                 "http://www.vcutvhd.vcu.edu/shows/amped/thesort.html",
                 "http://www.vcutvhd.vcu.edu/shows/local/richmondlucha.html",
                 "http://www.vcutvhd.vcu.edu/shows/insideout/insideout.html",
                 "http://www.vcutvhd.vcu.edu/shows/medicalcenter/trauma.html",
				 "http://www.vcutvhd.vcu.edu/shows/medicalcenter/support.html",
                 "http://www.vcutvhd.vcu.edu/shows/medea/medea1.html",
                 "http://www.vcutvhd.vcu.edu/shows/medea/medea2.html",
                 "http://www.vcutvhd.vcu.edu/shows/medea/medea3.html",
                 "http://www.vcutvhd.vcu.edu/shows/medea/medea4.html",
				 "http://www.vcutvhd.vcu.edu/shows/medea/medea5.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/comedysportz.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/swazz.html",
				 "http://www.vcutvhd.vcu.edu/shows/engineering/robotics.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/strut1.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/strut2.html",
				 "http://www.vcutvhd.vcu.edu/shows/dance_music/africa.html",
				 "http://www.vcutvhd.vcu.edu/shows/sculpture/sculpture1.html",
				 "http://www.vcutvhd.vcu.edu/shows/dracula/dracula2.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/frisbee1.html",
				 "http://www.vcutvhd.vcu.edu/shows/webisodes/ilost.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/art180-pt1.html",
				 "http://www.vcutvhd.vcu.edu/shows/webisodes/oasis.html",
				 "http://www.vcutvhd.vcu.edu/shows/dracula/dracula_uncut.html",
				 "http://www.vcutvhd.vcu.edu/shows/dracula/dracula_uncut2.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/jiujitsu2.html",
				 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/freak.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/duchess.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/fools.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/army.html",
				 "http://www.vcutvhd.vcu.edu/shows/engineering/eschool.html",
				 "http://www.vcutvhd.vcu.edu/shows/medicalcenter/empathy.html",
				 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/death.html",
				 "http://www.vcutvhd.vcu.edu/shows/medicalcenter/heart.html",
				 "http://www.vcutvhd.vcu.edu/shows/insideout/sange.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/directors.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/art180-pt2.html",
				 "http://www.vcutvhd.vcu.edu/shows/studyabroad/vcuqatar.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/abbeyroad.html",
				 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/lens2.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/palominos.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/foolsdeux.html",
				 "http://www.vcutvhd.vcu.edu/shows/medicalcenter/mercy.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/chop.html",
				 "http://www.vcutvhd.vcu.edu/shows/insideout/ess.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/toast.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/uesbb.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/johnston.html",
				 "http://www.vcutvhd.vcu.edu/shows/studyabroad/guadalajara.html",
				 "http://www.vcutvhd.vcu.edu/shows/theatre/shadowplay.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/rockvote.html",
				 "http://www.vcutvhd.vcu.edu/shows/theatre/sp-performance.html",
				 "http://www.vcutvhd.vcu.edu/shows/webisodes/emmy.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/ki.html",
				 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/lens3.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/art180-pt3.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/40th.html",
				 "http://www.vcutvhd.vcu.edu/shows/insideout/beck.html",
				 "http://www.vcutvhd.vcu.edu/shows/medicalcenter/nicu.html",
				 "http://www.vcutvhd.vcu.edu/shows/medicalcenter/massey.html",
				 "http://www.vcutvhd.vcu.edu/shows/cinemaphiles/hartert.html",
				 "http://www.vcutvhd.vcu.edu/shows/amped/animalbeat.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/art180-pt4.html",
				 "http://www.vcutvhd.vcu.edu/shows/local/cameratruck.html"
				 
                 ];

var urlTitleList = [
				 "Cinemaphiles: Byrd Theatre",
				 "Local Life: River City Roller Girls",
				 "VCU Study Abroad: Guatemala - Part 2",
				 "VCU Theatre Presents: Dracula - Part 1",
				 "VCU Inside Out: Locker 50B",
				 "VCU Inside Out: Bonnie Brown",
				 "Local Life: A Concert for Lindsay - Part 1",
				 "Local Life: A Concert for Lindsay - Part 2",
				 "Local Life: Jiu-Jitsu",
				 "Cinemaphiles: 48 Hour Film Festival, Part 1",
				 "Cinemaphiles: 48 Hour Film Festival, Part 2",
				 "VCU TV/HD Webisode 2: Alex vs. Nick",
	             "VCU Study Abroad: Guatemala Part 1",
				 "VCU TV/HD Webisode 1: The New Boss",
				 "Local Life: VCU Comics",
                 "Local Life: Bottoms Up Pizza",
                 "Cinemaphiles: Joe Carabeo",
                 "Cinemaphiles: Alex Germanotta/Todd Raviotta",
                 "Cinemaphiles: Steven Harris",
                 "Cinemaphiles: Matt West",
                 "VCU Amped: The Social Dropouts",
                 "VCU Amped: The Sort",
                 "Local Life: Richmond Lucha",
                 "VCU Inside Out",
                 "VCU Medical Center: VCU Trauma Center",
				 "VCU Medical Center: Support Teams",
                 "VCU Theatre Presents: Medea Part 1 - What is Medea?",
                 "VCU Theatre Presents: Medea Part 2 - Bringing Medea to Life.",
                 "VCU Theatre Presents: Medea Part 3 - Last Call",
                 "VCU Theatre Presents: Medea The Performance - Part 1",
				 "VCU Theatre Presents: Medea The Performance - Part 2",
				 "Local Life: Richmond Improv - ComedySportz",
				 "Local Life: All That Swazz",
				 "VCU Engineering: First Robotics",
				 "Local Life: STRUT 2007 - Part 1",
				 "Local Life: STRUT 2007 - Part 2",
				 "VCU Dance/Music: For Africa",
				 "VCU Sculpture",
				 "VCU Theatre Presents: Dracula - Part 2 - The Blood",
				 "Local Life: Ultimate Frisbee, Part 1",
				 "VCU TV/HD Webisode 3: iLost",
				 "Local Life: Art 180, Part 1",
				 "VCU TV/HD Webisode 4: Oasis",
				 "VCU Theatre Presents: Dracula 'Uncut'- Part 1",
				 "VCU Theatre Presents: Dracula 'Uncut'- Part 2",
				 "Local Life: Jiu-Jitsu Lifestyle",
				 "Cinemaphiles: FREAK",
				 "VCU Amped: The Duchess of York",
				 "VCU Amped: House of Fools Live",
				 "VCU Amped: Army of Me",
				 "VCU Engineering: The New E-School",
				 "VCU Medical Center: Clinical Empathy",
				 "Cinemaphiles: Student Lens: Death",
				 "VCU Medical Center: A Matter of Heart",
				 "VCU Inside Out: Gary Sange",
				 "Local Life: VCU Ultimate: Director's Cut",
				 "Local Life: Art 180, Part 2",
				 "Study Abroad: VCU Qatar",
				 "VCU Amped: Abbey Road Live",
				 "Cinemaphiles: Student Lens: Part 2",
				 "VCU Amped: Palominos",
				 "VCU Amped: House of Fools Deux",
				 "VCU Medical Center: Mission of Mercy",
				 "Local Life: Chop Suey",
				 "VCU Inside Out: Lindsay Ess",
				 "VCU Amped: Cold Toast",
				 "VCU Amped: Upper East Side Big Band",
				 "VCU Amped: Daniel Johnston",
				 "Study Abroad: Guadalajara",
				 "VCU Theatre: Shadowplay - Behind-the-Scenes",
				 "VCU Amped: Sheryl Crow and Jack Johnson",
				 "VCU Theatre: Shadowplay - Performance",
				 "VCU TV/HD Webisode 5: Capital Emmy's",
				 "VCU Amped: Ki: Theory",
				 "Cinemaphiles: Student Lens: Part 3: Brain Bear",
				 "Local Life: Art 180, Part 3",
				 "Local Life: VCU 40th Anniversary",
				 "VCU Inside Out: Patti D'Beck",
			     "VCU Medical Center: NICU",
				 "VCU Medical Center: Massey Cancer Center",
/** 81 **/		 "Cinemaphiles: Student Lens: Richard Hartert",
/** 82 **/		 "VCU Amped: Animal Beat",
/** 83 **/		 "Local Life: Art 180, Part 4",
/** 84 **/		 "Local Life: Camera Truck"
                 ];

/**
 * Since carousel.addItem uses an HTML string to create the interface
 * for each carousel item, this method formats the HTML for an LI.
 **/
var fmtItem = function(imgUrl, url, title) {

      var innerHTML = 
          '<a class="' + imgUrl + ' bt" href="' + 
          url + 
          '" title="' + title + '">&nbsp;</a>';
  
    return innerHTML;
    
};

/**
 * Custom inital load handler. Called when the carousel loads the initial
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadInitHandler
 **/
var loadInitialItems = function(type, args) {

    var start = args[0];
    var last = args[1]; 

    load(this, start, last);    
};

/**
 * Custom load next handler. Called when the carousel loads the next
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadNextHandler
 **/
var loadNextItems = function(type, args) {    

    var start = args[0];
    var last = args[1]; 
    var alreadyCached = args[2];
    
    if(!alreadyCached) {
        load(this, start, last);
    }
};

/**
 * Custom load previous handler. Called when the carousel loads the previous
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadPrevHandler
 **/
var loadPrevItems = function(type, args) {
    var start = args[0];
    var last = args[1]; 
    var alreadyCached = args[2];
    
    if(!alreadyCached) {
        load(this, start, last);
    }
};

var load = function(carousel, start, last) {
    for(var i=start; i<=last; i++) {
        carousel.addItem(i, fmtItem(imageList[i-1], urlList[i-1], urlTitleList[i-1]));
    }
};



/**
 * Custom button state handler for enabling/disabling button state. 
 * Called when the carousel has determined that the previous button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: prevButtonStateHandler
 **/
var handlePrevButtonState = function(type, args) {
    var enabling = args[0];
    var leftImage = args[1];
    if(enabling) {
        leftImage.src = "../../images/left-enabled.gif";        
    } else {
        leftImage.src = "../../images/left-disabled.gif";    
    }
    
}

/**
 * Custom button state handler for enabling/disabling button state. 
 * Called when the carousel has determined that the next button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: nextButtonStateHandler
 **/
var handleNextButtonState = function(type, args) {
    var enabling = args[0];
    var rightImage = args[1];
    if(enabling) {
        rightImage.src = "/dev/tvhd/images/right-enabled.gif";    
    } else {
        rightImage.src = "/dev/tvhd/images/right-disabled.gif";
    }
    
};

/**
 * You must create the carousel after the page is loaded since it is
 * dependent on an HTML element (in this case 'dhtml-carousel'.) See the
 * HTML code below.
 **/

function shownFirst(current) 
{
	if (current < 5) 
	{
		return 1;
	}
	else if (current > (imageList.length - 4))
	{
		return (imageList.length - 8);
	}
	else 
	{
		return current - 4;
	}
}

function getImgsSize()
{
	return imageList.length;
}

function getShowing(current) 
{	
	return "Showing number " + current + " of " + imageList.length;
}


function getPrevNextShow(current) 
{	
	return getPrevShow(current) + " | " + getNextShow(current);
}

function getNextShow(current) 
{	
	if(current == urlList.length)
	{
		return "Next show";
	}
	else
	{
		newURL = urlList[(current)];
		return "<a href=\"" + newURL + "\">Next show</a> <img alt=\"\" src=\"../../images/layout/tinyarrow-right.gif\"/>";
	}
}

function getPrevShow(current) 
{	
	if(current == 1)
	{
		return "Previous show";
	}
	else
	{
		newURL = urlList[(current - 2)];
		return "<img alt=\"\" src=\"../../images/layout/tinyarrow-left.gif\"/> <a href=\"" + newURL + "\">Previous show</a>";
	}
}