var videos = new Array(
	{
		title:'Kumarettante Onam',
		embed:'<embed src="http://www.youtube.com/v/QvWWX_0I3zQ&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>',
		descr:'Kumarettante Onam. A music video + short film',
		sdescr:"Kumarettan and his conscience.",
		category:"song"
	},
	{
		title:'Kanmani Song Video',
		embed:'<embed src="http://www.youtube.com/v/hJX1vCk7amY&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>',
		descr:'Kanmani. The music video. Watch the video thats doing heavy rounds on the internet.',
		sdescr:"Infatuation transforms a little girl's world.",
		category:"song"
	},
	{
		title:'Kunnimanikal',
		embed:'<embed src="http://www.youtube.com/v/AVstZBgXoJs&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>',
		descr:'Nostalgia Unleashed. A story that explores childhood friendhips that still carries strong over the years.',
		sdescr:'Nostalgia unleashed',
		category:"song"
	}
);

function showVideo(i) {
	$('tv').innerHTML = videos[i]["embed"];
	$('tvDescr').innerHTML = videos[i]["descr"];
}

function videoItem(i) {
	var vitem = ('<a href="#" onClick="javascript:showVideo(' + i + ')">');
	vitem += ('<div class="videothumb">');
	vitem += ('<p class="heading">' + videos[i]["title"] + '</p>');
	vitem += (videos[i]["sdescr"]);
	vitem += ('</div>');
	vitem += ('</a>');
	return vitem;
}

function listAll(category) {
	var listOrder = [0, 1, 2];
	var first = null;
	for (var i = 0; i < listOrder.length; i++) {
		if (category == 'all' || category == videos[listOrder[i]]["category"]) {
			$('videolist').innerHTML += videoItem(listOrder[i]);
			if (first == null) first = listOrder[i];
		}
	}
	if (category == 'all' || first == null) {
		return 0;
	} else { 
		return first;
	}
}

function initVideoPage(category) {
	showVideo(listAll(category));
}