if (Mediastruktur == undefined) var Mediastruktur = {};

/*

Global JavaScript Document for XL-Studios Stockholm
Powered by MEDIASTRUKTUR

*/

var xlpop;

/* Plain function for opening small information windows, like terms */
function openInfo(url, highresWidth, highresHeight) {
	var width = highresWidth;
	var height = highresHeight;
	var screenX = (screen.availWidth-width)/2;
	var screenY = (screen.availHeight-height)/2; 
	xlpop = window.open(url, 'xlstudiosinfo', 'width='+width+',height='+height+',status=no,resizable=yes,scrollbars=yes,left='+screenX+',screenX='+screenX+',top='+screenY+',screenY='+screenY+'');
	
	return false;
}


/*
 *	Class	Mediastruktur.ImageSlider
 *	Requires and cred: Prototype.js 1.6, Script.aculo.us 1.8.1
 *
 *	Author: filip@mediastruktur.se
 */
Mediastruktur.ImageSlider = Class.create({
	initialize: function() {
		try {
			/* Container to search and append click events for */
			this.container 			= $("thumbnails");
			this.slider 			= $("slider");
			this.bigImageContainer 	= $("displayImage");
			this.anchorElements 	= $A(this.container.getElementsByTagName("a"));
			this.defaultWidth		= 980;
			
			this.tempElement;
			/* For each anchor in #thumbs */
			this.anchorElements.each(function(item, i) {
				/* IE-FIX */
				item = $(item);
				/* Continue ... */
				item.writeAttribute("rel", "slider-"+i);
				item.addClassName("carousel-jumper");
				
				if (i != 0) {	
					/* Create image and append to DIV */
					this.tempDiv = new Element('div', {"class":"slide", 'id':"slider-"+i});
					this.tempDiv.appendChild(new Element('img', {'src': item.href}));
					
					/* Append to bigImageContainer */
					this.bigImageContainer.appendChild(this.tempDiv);
				}
			}, this);
			/* Set up Carousel for sliding functionality */
			this.bigImageContainer.setStyle({width:this.defaultWidth*this.anchorElements.size()+"px"});
			this.carousel = new Carousel($("slider"), $$(".slide"), $$("a.carousel-jumper"), {duration: 0.8});
		} catch(e) {
			/* Do nothing */
		}
	},
	/* OnMouseOver */
	onClickEvent: function(event) {
		this.img			= Event.element(event);
		this.a 				= Event.element(event).up("a");
		this.href 			= this.a.href;
		
		
		/* Stop anchors event, like "return false" */
		Event.stop(event);
	}
});

/* OnLoad */
Event.observe(window, 'load', function() {
	new Mediastruktur.ImageSlider();
});

