function selectMovie(frm,id,code,title)
{
   frm.action = 'listmovies.php?movieid='+id+'&code='+code+'&title='+title;
   frm.submit();
}

function selectTrailer(frm,id,code,title)
{
   frm.action = 'listtrailers.php?movieid='+id+'&code='+code+'&title='+title;
   frm.submit();
}

function selectTvShow(frm,id,code,title)
{
   frm.action = 'listtvshows.php?mainid='+id+'&code='+code+'&title='+title;
   frm.submit();
}

function selectEvent(frm,id,code,title)
{
   frm.action = 'listevents.php?mainid='+id+'&code='+code+'&title='+title;
   frm.submit();
}

function selectPop(frm,id,code,title)
{
   frm.action = 'listpops.php?mainid='+id+'&code='+code+'&title='+title;
   frm.submit();
}

function selectComedy(frm,id,code,title)
{
   frm.action = 'listcomedies.php?mainid='+id+'&code='+code+'&title='+title;
   frm.submit();
}

function selectVideoSong(frm,id,code,titleStr)
{
   var title = formatTitle(titleStr);
   frm.action = 'listsongs.php?mainid='+id+'&code='+code+'&title='+title;
   frm.submit();
}


function selectCommercial(frm,id,code,title)
{
   frm.action = 'listcommercials.php?mainid='+id+'&code='+code+'&title='+title;
   frm.submit();
}

function selectVideo(frm,id,language,code,title)
{
   if(code == 'c') {
		selectComedy(frm,id,language,title);
	}else if (code == 't')
	{
		selectTrailer(frm,id,language,title);
	}else if (code == 'e')
	{
		selectEvent(frm,id,language,title);
	}else if (code == 'p')
	{
		selectPop(frm,id,language,title);
	}else if (code == 'm')
	{
		selectMovie(frm,id,language,title);
	}else if (code == 'tv')
	{
		selectTvShow(frm,id,language,title);
	}
	else if (code == 'co')
	{
		selectCommercial(frm,id,language,title);
	}
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function formatTitle(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
