	var curr_countdown_item = 2; 
	var curr_countdown_item_two = 0; 
	var countdown_firsttime = true;
	var countdown_firsttime_two = true;

	var contestCountdown = [
			'<a href="http://www.101d.com/tour" title="Metal Harvest: The Roar Tour"><img src="http://devmedia.101distribution.com/assets/build/9.09.07/site/en_101/images/contest/Contest-Countdown-Tour.jpg" width="265" height="100" alt="" /></a><p class="b"><span class="date">1.20.10</span>Metal Harvest: The Roar Tour</p><p class="desc">Win a chance to headline the 2009 Metal Harvest: The Roar Tour.</p>',
			'<a href="http://www.101d.com/" title="Free Music Fridays"><img src="http://devmedia.101distribution.com/assets/build/9.09.07/site/en_101/images/contest/101-CELL_IMAGE-72.jpg" width="265" height="100" alt="" /></a><p class="b"><span class="date">10.1.09</span>Free Music Fridays</p><p class="desc">Get exclusive ringtones and MP3s from 101 Distribution weekly direct to your mobile phone.</p>',
			'<a href="http://www.101d.com/" title="Win Gear"><img src="http://devmedia.101distribution.com/assets/build/9.09.07/site/en_101/images/contest/Contest-Countdown-Gear.jpg" width="265" height="100" alt="" /></a><p class="b">Win Gear</p><p class="desc">Register to win a complete four piece band setup in the 101d Best Bands Contest.</p>'
	];
	var countdown_items = contestCountdown.length-1;
	var boxes = YAHOO.util.Selector.query('#contest_1 .right .box');
	function startCountdownSwap(index) {
		index = curr_countdown_item;
		if (countdown_firsttime == true) {
			index = 1;
		}
		countdown_firsttime = false;
		var fade = new YAHOO.util.Anim(boxes[0], {
			opacity: {from: 96, to:0}
		}, 3, YAHOO.util.Easing.easeOut);
		fade.onComplete.subscribe(function() {
			YAHOO.util.Dom.get(boxes[0]).innerHTML = contestCountdown[index];					
			fadeIn.animate();
		});
		var fadeIn = new YAHOO.util.Anim(boxes[0], {
			opacity: {from: 0, to:96}
		}, 3, YAHOO.util.Easing.easeIn);

		fadeIn.onComplete.subscribe(function() {
			++curr_countdown_item;
			curr_countdown_item = (curr_countdown_item > countdown_items) ? 0 : curr_countdown_item;
		});
		fade.animate();
	}
	function startCountdownTwo() {
		setInterval("startCountdownSwapTwo(" + curr_countdown_item_two + ")", 4000);
	}
	function startCountdownSwapTwo(index) {
		index = curr_countdown_item_two;
		if (countdown_firsttime_two == true) {
			index = 2;
		}
		countdown_firsttime_two = false;
		var fade = new YAHOO.util.Anim(boxes[1], {
			opacity: {from: 96, to:0}
		}, 3, YAHOO.util.Easing.easeOut);
		fade.onComplete.subscribe(function() {
			YAHOO.util.Dom.get(boxes[1]).innerHTML = contestCountdown[index];					
			fadeIn.animate();
		});
		var fadeIn = new YAHOO.util.Anim(boxes[1], {
			opacity: {from: 0, to:96}
		}, 3, YAHOO.util.Easing.easeIn);

		fadeIn.onComplete.subscribe(function() {
			++curr_countdown_item_two;
			curr_countdown_item_two = (curr_countdown_item_two > countdown_items) ? 0 : curr_countdown_item_two;
		});
		fade.animate();
	}

	// build JSON object for clickable event list cycle
	var curr_item = 0;
	var items = {    "event" : [
                                    { "title" : "Win A Day With Big Black &amp; Bam Bam, Nov. 15" },
                                    { "title" : "Stay Independent. The Video Contest, Dec. 15" }                                                                      
                                  ], // End "event" array.                                  
                  "desc"       : [
                                    { "text" : "One lucky Chunky Boyz fan will win roundtrip airfare and acomadations to Dallas, TX to lay low with Big Black & Bam Bam." },
                                    { "text" : "Write a song, shoot a music video and enter to win a MacBook Pro&reg;&frasl; Pro Tools&reg; package, a 101D Professional Account for one project and more." }                                 
                                  ], // End "description" array
                  "link"       : [
                                    { "title" : "Do Work SON! &raquo;",
                                      "href"  : "http://www.101distribution.com/artist/?view=promotions&id=6794"},                                                                         
                                    { "title" : "Enter To Win Now! &raquo;",
                                      "href"  : "http://www.101dcontest.com/"}                                  
                                  ] // End "link" Array
                } // End items

	var vidUrls = [
		'<object width="667" height="398"><param name="movie" value="http://www.youtube.com/v/ICMQLj28Azo&amp;hl=en&amp;fs=1&amp;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ICMQLj28Azo&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="667" height="398"></embed></object>',
		'<object width="667" height="398"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6389327&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6389327&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="667" height="398"></embed></object>',
		'<object width="667" height="398"><param name="movie" value="http://www.youtube.com/v/X7LKnZrjuf8&amp;hl=en&amp;fs=1&amp;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/X7LKnZrjuf8&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="667" height="398"></embed></object>',
		'<object width="667" height="398"><param name="movie" value="http://www.youtube.com/v/CAvBGbyGD7A&amp;hl=en&amp;fs=1&amp;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/CAvBGbyGD7A&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="667" height="398"></embed></object>',
		'<object width="667" height="398"><param name="movie" value="http://www.youtube.com/v/Z7sEaxzjBpU&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Z7sEaxzjBpU&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="667" height="398"></embed></object>'
	];
	var auto_animate;

	function setActiveVideoItem(e, index) {
		var text = YAHOO.util.Dom.getElementsByClassName('text', 'dd');
		var len = text.length;
		for (var i = 0; i < len; i++) {
			YAHOO.util.Dom.removeClass(text, "selected");	
		}
		YAHOO.util.Dom.addClass(text[index], "selected");
	}
	function setVideoUrl(e, index) {
		YAHOO.util.Event.preventDefault(e);
		YAHOO.util.Dom.get('entryVideoPlayer').innerHTML = vidUrls[index];		
	}
	function setTabStatus(e, id) {
		YAHOO.util.Event.preventDefault(e);
		var winnerLinks = YAHOO.util.Dom.get('winnersContainer').getElementsByTagName('ul')[0].getElementsByTagName('a');
		for (var i = 0; i < winnerLinks.length; i++) {
			winnerLinks[i].className = "";
		}
		if (id=="almostWinners") {
			YAHOO.util.Dom.get("defVideoWinners").style.display = "none";
			YAHOO.util.Dom.get("defVideoEntries").style.display = "inline";
		} else {
			YAHOO.util.Dom.get("defVideoEntries").style.display = "none";
			YAHOO.util.Dom.get("defVideoWinners").style.display = "inline";
		}
		YAHOO.util.Dom.get(id).className = "selected";
	}

	var max_item_length = items.event.length;
	var interval, top_interval, cur_scroll = 0;
	var top_cur_scroll = 0;
	var max_top_scroll = -364;
	var amount_to_scroll = 392;
	var temp_scroll = 0;
	var total_num_pics = 2; // total pics to cycle through
	var total_scroll_height = (max_top_scroll * total_num_pics);
	var in_transition = false;
	var iteration_next = 0; // scroll next iteration
	var iteration_previous = 0; // scroll previous iteration
	var finished_previous = false;
	var finished_next = false;

	function loadCurrent() {
		YAHOO.util.Dom.get('eventTitle').innerHTML = items.event[0].title;
		YAHOO.util.Dom.get('eventDesc').innerHTML = items.desc[0].text;
		YAHOO.util.Dom.get('eventLink').href = items.link[0].href;
		YAHOO.util.Dom.get('eventLink').title = items.link[0].title;
		YAHOO.util.Dom.get('eventLink').innerHTML = items.link[0].title;
	}

	function moveNext(e, evt) {
		if (evt != undefined) { clearInterval(auto_animate); }
		try { YAHOO.util.Event.preventDefault(e);	} catch(error) {} 
		curr_item++;
		if (curr_item == max_item_length) {
			curr_item = 0;
		}
		YAHOO.util.Dom.get('eventTitle').innerHTML = items.event[curr_item].title;
		YAHOO.util.Dom.get('eventDesc').innerHTML = items.desc[curr_item].text;
		YAHOO.util.Dom.get('eventLink').href = items.link[curr_item].href;
		YAHOO.util.Dom.get('eventLink').title = items.link[curr_item].title;
		YAHOO.util.Dom.get('eventLink').innerHTML = items.link[curr_item].title;
		if (!in_transition) {
			scrollContestNext();
		}
	}
	function movePrevious(e, evt) {
		if (evt != undefined) { clearInterval(auto_animate); }
		YAHOO.util.Event.preventDefault(e);	 
		curr_item--;
		if (curr_item == -1) {
			curr_item = max_item_length -1;
		}
		YAHOO.util.Dom.get('eventTitle').innerHTML = items.event[curr_item].title;
		YAHOO.util.Dom.get('eventDesc').innerHTML = items.desc[curr_item].text;
		YAHOO.util.Dom.get('eventLink').href = items.link[curr_item].href;
		YAHOO.util.Dom.get('eventLink').title = items.link[curr_item].title;
		YAHOO.util.Dom.get('eventLink').innerHTML = items.link[curr_item].title;
		if (!in_transition) {
			scrollContestPrevious();
		}
	}

	function scrollDatesUp() {
		interval = setInterval(function()
	 	{
			cur_scroll += 3;
			YAHOO.util.Dom.get('defVideoEntries').scrollTop = cur_scroll;
		 }, 40);
	}
	
	function scrollDatesDown() {
		interval = setInterval(function()
	 	{
			cur_scroll -= 3;
			YAHOO.util.Dom.get('defVideoEntries').scrollTop = cur_scroll;
		 }, 40);
	}
	
	function stopDates() {
		clearInterval(interval);
	}


	function scrollContestNext() {		
		top_interval = setInterval(function()
	 	{
			in_transition = false;				
			if (temp_scroll < amount_to_scroll) {				
				in_transition = true;
				YAHOO.util.Dom.setStyle('contestContainer', 'backgroundPosition', ('0 ' + (top_cur_scroll + 'px')));
				top_cur_scroll -= 28;
				temp_scroll += 28;
			} else {
				temp_scroll = 0;
				top_cur_scroll += 28;
				stopTopScroll();
			}
		 }, 20);
	}
	function scrollContestPrevious() {
		top_interval = setInterval(function()
	 	{
			in_transition = false;
			if (temp_scroll < amount_to_scroll) {				
				in_transition = true;
				YAHOO.util.Dom.setStyle('contestContainer', 'backgroundPosition', ('0 ' + (top_cur_scroll + 'px')));
				top_cur_scroll += 28;
				temp_scroll += 28;
			} else {				
				temp_scroll = 0;
				top_cur_scroll -= 28;
				stopTopScroll();
			}			
		 }, 20);
	}

	function stopTopScroll() {
		clearInterval(top_interval);
	}

