/*  gallery.js
 *  (c) 2007 mech <mech@kiwi2do.com>
 *
 *  Video gallery
/*--------------------------------------------------------------------------*/

// namespacing to avoid library collision
var Threesixzero = new Object();

// short description for all local video gallery
Threesixzero.Gallery = {
	desc: {
	  "Food Specialists": "<h1>Food Specialists (mediacorp Ch U) 10 x 30 mins</h1><p>A food stylist. A food photographer. A Food caterer. A fake-food sculptor. Get into the world of these food related occupations to get an inside knowledge of some quirky food businesses!</p>",
	  "Love Singapore": "<h1>Love Singapore (Mediacorp CH U) 8 x 30 mins</h1><p>Which places in Singapore are most endearing to its people and residents? In each episode 3 Singaporeans and residents share with us why a certain place in Singapore holds a special meaning in their hearts.</p>",
	  "Stars For a Cause": "<h1>Stars For a Cause (Mediacorp CH U) 10 x 47 mins</h1><p>Stars For a Cause takes some well known local and regional celebrities away to various parts of Asia for some voluntary works. </p>",		
	  "My World My Blog Season 1": "<h1>My World My Blog Season 1 (Mediacorp Channel U) 10 x 30 mins</h1><p>A fully dramatized documentary series, My World My Blog explores the issues faced by our youths today. This series garnered a few International Awards, including Best Docudrama at the New York Festival.</p>",
	  "Lifewatch": "<h1>Lifewatch (Mediacorp Ch5) 8 x 30 mins</h1><p>An award-winning reality-doc series that takes viewers right into the insides of Singapore’s largest public hospital, Singapore General Hospital, for a real taste of the actions and dramas that take place every minute and second of the day.</p>",
	  "So Simple 2": "<h1>So Simple 2</h1><p>The popular So Simple returns in a new season with an expansion from the original concept of finding joy in DIY to include the concept of LOHAS in health, fitness, environment, personal development, sustainable living and social justice. Join host Peifen as she travels to Australia, Taiwan and Japan as she experienced with her the sparks, joys and sometimes, disappointments of learning to live a naturally creative life, everyday.</p>",
	  "Twilight Years": "<h1>Twilight Years</h1><p>In this 10 parts series documentary, we feature 2 different elderly Asians from two different countries. Coming from different background, each character may share certain commonness in their views towards certain issues yet both have unique personalities, traits and a whole set of problems and issues faced.</p>",
	  "Design Asia": "<h1>Design Asia</h1><p>Design Asia goes behind the products and finished works to see the real masters at work- how did such a design come about? How did these designers manage to conceive and create an intriguing idea to begin with? How have these designs come to be seen as uniquely Asian in spirit but utterly modern in its outlook?</p>",
		"Chef In Black": "<h1>Chef in Black (Arts Central) Season 1: 10 x 24 mins</h1><p>In season 1, our culinary explorer, Emmanuel Stroobant, goes on a motor cycle journey to the various nooks and crannies of Singapore to discover the food that defines Singapore cooking; from the fanfare of the hawker centers to culturally diversified areas like Little India and Chinatown, from the secrets of home cooked Peranakan cuisine to the most expensive designer Chinese restaurant in town. Emmanuel will then create his own versions of the same cuisine.</p><p>* to enquire about sales and distribution for the above programmes please <a href='contact.html'>contact us</a></p>",
		"Chef In Black Bangkok": "<h1>Chef in Black Bangkok (Arts Central) Season 2: 11 x 24 mins</h1><p>In season 2 Emmanuel travels beyond Singapore to places like Macau, Hong Kong, Thailand, Vietnam and Malaysia to explore more wonderful cuisines from South East Asia.</p><p>* to enquire about sales and distribution for the above programmes please <a href='contact.html'>contact us</a></p>",
		"Find Me A Singaporean": "<h1>Find Me A Singaporean (Mediacorp Channel U) 10 x 24 mins</h1><p>A very popular series hosted by Berlinda Lee, Find Me A Singaporean travels to far flung places like Kenya, Peru, Norway, Fugong, Papua New Guinea to find that Singaporean residing there.</p>",
		"King of Kitchens": "<h1>King of Kitchens (Mediacorp Channel U) 10 x 24 mins</h1><p>Launched in December 2005 this food based reality-tv showcases award-winning Chef Sam Leong in his most natural, honestly brutal self! This hugely popular series takes viewers on an intimate journey into the challenging, fun, sometimes agonizing and often hilarious moments of a well known celebrity chef Sam Leong where Sam's creativity will be keenly tested and challenged as he strives to whip up a dish for a myriad of audiences in Asia!</p>",
		"So Simple": "<h1>So Simple (Mediacorp Channel U) 13 x 24 mins</h1><p>As more people become conscious of their health and total well-being, businesses such as spas, slimming centres, fitness gyms became overwhelmingly popular overnight. In the midst of these healthy but commercialized activities, more people are becoming increasingly aware of a more organic and natural way of total well-being. These lifestyles - known also as Simple Living or Slow Living, promote a wholesome, back to basics and nature kind of well-being, which not only benefits oneself but the entire environment as well.</p><p>This series which debut on Mediacorp Channel U aims to showcase these new lifestyle concepts. Viewers will realize, and come to appreciate, that total well-being need not cost a bomb and in fact, could be easily attained at home!</p>",
		"Waxing Lyrical": "<h1>Waxing Lyrical (Arts Central)</h1><p>Waxing Lyrical is a visual experimentation with poetry - where instead of just words, we visualize some of the works by local poets into some short visual pieces.</p>",
		"Black Roses of Bangkok": "<h1>Black Roses of Bangkok (National Geographic Channel) 1 x 47 mins</h1><p>Using a character-driven narrative, this documentary tells the compelling stories of the two female boxers on their journey to clinch a world title. The documentary will intertwine the stories of two leads, &quot;Nong Mai&quot; and &quot;Siriporn&quot;, one fighting from outside prison and the other from within the walls of prison, to a new life. The documentary follows &quot;Nong Mai&quot; on her 1st match after she is released from jail to her 1st world title match challenge. The documentary also captured &quot;Siriporn&quot; on her bid for the world boxing title.</p>",
		"Brat Camp China": "<h1>Brat Camp China (National Geographic Channel) 1 x 47 mins</h1><p>An ex-army veteran started this atypical school which &quot;moves&quot; throughout mainland China, all year round. The kids - delinquents from age 8 to 16 - are taught en route as they marched on foot for 1000km. The kids wear camouflage uniforms, sleep in trucks and are expected to carry out orders like dutiful soldiers. With no pocket money, no mummies to wash their clothes and serve them meals these kids are forced to metamorphose and take responsibility for their lives.</p><p>Over a span of 1 year, this emotionally-packed verite-style documentary tracks the journey of 3 students, each from different starting points moving towards a common destination where they will discover a life-changing experience.</p>",
		"Culinary China - Food for Thought": "<h1>Culinary China (Discovery Channel) 2 x 47 mins</h1><p>It is widely agreed that China has one of the world's great cuisines. It is perhaps not so commonly known that Chinese food culture had shaped the way some of the people are eating today with its food inventions and discoveries thousands of years ago.</p><p><strong>Culinary China: Food for Thought</strong> gives an insight into the inventions of Chopsticks, Hotpot, Vinegar, Beancurd and Noodles. What is it that drives the Chinese to create magnificence out of raw food ingredients? What are some of the food inventions that mark the Chinese character?</p><p>* to enquire about sales and distribution for the above programmes please <a href='contact.html'>contact us</a></p>",
		"Culinary China - The Heavenly Foods": "<h1>Culinary China (Discovery Channel) 2 x 47 mins</h1><p>It is widely agreed that China has one of the world's great cuisines. It is perhaps not so commonly known that Chinese food culture had shaped the way some of the people are eating today with its food inventions and discoveries thousands of years ago.</p><p><strong>Culinary China: The Heavenly Foods</strong> takes viewers into the world of the people whose lives are closely connected to the four most expensive and sought after foods on earth. Meet Lee Lian Yan, one of the bravest men in China, who climb as high as 60 metres, without any form of support, risking his life for one thing- the bird's nests that could be found in many hidden parts of the caves of Huaiji. Meet Yeung Koon Yat, the man who revolutionized and made a great wealth out of Abalone, and discover the greatest secret of his Abalone. Dive with Master Lee into the sea of north-eastern coast of China to search for the sea cucumbers and abalones. Meet Master Wei the chef who canonized the way to savor Shark's Fins.</p><p>* to enquire about sales and distribution for the above programmes please <a href='contact.html'>contact us</a></p>",
		"A Chinese Feast": "<h1>A Chinese Feast (Discovery Channel) 1 x 47 mins</h1><p>Go on a gastronomic journey across centuries as you feast your eyes on lavish Chinese banquets. This documentary, first aired on Discovery, explores the Chinese psyche for food, going back into history to track down ancient Chinese dietary habits and returning to modern day China to witness the ever growing Chinese appetite.</p><p>* to enquire about sales and distribution for the above programmes please <a href='contact.html'>contact us</a></p>"
	},
	
	removeGalleryCurrentClass: function(className) {
		var currentList = document.getElementsByClassName(className, $('gallery'));
		$A(currentList).each(function(node) {
			node.removeClassName(className);
		});
	}
}

Threesixzero.prepareWorks = function() {
	var localList = $('gallery').getElementsByTagName('a');
	
	$A(localList).each(function(node) {
		var header = node.firstChild.getAttribute('alt');
		var shortDesc = Threesixzero.Gallery.desc[header] || "No description currently";	
		
		Event.observe(node, "click", function() {
			// first, remove all the gallery's current style
			Threesixzero.Gallery.removeGalleryCurrentClass('current');
			
			if (node.parentNode) {
				// IE 6 encounter error if use node.parentNode.addClassName('current')
				node.parentNode.className = 'video current';
			}
			
			var container = $('shortdesc');
			
			container.innerHTML = shortDesc;
			
			var imagePath = node.firstChild.src.split('/')[node.firstChild.src.split('/').length - 1];
			var videoSrc = imagePath.gsub('.jpg|.gif|.png', '_stream.mov');
						
			$('video-content').getElementsByTagName('iframe')[0].src = "video.html?mode=show&src=" + videoSrc;
		});
	});
	
}

// Simon Willison's addLoadEvent
function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) { // for IE 7 runtime error
				oldonload();
			}
			
			func();
		}
	}
}

// using Dean Edwards - see http://dean.edwards.name/weblog/2006/06/again/
function init() {
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	
	if (_timer) clearInterval(_timer);
	
	// do stuff
	Threesixzero.prepareWorks();
}

/* for Mozilla and Opera 9 */
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
}

/* for IE */
/*@cc_on @*/
/*@if (@_win32)
	document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
	var script = document.getElementById("__ie_onload");
	script.onreadystatechange = function() {
		if (this.readyState == "complete") {
			init();
		}
	};
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) {
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			init();
		}
	}, 10);
}

/* for other browsers */
window.onload = init;


// all onload operation here
// addLoadEvent(Threesixzero.prepareWorks)