// JavaScript Document
/*
Shawn Lawler (rtcweb@umn.edu)
Interface enhancements and Behavior layer for RTC Media
*/

var W3CDOM = (document.getElementById);
var toggleOrderDvd = true;

function initOrderingInfo() {
	
	// Hide the order information first to eliminate/minimize flicker and toggle the link arrow
	document.getElementById('order_info').className = 'toggle_off';
	document.getElementById('toggle_arrow').className = 'toggle_up';
	
	var odParent = document.getElementById('orderdvd');
	var od = document.getElementById('order_link').getElementsByTagName('a')[0];
	
	// make the order link clickable and set the title attrib for the tooltip and screen reader usability
	/*od.setAttribute('href', '');
	od.href = '';*/
	od.setAttribute('title', 'Click to toggle ordering information.');
	// attach event handlers
	od.onclick=function(){orderDvdToggle();return false};
	od.onkeypress=function(){orderDvdToggle();return false};
}

function orderDvdToggle () {
	if (toggleOrderDvd) {
		document.getElementById('order_info').className = 'toggle_on';
		document.getElementById('toggle_arrow').className = 'toggle_down';
		toggleOrderDvd = false;
	}
	else if (!toggleOrderDvd) {
		document.getElementById('order_info').className = 'toggle_off';
		document.getElementById('toggle_arrow').className = 'toggle_up';
		toggleOrderDvd = true;
	}
}

// For use with AS3<->JS API
function getFlashMovie(movieID) {
	var mySwf=document.getElementById(movieID);
	return mySwf;
}

function hookUpPlaylist() {
	$("#playlist").show(200);
	$("#playlist a").click(function() {
		$(this).addClass('current');
		var vidFrag;
		var capFrag;
		if ($(this).find("span.vidfrag").length) vidFrag = $(this).find("span.vidfrag").text();
		if ($(this).find("span.capfrag").length) capFrag = $(this).find("span.capfrag").text();
		getFlashMovie("flashcontent").sendVidPropsToFlash(vidFrag, capFrag);
		return false;
	});
}
