var chatStatus = false;
var chatActive = true;
var chatLastMove = new Date();

Object.extend(Array.prototype,{
	
	currentIndex: 0,
	
	nextIndexData: function() {
		if(this.length){
			if (this.currentIndex == (this.length -1)){
				this.currentIndex = 0;
			} else {
				this.currentIndex++;
			}
			return this[this.currentIndex];
		} else {
			return false;
		}
	},
	nextIndex: function() {
		if(this.length){
			if (this.currentIndex == (this.length -1)){
				nextAlong = 0;
			} else {
				nextAlong = this.currentIndex + 1;
			}
			return nextAlong;
		} else {
			return false;
		}
	}
	
});


Effect.OpenUp = function(element) {
	if(element.id == 'shoutboxselfwrap'){
		chatStatus = true;
	}
    new Effect.BlindDown(element, arguments[1] || {});
 }

 Effect.CloseDown = function(element) {
	if(element.id == 'shoutboxselfwrap'){
		chatStatus = false;
	}
	new Effect.BlindUp(element, arguments[1] || {});
 }

 Combo = function(element) {
     element = $(element);
     if(element.style.display == 'none') { 
          new Effect.OpenUp(element, arguments[1] || {}); 
     }else { 
          new Effect.CloseDown(element, arguments[1] || {}); 
     }
 }

 updateGallerySlide = function() {
	
	theSlide = pics.nextIndexData();
	loadNextGalleryImage();

	new Effect.Opacity('slide',{duration:1,queue:'end',from:1.0,to:0,afterFinish:function(){
		
		$('slide').src = theSlide['file'];
		$('picture_link').href = "?pid="+theSlide['id'];
		new Effect.Opacity('slide',{duration:1,queue:'end',from:0,to:1.0});
		
	}});	
	
 }

 loadNextGalleryImage = function() {
	
	preload = new Image();
	preload.src = pics[pics.nextIndex()]['file'];
	
 }


Event.observe(document,"mousemove",modifyChatActive);

function modifyChatActive(){
	if(!chatActive){
		chatActive = true;
	}
	chatLastMove = new Date();
}


function TagChecker(){
	
	if($('tagset').value.match(/[a-zA-Z0-9]{3}.*/mig)){
		return true;
	} else {
		alert("Oula mon garçon! T'aurais pas oublié de mettre des tags des fois?");
		return false;
	}
}