// -----------------------------------------------------------------------------------
// 
// This page coded by Scott Upton
// http://www.uptonic.com | http://www.couloir.org
//
// This work is licensed under a Creative Commons License
// Attribution-ShareAlike 2.0
// http://creativecommons.org/licenses/by-sa/2.0/
//
// Associated APIs copyright their respective owners
//
// -----------------------------------------------------------------------------------
// --- version date: 11/28/05 --------------------------------------------------------


// get current photo id from URL
var thisURL = document.location.href;
var splitURL = thisURL.split("#");
var photoId = splitURL[1] - 1;

// if no photoId supplied then set default
var photoId = (!photoId)? 0 : photoId;

// CSS border size x 2
var borderSize = 10;

// Photo directory for this gallery
var photoDir = "photos/01/";

// Define each photo's name, height, width, and caption
var photoArray = new Array(
	// Source, Width, Height, Caption
// 01 <a href'http://gallery.comfortnetworks.nl/index.html#'>
new Array("nepal_central.jpg", 		"700", "470", "[03 August 2007] - Just landed in <a href='http://gallery.comfortnetworks.nl/index.html#14'>Kathmandu</a> by plane. Already dark on the streets I find out my dearest friend has been put into jail. The second day I arrive in the Gorkha district by bus. I stare at one of the outstanding views of Gorkha. Where is Baburam? What could have happend? "),
//02
new Array("gorkha kids.jpg", 		"542", "638", "I arrive in the remote village of Tanti Pokhari. I find Baburam, his family, everybody is so happy to see me coming back. I stayed for 13 days, talking, crying and working on Baburams farm."),
//03
new Array("baburamcorn.jpg", 		"599", "600", "Looking outside from Baburams cottage. Last month they harvested the corn, it hangs outside to dry. Also where I sleep, on the balcony. It is the Monsoon period."),
//04
new Array("bbyson.jpg", 			"900", "375", "Baby son 'Bisu' from Baburam's youngest son. "),
//05
new Array("cleancorn.jpg", 			"414", "529", "We cleaned the corn while sitting on top of it. Many hours pass."),
//06
new Array("corn.jpg", 				"600", "288", "We feed the animals, grind flower and do rituals for Lord Ganesh and Lakmsi."),
//07
new Array("gorkhaswim.jpg", 		"640", "430", "September when I returned to Gorkha some friends came along. Of the 4 people coming I was the only one who returned to Kathmandu to never see them again."),
//08
new Array("bridge.jpg", 			"480", "693", "Going back to Kathmandu. I have to walk many hours before I get out of this jungle and find a jeep somewhere that will bring me back to time."),
//09
new Array("ghr.jpg", 				"900", "264", "From where Baburam lives, The Great Himalayan Range is only a four days walk. After here Tibet is a 2 week walk. The Dalai Lama walked for two months when he was forced to escape and started his fight for the Tibetan Cause."),
//10
new Array("gorkha.jpg", 			"900", "357", "Were did this barbwire come from? I guess the Maobaden left it out here. The maoist have spread out over 20 million landmines and barricated the states with barb wire from central to west nepal."),
//11
new Array("wedding.jpg", 			"640", "169", "Just where I find the jeep, there is a pickning."),
//12
new Array("nepal_annapurna.jpg", 	"469", "650", "This girl is traveling alone with two goats, waiting for a bus to arrive. I'm waiting on the other side of the road. I'm going east where I'll find out a crisis is about to happen"),
//13
new Array("didi_santa_.jpg", 		"800", "600", "I managed to find Santa, Baburam's daughter. Her room is 3 by 4 squar meters, we're preparing her brothers birthday party. She is wearing a real rice tika. She explains to me that if I'd be interested in marring a Nepali woman I have to ask permission to the father. Why is she saying this to me?"),
//14
new Array("bramin.jpg", 			"410", "639", "Those who 'purify' themselves through philosophy are not on the true way. They are attached to words. They go from teacher to teacher, philosophy to philosophy, book to book. They grasp, they let go like a monkey letting go one branch to catch hold of another."),
//15
new Array("durbarsquargirl.jpg", 	"463", "600", "Children sitting on Durbar Squar (Kings squar)."),
//16
new Array("durbarsquarboy.jpg", 	"273", "600", "Children playing on Durbar Squar  after school."),
//17
new Array("eva_kathmandu.jpg", 		"480", "640", "In Kathmandu I meet Eva. She freaks out completely when after this visit to Durbar Squar <a href='http://gallery.comfortnetworks.nl/index.html#18'>devastating riots</a> rampaged thru town."),
new Array("ktmriot.jpg", 			"640", "307", "We get away savely. It is weird, the people seem to stay so friendly while seeing us. Of course... were not breaking any rules. "),
new Array("tukpu.jpg", 				"250", "600", "Hiding out in Little Star, Tibetan restaurant. They served THUKPA, red beans that release alcohol when you poor hot water over it."),
new Array("baktapur.jpg", 			"640", "360", "I'm passing thru Baktapur by bus. I'm on my way to visit my old friend Santosh Khanal."),
new Array("baktapur_woman.jpg", 	"480", "454", "The bus didn't show up. Drinking Chia, and wondering what these woman are talking about, while looking at me all the time. I'm trying to understand there dialect, unfortunately I don't get anything."),
new Array("baktapur_man.jpg", 		"358", "617", "Meeting old man is always bad for your health. They offer you beedies and sigarettes. It's their way of saying, I respect you. So I offer him a sigaret. He refuses."),
new Array("lordganesh.jpg", 		"379", "600", "Lord Ganesh statue at the Baktapur market. 1.4 meter high."),
new Array("changuwoman.jpg", 		"390", "474", "Woman passing time in Baktapur. Old town down the mountain of Nagakot."),
new Array("changunarayan.jpg", 		"420", "640", "Finally I arrive in Changunarayan. Home of the oldest temple in Kathmandu valley. Here I lived for 3 months painting and meditating after returning from the Vipassana monestary in 2001."),
new Array("changu.jpg", 			"480", "360", "Escaping the sun."),
new Array("changu_path.jpg", 		"588", "650", "It is so nice to remember this road. I'm on my way to surprise Santosh, I wonder if his daughter had recovered from respitory illness."),
new Array("changuritual.jpg", 		"640", "311", "Children making puja's for Lord Shiva in the evening during a festival in the Changu temple."),
new Array("olddraw.jpg", 			"480", "492", "I find copies of some old drawing I lost in the Changu Farm house in 2000."),
new Array("olddraw2.jpg", 			"439", "458", "Old Nepali man smoking tabacco."),
new Array("olddraw3.jpg", 			"640", "419", "Part of the 'Om Mani Peme Hum'"),
new Array("olddraw4.jpg", 			"394", "600", "Athletic Atonomy."),
new Array("kathmandu_market.jpg", 	"480", "656", "I'm making diner in a few days, checking out the markets. The prices went up dramaticly."),
new Array("kathmandu_ds.jpg", 		"900", "377", "I remember this temple, I slept here illigaly during the winter of 2000. This is where I got my invitation to join a tribe of Tibetans to walk back home to Tibet."),
new Array("ktmriot2.jpg", 			"800", "336", "Time to leave Nepal, situation is getting really bad. I pay Baburam to stay out of jail. They blame him on wrong acquisation, I don't know how to help him. Chandra is taking care of the situation right now."),
new Array("gino_hampi.jpg", 		"900", "446", "I have to leave now, leaving many things unfinished. Many people will wonder where I have gone so suddenly. Will I ever return? I'm sorry Baburam for leaving you, old man. I never forget your words. Everybody want to go to heaven. But nobody wants to die."),
new Array("karky.jpg", 				"800", "600", "Arrived in Varanassi INDIA on the <a href='http://gallery.comfortnetworks.nl/index.html#45'>Assi Ghat</a>. (This guy learnt me how to play djembe)"),
new Array("varanassi_band.jpg", 	"480", "360", "I'm in Varanassi for two days now, and already I met 4 musicians."),
new Array("italian.jpg", 			"480", "207", "Day three, another two musicians cross my path. Total of 7 musicians and 4 Isreali artists."),
new Array("eitansguitar.jpg", 		"640", "480", "So the deal is to paint and sell it. It became too beautifull to sell. While later on Eitan sells it - so I heard- in Arambol Goa."),
new Array("varanassi_barbera.jpg", 	"567", "650", "Chilling around Varanassi thru the night with 3 riksjaws 5 people. We planned to stay awake to see the sunrise at the Ganga. Drinking chai and eating samosa. (Hard to find 3 'o' clock at night)"),
new Array("gangavaranassimorning.jpg", "640", "583", "Had no sleep, nobody managed to stay awake to view the sunrise on the river. I was wasted from not sleeping, slept for hours in this boat."),
new Array("varanassi.jpg", 			"900", "404", "These priests play their music day and night. Could be nice if your sleepingroom wouldn't be next door."),
new Array("varanasse.jpg", 			"640", "391", "Waking up from sleeping in this boat, what is that smell? Burning flesh and inscents. Not only are they burning the dead, some dead people don't get burnt, some are just thrown in the Ganga river. Disabled people, pregnant woman, babies. They just float around, between the garbage and dead animals."),
new Array("gangavaranassi.jpg", 	"900", "497", "Well, sunrise ends here. I'm standing on the Assi ghat wondering how my Nepali friends are doing."),
new Array("italiano.jpg", 			"640", "480", "Karky (Nepali guy) restaurant. Daily hangout for the musicians."),
new Array("varanassi_room.jpg", 	"700", "574", "As it seems to become usual, everybody tends to hang around in my room. I'm listening to their travel stories, they just returned from Himachal Pradesh. That is where Manali, Parvati and Darmsala is."),
new Array("varanassi_barbera_cafe.jpg", "640", "620", "Barbera Wilding, she got a tattoo on her belly. Her 4 year old cousins first drawing. Haven't seen anything like it. She made a notebook out of my Lonely Planet Guide, at the moment I didn't expect to actually go to every place she marked."),
new Array("manalibridge.jpg", 		"800", "531", "So I left to Manali valley. Standing in between places looking for a riksjaw. I'm going to Himachal Pradesh. I don't know how long it will take, but finally I'm alone."),
new Array("manikaran.jpg", 			"381", "650", "Oktober '07 - Just woke up from sleeping with a 20 CM long spider. This town is build upon a hot spring. Nothing dies during the winter. Standing outside my bedroom, smoking a beedie looking out over the Manikaran Temple surrounded by steaming hot springs. I'm about to leave Parvati valley. I'm only hours away from Manali. But I'm not in a hurry."),
new Array("amrigirl.jpg", 			"640", "480", "I arrive in Manali, on my way thru the mountain searching for a place to sleep."),
new Array("old_manali_streetgirls.jpg", "640", "496", "Local kids hanging around completely deserted Old Manali. Where did everybody go? I learn that the last foreigners left 6 weeks before. Only locals here cleaning up their fields. Cleaning away hundreds of thousands of mariuana plants."),
new Array("eitanmanali.jpg", 		"505", "600", "Eitan advised me to go here. He stayed in Kasol. Sitting in the jungle as always chilling out. He said <a href='http://gallery.comfortnetworks.nl/index.html#56'>time</a> goes backwards here."),
new Array("vashist.jpg", 			"543", "650", "Its nice to have a hot water spring swimming pool behind the hotel. Looking out over the Great Himalayan Range. I'm thinking about going to Lai thru Darmsala as the winter is coming that part of India will be sealed because of the heavy snow fall."),
new Array("parvatti.jpg", 			"900", "463", "Daily view in Manali valley. I'm preparing to leave this place."),

new Array("gino_hampi_2.jpg", 		"800", "540", "So much to see, So much time."),
new Array("todarmsala.jpg", 		"519", "650", "I deside not to go to Darmsala. The weather is turning really cold, have no shoes, warm clothes etc. I'm leaving for <a href='http://gallery.comfortnetworks.nl/index.html#62'>GOA</a>."),
new Array("delhi2goa.jpg", 			"418", "295", "Just passed Delhi, already done about 700 km. Sitting in the train before I get terribly ill. After 2200 KM the train stops, I think I will die because of dehydration."),
new Array("mumbai_train.jpg", 		"640", "415", "Passing Mumbai by train. I get out to find water and fruits. "),
new Array("mumbai_train_2.jpg", 	"640", "421", "This train is almost one kilometer long. A city on wheels."),
new Array("mumbai_train_3.jpg", 	"900", "337", "no comment"),
new Array("butter_1.jpg", 			"570", 	"600", "Many weeks have past since I got better, arrived in GOA and made no photo's. Days before newyear, many friends, places to stay. I join up with 5 DJ's and sound engineers, they organise several Goa Trance Parties. After people heard my music they invited me to do a live performance at two events. "),
new Array("butterbeach.jpg", 		"564", "496", "Boats are taxying between the unreacheble butterfly beach and palolem beach. A small power generator is burried in the jungle. The last people leave the party. They record the music so people can <a href='http://www.artima-vj.com/mix/ButterLiveMix(01).avi' title='Download one hour of MP3 from www.artima-vj.com.'>download</a> from the net. "),
new Array("goapsy.jpg", 			"450", "600", "I design this flyer straight away and join up with a crew of extraordinary Norwegans."),
new Array("shaporafort.jpg", 		"345", "500", "The Norwegans set out to the abandoned Shapora fortress to illuminate the mind and load up with inspiration to perform at their parties. The fort is a old Portoguese defense structure, looking out over the arabian sea."),
new Array("palolemboat.jpg", 		"900", "326", "Sunrise on Palolem beach. Waking up again, at every sunrise. Together with Peter Regenworm, living on the beach together spending not more than 75 Eurocents a day."),

new Array("palolembeach.jpg", 		"900", "466", "Daily chillout inside and front of Big Bamboo beach lounch restaurant."),
new Array("celine_gino_palolem.jpg","900", "396", "It is here where I meet Celine. After a couple a days she goes back home. "),

new Array("celine_hampi.jpg", 		"900", "404", "Celine returns to India, we travel 600 KM south to visit Hampi. Relaxed next to the dam. Isreali playing 'Sunlight and Shadow' on his flute."),
new Array("hampi_water_temple.jpg", "287", "650", "Water of life, ..."),
new Array("hampi_rice.jpg", 		"640", "434", "Once more we come to Hampi to show my mother and her friend this beautifull miracle."),
new Array("mom.jpg", 				"900", "558", "To accomplish without acting and to obtain without seeking, is this what is meant by the function of Heaven?"),
new Array("gino_celine_badami.jpg", "691", "600", "My mother making this picture in Badami. We're traveling together with my mother and her friend."),
new Array("badami_chill.jpg", 		"714", "497", "Chilling out smoking beedies in one of the very hard to obtain badami hotels."),
new Array("poster_celinephoto.jpg", "487", "650", "Bollywood poster hanging in Badami."),
new Array("badami_town.jpg", 		"900", "459", "Badami, because it is not very interesting not many foreign tourists come here. Nice and 'untouched'."),
new Array("badami_view.jpg", 		"900", "183", "Badami, not very pretty. So I took a picture of the view above town."),
new Array("holycow.jpg", 			"261", "600", "When the truth was lost, its characteristics appeared.  When its characteristics were lost, benevolence appeared. When benevolence was lost, righteousness appeared.  When righteousness was lost, ceremonies appeared. Ceremonies are but the unsubstantial flowers of the truth, and the commencement of disorder."),
new Array("togokorna.jpg", 			"900", "498", "Waiting on the busstation before arriving at Gokorna. "),
new Array("mom2.jpg", 				"900", "441", "The basic thought of exploration is the beginning of something new and the release from what has been."),

// # 80
new Array("gokorna_station.jpg", 	"425", "600", "Waiting for the train at Gokarna Train Station. We need to go back to <a href='http://gallery.comfortnetworks.nl/index.html#67'>Palolem</a>, my mother and her friend are leaving for Holland. Celine and I are traveling north to Delhi."),
new Array("steveshouse.jpg", 		"688", "500", "Living in Steve's house. Playing music, cooking, reading, relaxing and talking. Thank you Steve, you are The man. "),
new Array("girls_udaipur.jpg", 		"487", "650", "We arrive in Udaipur. Girls being 'cool' with Celine's sunglasses"),
new Array("chillin_man.jpg", 		"900", "534", "Locals resting in a temple in the center of Udaipar. Such a beautifull day, so filled with love."),
new Array("udaipurcity.jpg", 		"900", "300", "Udaipur city. James Bond's movie 'Octopussy' was filmed here. Riches destroy the foolish."),
new Array("udaipur.jpg", 			"480", "360", "Sitting inside the old palace in Udaipur."),
new Array("celine_gino.jpg", 		"298", "650", "Celine and me sitting in a boat again. We like boats. Udaipur lake."),
new Array("sunset_udaipur.jpg", 	"900", "551", "He who knows the part which the Heavenly in him plays, and knows also that which the Human in him ought to play, has reached the perfection of knowledge."),
new Array("gino.jpg", 				"298", "600", "Celine and me strive further north, to settle in Puskar. Riding a Camel, feeling really comfortable... NOT!"),
new Array("children_puskar.jpg", 	"900", "268", "Street children living outside Puskar. They all start to dance when I play the drum."),
new Array("thinking.jpg", 			"450", "600", "You have two possibilities: action and contemplation. Both lead to the same way."),
new Array("celine_delhi.jpg", 		"433", "650", "Arrived in Delhi to meet with Agna <a href='http://aggna.blog.onet.pl/' title='if you can read Polsky...'>aggna.blog.onet.pl</a>, Krzysztof and Vishal. Feels like family."),
new Array("gino_delhi.jpg", 		"200", "650", "Amazing how one city can give such different experiences."),
new Array("vishal_dehli.jpg", 		"641", "550", "Krzysztof and Vishal. These days seem to pass slowely. I leave for Holland within 2 days. Celine is going back to Geneva."),
new Array("celine_gino_delhi.jpg", 	"900", "342", "I'll miss you."),
new Array("celine_gino_delhi_2.jpg", "900", "254", "Agna and Krzysztof tell about their travel and show us their photo's."),
new Array("agna_friend.jpg", 		"286", "650", "Krzysztof Urbanski. <br><br>Each human being was given a virtue; the ability to choose. Anyone who fails to use this virtue transforms into a curse, and others will choose for them. <br><center> - THE END - <br><a href='http://www.comfortnetworks.nl/' title='Return to COMFORTNETWORKS main site'>return to home page</a></center>")
);

// Number of photos in this gallery
var photoNum = photoArray.length;

/*--------------------------------------------------------------------------*/

// Additional methods for Element added by SU, Couloir
Object.extend(Element, {
	getWidth: function(element) {
   	element = $(element);
   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   	element = $(element);
    	element.style.height = h +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

/*--------------------------------------------------------------------------*/

var Slideshow = Class.create();

Slideshow.prototype = {
	initialize: function(photoId) {
		this.photoId = photoId;
		this.photo = 'Photo';
		this.photoBox = 'Container';
		this.prevLink = 'PrevLink';
		this.nextLink = 'NextLink';
		this.captionBox = 'CaptionContainer';
		this.caption = 'Caption';
		this.counter = 'Counter';
		this.loader = 'Loading';
	},
	getCurrentSize: function() {
		// Get current height and width, subtracting CSS border size
		this.wCur = Element.getWidth(this.photoBox) - borderSize;
		this.hCur = Element.getHeight(this.photoBox) - borderSize;
	},
	getNewSize: function() {
		// Get current height and width
		this.wNew = photoArray[photoId][1];
		this.hNew = photoArray[photoId][2];
	},
	getScaleFactor: function() {
		this.getCurrentSize();
		this.getNewSize();
		// Scalars based on change from old to new
		this.xScale = (this.wNew / this.wCur) * 100;
		this.yScale = (this.hNew / this.hCur) * 100;
	},
	setNewPhotoParams: function() {
		// Set source of new image
		Element.setSrc(this.photo,photoDir + photoArray[photoId][0]);
		// Set anchor for bookmarking
		Element.setHref(this.prevLink, "#" + (photoId+1));
		Element.setHref(this.nextLink, "#" + (photoId+1));
	},
	setPhotoCaption: function() {
		// Add caption from gallery array
		Element.setInnerHTML(this.caption,photoArray[photoId][3]);
		Element.setInnerHTML(this.counter,((photoId+1)+'/'+photoNum));
	},
	resizePhotoBox: function() {
		this.getScaleFactor();
		new Effect.Scale(this.photoBox, this.yScale, {scaleX: false, duration: 0.3, queue: 'front'});
		new Effect.Scale(this.photoBox, this.xScale, {scaleY: false, delay: 0.5, duration: 0.3});
		// Dynamically resize caption box as well
		Element.setWidth(this.captionBox,this.wNew-(-borderSize));
	},
	showPhoto: function(){
		new Effect.Fade(this.loader, {delay: 0.5, duration: 0.3});
		// Workaround for problems calling object method "afterFinish"
		new Effect.Appear(this.photo, {duration: 0.5, queue: 'end', afterFinish: function(){Element.show('CaptionContainer');Element.show('PrevLink');Element.show('NextLink');}});
	},
	nextPhoto: function(){
		// Figure out which photo is next
		(photoId == (photoArray.length - 1)) ? photoId = 0 : photoId++;
		this.initSwap();
	},
	prevPhoto: function(){
		// Figure out which photo is previous
		(photoId == 0) ? photoId = photoArray.length - 1 : photoId--;
		this.initSwap();
	},
	initSwap: function() {
		// Begin by hiding main elements
		Element.show(this.loader);
		Element.hide(this.photo);
		Element.hide(this.captionBox);
		Element.hide(this.prevLink);
		Element.hide(this.nextLink);
		// Set new dimensions and source, then resize
		this.setNewPhotoParams();
		this.resizePhotoBox();
		this.setPhotoCaption();
	}
}

/*--------------------------------------------------------------------------*/

// Establish CSS-driven events via Behaviour script
var myrules = {
	'#Photo' : function(element){
		element.onload = function(){
			var myPhoto = new Slideshow(photoId);
			myPhoto.showPhoto();
		}
	},
	'#PrevLink' : function(element){
		element.onmouseover = function(){
			soundManager.play('beep');
		}
		element.onclick = function(){
			var myPhoto = new Slideshow(photoId);
			myPhoto.prevPhoto();
			soundManager.play('select');
		}
	},
	'#NextLink' : function(element){
		element.onmouseover = function(){
			soundManager.play('beep');
		}
		element.onclick = function(){
			var myPhoto = new Slideshow(photoId);
			myPhoto.nextPhoto();
			soundManager.play('select');
		}
	},
	a : function(element){
		element.onfocus = function(){
			this.blur();
		}
	}
};

// Add window.onload event to initialize
Behaviour.addLoadEvent(init);
Behaviour.apply();
function init() {
	var myPhoto = new Slideshow(photoId);
	myPhoto.initSwap();
	soundManagerInit();
}
