//quick'n dirty
Slideshow = Class.create({
	initialize: function() {	
		this.idx = 1;
		this.numSlides = 12;
		//this.numSlides = 5;
		this.slideLength = 5;
		this.fadeLength = 1;
		try{
			//return;
			$('slideshow').down().down().remove();
			//return;
			for(var i=0;i<this.numSlides;i++){
				var slide = new Element("div", {'id':"slide_" + i});
				var img = new Element("img", {'src':'/img/slides/slide_'+(i+1)+".jpg"});
				Element.insert( slide, img);
				Element.insert( $('slideshow').down(), slide);
				if(i==0){
					this.lastSlide = slide;
				}else{
					//slide.attributes["style"]="display:none";
					//slide.width="220"
				}
				slide.setStyle({"zIndex":666-i});
				slide.instance = this;
			}
			this.slides = $('slideshow').down().childElements();
			var self = this;
			//self.next();
			setTimeout(function(){self.next();}, this.slideLength*1000);
		}catch(e){
			window.status = "shite :(";
		}
	},
	next: function(){
		var nextSlide = $("slide_"+this.idx);
		nextSlide.style.zIndex = 667;
		//alert(nextSlide.id);
		if(this.lastSlide){
			//this.lastSlide.style.zIndex = -666;
			this.lastSlide.fade({ duration: this.fadeLength });
		}
		nextSlide.style.display = "none";
		nextSlide.appear({ duration: this.fadeLength });
		this.lastSlide = nextSlide;
		this.idx++;
		this.idx = this.idx > this.slides.length-1 ? 0:this.idx;
		
		var self = this;
		setTimeout(function(){self.next();}, this.slideLength*1000);
	}
});	
Event.observe(window, 'load', function() {
		_sildeshow = new Slideshow();
});
var popupWin = '';
function popup(url, winWidth, winHeight, centered) {
	if (!popupWin.closed && popupWin.location){
		popupWin.location.href = url;
	}
	if(centered){
		_left = ((screen.width-winWidth)/2);
		_top = ((screen.height-winHeight)/2)-50;
	}else{
		_left = 0;
		_top = 0;
	}
	scrollbarsEnabled = "1";
	props = 'toolbar=0,left=' + _left + ',top=' + _top + ',status=0,menubar=0,scrollbars=' + scrollbarsEnabled + ',resizable=0,width=' + winWidth + ',height=' + winHeight ;
	//alert(props);
	popupWin = window.open(	url,'popup_' + winWidth + "_" + winHeight, props );
	popupWin.focus();
	return false;
}
