/*SELUC VIDEO FUNCTIONS*/
var player = null;
var file       = null;
var id         = null;
var theFile    = null;


if(!(playItem = $.swfobject.getQueryParamValue('item'))) {
	playItem = null;
}

if(!(file = $.swfobject.getQueryParamValue('playlist'))) {
	file='http://www2.selu.edu/thesoutheasternchannel/lib/data/'+theFile+'.xml';
}

if(!(id = $.swfobject.getQueryParamValue('vid'))) {
	id = null;
}	  

function playAway() {
	if(id != null) {
		//play by title
		setTimeout("playIt(id)", 200);
	} else if (playItem != null) {
		//play item number
		setTimeout("player.sendEvent('ITEM', playItem)", 200);
	} else {
	//just load do not play
	}
};

function playIt(id)
{
	str = id.replace(/\+/gi,"%20");
	var title    = unescape(str);
	var playlist = player.getPlaylist();
	for(var j in playlist) {
		if(title == playlist[j].title) {
			player.sendEvent('ITEM', j);
			player.sendEvent('PLAY', 'true');
		break;
		}
	}
};

function itemMonitor(obj) {
		gid('nowplaying').innerHTML = '<h2>Now Playing: ' + player.getPlaylist()[obj.index].title + '</h2>'; 
	
};

function addListeners() {
	if (player) { 
	  player.addControllerListener('ITEM', 'itemMonitor');
	} else {
		setTimeout("addListeners()",100);
	}
}
/**/
function buildmp480(theFile, theAutostart, theShuffle) {
	var flashvars={};
	flashvars.file='http://www2.selu.edu/thesoutheasternchannel/lib/data/'+theFile+'.xml';
	flashvars.config='http://www2.selu.edu/thesoutheasternchannel/lib/data/mpconfig_480.xml';
	flashvars.streamer='rtmp://gimli.csd.selu.edu/vod/'+theFile;
	flashvars.autostart= theAutostart;
	flashvars.shuffle= theShuffle;
	var params={};
	params.allowfullscreen='true';
	params.allowscriptaccess='always';
	params.wmode='opaque';
	var attributes={};
	attributes.id='mplayer';
	attributes.name='mplayer';
	$.swfobject.embedSWF('http://www2.selu.edu/thesoutheasternchannel/lib/inc/videoplayer/secmplayer_4_4.swf','mplayer','480','340','9.0.0','http://www2.selu.edu/thesoutheasternchannel/lib/media/expressinstall.swf',flashvars,params,attributes);
}

function buildmp320(theFile, theAutostart, theShuffle) {
	var flashvars={};
	flashvars.file='http://www2.selu.edu/thesoutheasternchannel/lib/data/'+theFile+'.xml';
	flashvars.config='http://www2.selu.edu/thesoutheasternchannel/lib/data/mpconfig_320.xml';
	flashvars.streamer='rtmp://gimli.csd.selu.edu/vod/'+theFile;
	flashvars.autostart= theAutostart;
	flashvars.shuffle= theShuffle;
	flashvars.repeat='list';
	var params={};
	params.allowfullscreen='true';
	params.allowscriptaccess='always';
	params.wmode='opaque';
	var attributes={};
	attributes.id='mplayer';
	attributes.name='mplayer';
	$.swfobject.embedSWF('http://www2.selu.edu/thesoutheasternchannel/lib/inc/videoplayer/secmplayer_4_4.swf','mplayer','320','234','9.0.0','http://www2.selu.edu/thesoutheasternchannel/lib/media/expressinstall.swf',flashvars,params,attributes);

}

function buildmp480_2(theFile,  theAutostart, theShuffle) {
	var flashvars={};
	flashvars.file='http://www2.selu.edu/thesoutheasternchannel/lib/data/'+theFile+'.xml';
	flashvars.config='http://www2.selu.edu/thesoutheasternchannel/lib/data/mpconfig_480.xml';
	flashvars.streamer='rtmp://gimli.csd.selu.edu/vod/'+theFile;
	flashvars.autostart= theAutostart;
	flashvars.shuffle= theShuffle;
	var params={};
	params.allowfullscreen='true';
	params.allowscriptaccess='always';
	params.wmode='opaque';
	var attributes={};
	attributes.id='mplayer2';
	attributes.name='mplayer2';
	$.swfobject.embedSWF('http://www2.selu.edu/thesoutheasternchannel/lib/inc/videoplayer/secmplayer_4_4.swf','mplayer2','480','340','9.0.0','http://www2.selu.edu/thesoutheasternchannel/lib/media/expressinstall.swf',flashvars,params,attributes);
};

function playerReady(obj) {
	player = gid(obj.id);
    playAway();
	addListeners();
}

function gid(name) {
	return document.getElementById(name);
}
//Global Ready Functions
jQuery().ready(function(){
	$('.box').corner('10px');
});