// script.js 
// javascript functions used by video template site
// written by Bill @ Idea Market Design Inc. (http://www.ideamarket.ca)

// load movie list of a particular category
// @objSelect	the select object
function changeCategory(objSelect) {

	var objName = $E('b','categoryArea');
	var selectedOption = objSelect.options[objSelect.selectedIndex];

	// show loading message
	//$('thumbArea').innerHTML = '<img src="image/loading_thumbnail.jpg" alt="loading" />';
	$('thumbArea').innerHTML = '<h2>loading...</h2>';

	// change category title
	objName.innerHTML = selectedOption.innerHTML;

	// load thumb area
	var url = servlet + '?task=loadthumbarea&catid=' + objSelect.value;
	var objAjax = new Ajax(url, {method: 'get', update: 'thumbArea' });
	objAjax.request();

	// load new ads
	var url = servlet + '?task=getfooter&catid=' + objSelect.value + '&part=1';
	new Ajax(url, {onComplete: so_reload, method: 'get', update: 'jw-sir'}).request();
	var url = servlet + '?task=getfooter&catid=' + objSelect.value + '&part=2';
	new Ajax(url, {onComplete: so_reload2, method: 'get', update: 'jw-sir-2'}).request();
}

// play a video
// @vid 	video id
// @clicked	the div object we just clicked on
function playVideo(vid,clicked) {

	// show loading message
	$('mainVideo').innerHTML = '<img src="image/loading_movie.jpg" alt="loading" />';
	$('videotitle').innerHTML = 'loading...';
	$('videodesc').innerHTML = '';

	// load the movie
	var url = servlet + '?task=loadmovie&movieid=' + vid;
	var objAjax = new Ajax(url, {method: 'get', update: 'mainVideo', evalScripts: true});
	objAjax.request();

	// update title and description text
	var url = servlet + '?task=getmovietitle&movieid=' + vid;
	new Ajax(url, {method: 'get', update: 'videotitle'}).request();
	var url = servlet + '?task=getmoviedesc&movieid=' + vid;
	new Ajax(url, {method: 'get', update: 'videodesc'}).request();

	// change thumb area highlights
	var thumblist = $$('div.thumbnailList');
	for (var i=0; i<thumblist.length; i++) {
		thumblist[i].style.background = '#CCC';
		thumblist[i].onmouseout = function () { this.style.background='#CCC'; };
	}

	if ( clicked != null ) {
		clicked.style.background = '#DDD';
		clicked.onmouseout = null;
	}

}
