/* SL: html constructor for home page carousels  */

function buildCarouselContent(videoArray, carouselName, count) {
	var total = count;
	
	
	var videoPageArray = videoArray;
	if (videoPageArray.length > 0) {
		for (var i = 0 ;i < total; i++) {
			document.write("<li id=\"" + carouselName + "-item-" + (i+1) + "\">");
			document.write("<div class=\"featured\">");
			document.write("<div class=\"playThumb\"><a target=\"_parent\" href=\"/" + videoPageArray[i].vprop1 + "?cid=" + videoPageArray[i].vprop7 + "&pid=" + videoPageArray[i].vprop10 + "&category=" + category_type + "&play=true\"><img src=\"" + videoPageArray[i].vprop11 + "\" width=\"120\" height=\"90\" border=\"0\" /></a></div><div class=\"content\">");
			document.write("<h5 class=\"showname\">" + videoPageArray[i].vprop3 + "</h5>");
			document.write("<h5>" + videoPageArray[i].vprop2 + "</h5>");
			document.write("<p class=\"season_episode\">");
			if (videoPageArray[i].vprop4 != '') document.write("Season " + videoPageArray[i].vprop4 + ": ");
			if (videoPageArray[i].vprop6 != '') document.write("Ep. " + videoPageArray[i].vprop6);
			document.write("</p><p class=\"duration\">" + videoPageArray[i].vprop8 + " (" + videoPageArray[i].vprop9 + ")</p><div class=\"clear\"></div></div><div class=\"clear\"></div></div></li>");
		}
	}
	else {
		document.write("<br/><h5>There are currently no videos in this category.<br/><br/>Please, check back later.</h5><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>")
	}
}

function buildCarouselControlsHp(carouselName, count, category, where) {
	var total = count;
	var itemsPerPage = 4;
	var itemsToShow = itemsPerPage;
	var number_of_pages = Math.ceil(count / itemsPerPage);

	document.write('<div class="carousel-prev" onclick="selectPrevDot(\'' + carouselName + '\')"><img id="' + carouselName + '-prev-arrow" class="left-button-image" src="/heckleu/images/common/left-enabled-blue.gif" alt="Previous"/></div>');
	
	for (i=0; i<number_of_pages; i++) {
		document.write('<div class="navdot"><a href="javascript:void(0)" onclick="' + carouselName + '.scrollTo(' + eval(i*itemsPerPage+1) + ');selectDot(\''+ carouselName + '\',\'' + carouselName + '-navdot' + i + '\')"><img id="' + carouselName + '-navdot' + i + '" src="/hp_2008/images/carousel/nav_dot_off.gif" border="0" alt="Page ' + (i+1) + '" title="Page ' + (i+1) + '"/></a></div>');
	}	
	
	document.write('<div class="carousel-next" onclick="selectNextDot(\'' + carouselName + '\')"><img id="' + carouselName + '-next-arrow" class="right-button-image"	src="/heckleu/images/common/right-enabled-blue.gif" alt="Next"/></div>');

	if (where == 'NEWEST')
	{
	document.write('<a class="btn" href="viewallvideo.php?vCategory=NEWEST" style="float:right; margin-top:13px; margin-right:45px"><span>View All</span></a>');
	}
	
	if (where == 'MOST')
	{
	document.write('<a class="btn" href="viewallvideo.php?vCategory=MOST" style="float:right; margin-top:13px; margin-right:45px"><span>View All</span></a>');
	}
	
	if (where == 'TOP')
	{
	document.write('<a class="btn" href="viewallvideo.php?vCategory=TOP" style="float:right; margin-top:13px; margin-right:45px"><span>View All</span></a>');
	}


}


function buildCarouselControls(carouselName, count, category, where, itemsPerPage) {
	
	var total = count;
	var itemsToShow = itemsPerPage;
	var number_of_pages = Math.ceil(count / itemsPerPage);
	
	//alert(number_of_pages);

	document.write('<div class="carousel-prev" onclick="selectPrevDot(\'' + carouselName + '\')"><img id="' + carouselName + '-prev-arrow" class="left-button-image" src="/heckleu/images/common/left-enabled-blue.gif" alt="Previous"/></div>');
	
	for (i=0; i<number_of_pages; i++) {
		document.write('<div class="navdot"><a href="javascript:void(0)" onclick="' + carouselName + '.scrollTo(' + eval(i*itemsPerPage+1) + ');selectDot(\''+ carouselName + '\',\'' + carouselName + '-navdot' + i + '\')"><img id="' + carouselName + '-navdot' + i + '" src="/hp_2008/images/carousel/nav_dot_off.gif" border="0" alt="Page ' + (i+1) + '" title="Page ' + (i+1) + '"/></a></div>');
	}	
	
	document.write('<div class="carousel-next" onclick="selectNextDot(\'' + carouselName + '\')"><img id="' + carouselName + '-next-arrow" class="right-button-image" src="/heckleu/images/common/right-enabled-blue.gif" alt="Next"/></div>');

	if (where == 'NEWEST')
	{
	document.write('<a href="/heckleu/video_rss.php?cat=recent" style="float:right; margin-top:13px; margin-right:45px"><img src="/heckleu/images/content/rss_clear_btn.gif" border="0"></a><a href="contest/viewallvideo.php?vCategory=NEWEST" style="float:right; margin-top:13px; margin-right:5px"><img src="/heckleu/images/content/viewall.gif" border="0"></a>');
	}
	
	if (where == 'MOST')
	{
	document.write('<a class="btn" href="contest/viewallvideo.php?vCategory=MOST" style="float:right; margin-top:13px; margin-right:45px"><span>View All</span></a>');
	}
	if (where == 'TOP')
	{
	//document.write('<a class="btn" href="contest/viewallvideo.php?vCategory=TOP"" style="float:right; margin-top:13px; margin-right:45px"><span>View All</span></a>');
	}

}

/*function selectDot(carouselName, dotId) {
	var dotsArray = new Array();
	dotsArray = $$('div#' + carouselName + ' div.navdot img');
	for (i=0; i<dotsArray.length; i++) {
		$(dotsArray[i]).src = '/hp_2008/images/carousel/nav_dot_off.gif';
	}
	document.getElementById(dotId).src = '/specials/grammys/images/common/nav_dot_on.gif';
}

function selectPrevDot(carouselName) {
	var carousel = eval(carouselName);
	var currentElement = carousel.getFirstVisible();
	var carouselSize = carousel.getProperty('size');
	var numVisible = carousel.getProperty('numVisible');
	if (carouselSize - currentElement >= numVisible) {
		var prevDotId = Math.floor(currentElement/numVisible);
	}
	else {
		var prevDotId = Math.floor(currentElement/numVisible + 1);
	}
	var dotsArray = new Array();
	dotsArray = $$('div#' + carouselName + ' div.navdot img');
	for (i=0; i<dotsArray.length; i++) {
		$(dotsArray[i]).src = '/hp_2008/images/carousel/nav_dot_off.gif';
	}
	document.getElementById(carouselName + '-navdot' + prevDotId ).src = '/specials/grammys/images/common/nav_dot_on.gif';
}

function selectNextDot(carouselName) {
	var carousel = eval(carouselName);
	var currentElement = carousel.getFirstVisible();
	var carouselSize = carousel.getProperty('size');
	var numVisible = carousel.getProperty('numVisible');
	
	//alert(carouselSize - currentElement);
	if (carouselSize - currentElement >= numVisible) {
		var nextDotId = Math.floor(currentElement/numVisible);
	}
	else {
		var nextDotId = Math.floor(currentElement/numVisible + 1);
	}
	var dotsArray = new Array();
	dotsArray = $$('div#' + carouselName + ' div.navdot img');
	for (i=0; i<dotsArray.length; i++) {
		$(dotsArray[i]).src = '/hp_2008/images/carousel/nav_dot_off.gif';
	}
	document.getElementById(carouselName + '-navdot' + nextDotId ).src = '/specials/grammys/images/common/nav_dot_on.gif';
	

}*/
