var arr_description = new Array();
arr_description['http://www.alexanderfyrdahl.se/photos/hellaamber.jpg']='AMBER OAK<br/>Skellefteå, Sweden<br /><br />Promotional shoot for record label';
arr_description['http://www.alexanderfyrdahl.se/photos/brmc2.jpg']='BLACK REBEL MOTORCYCLE CLUB<br/>San Francisco, California<br /><br/>Magazine feature';
arr_description['http://www.alexanderfyrdahl.se/photos/paige.jpg']='PAIGE<br/>London, UK<br /><br />Photoshoot for Young Summer EP';
arr_description['http://www.alexanderfyrdahl.se/photos/nikola2.jpg']='NIKOLA SARCEVIC (Millencolin)<br/>Örebro, Sweden<br /><br />Headshot for interview';
arr_description['http://www.alexanderfyrdahl.se/photos/kungsan2.jpg']='FIN<br/>Västerås, Sweden<br /><br />Promotional shoot for upcoming release';
arr_description['http://www.alexanderfyrdahl.se/photos/portratt.jpg']='FIN<br/>Västerås, Sweden<br /><br />Individual portraits for Myspace';
arr_description['http://www.alexanderfyrdahl.se/photos/architects.jpg']='ARCHITECTS<br/>Brighton, UK<br /><br />Pre-show photo session';
arr_description['http://www.alexanderfyrdahl.se/photos/adept.jpg']='ADEPT<br/>Stockholm, Sweden<br /><br/>Myspace header';
arr_description['http://www.alexanderfyrdahl.se/photos/destine.jpg']='DESTINE<br/><br />NEW!<br/>Now featuring live photos!';
arr_description['http://www.alexanderfyrdahl.se/photos/adept3.jpg']='ADEPT<br/>Stockholm, Sweden<br /><br />Promo for the new album Death Dealers';
arr_description['http://www.alexanderfyrdahl.se/photos/wws.jpg']='WALKING WITH STRANGERS<br/>Trollhättan, Sweden<br /><br />Photoshoot for the single Dead Hands';
arr_description['http://www.alexanderfyrdahl.se/photos/weekends.jpg']='WEEK ENDS TOMORROW<br/>Strängnäs, Sweden<br /><br />Promotional pictures';

/*!
 * Scaler: Scaling background images to fill browser window with centering and aspect ratio. iPad and iPhone friendly  - v3 - 04/06/2010
 * http://klippoglim.no/
 * http://kirie.no/
 * 
 * Copyright (c) 2010 Eirik Backer
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.gnu.org/licenses/gpl-2.0.html) licenses.
 */

function Scaler(id){
	var imgs=document.getElementById(id).getElementsByTagName('img'),index=0;
	var resize=function(to){
		var to=((to==='+1'?index+1:(to==='-1'?index-1:(isNaN(to)?index:to)))%imgs.length),to=to<0?imgs.length-1:to;				//Get current index
		if(to!=index)for(var i=0,l=imgs.length;i<l;i++){imgs[i].className=i==to?'bgshow':'';imgs[i].style.display='block'}		//Change current and start loading
		var i=imgs[to],nw=Math.round(document.body.clientHeight*(i.offsetWidth/i.offsetHeight));
		i.style.width=(i.offsetWidth>i.offsetHeight&&document.body.clientWidth>nw)?'50%':nw+'px';
//Scale by css if possible
		document.getElementById('description').innerHTML=arr_description[i.src];
		return index=to;
	}

	if(window.attachEvent){window.attachEvent('onload',resize);window.attachEvent('onresize',resize)}							//Attact events IE
	else{window.addEventListener('load',resize,false);window.addEventListener('resize',resize,false)}							//Attact events others
	return resize;
};

/*
 * How to use:
 * 
 * var myscaler=Scale('id-of-the-container-element');				// Bind events and return a scale function
 * myscaler(3);														// Swap to image with index 3
 * myscaler('+1');													// Go to next image (loops to first if current is the end of gallery)
 * myscaler('-1');													// Go to previous image (loops to last if current is the first of gallery)
 * 
 * See example.js for a simple example implementation
 */
