(function(){

  var eventMatchers = {
    'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
    'MouseEvents': /^(?:click|mouse(?:down|up|over|move|out))$/
  }
  var defaultOptions = {
    pointerX: 0,
    pointerY: 0,
    button: 0,
    ctrlKey: false,
    altKey: false,
    shiftKey: false,
    metaKey: false,
    bubbles: true,
    cancelable: true
  }

  Event.simulate = function(element, eventName) {
    var options = Object.extend(defaultOptions, arguments[2] || { });
    var oEvent, eventType = null;

    element = $(element);

    for (var name in eventMatchers) {
      if (eventMatchers[name].test(eventName)) { eventType = name; break; }
    }

    if (!eventType)
      throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');

    if (document.createEvent) {
      oEvent = document.createEvent(eventType);
      if (eventType == 'HTMLEvents') {
        oEvent.initEvent(eventName, options.bubbles, options.cancelable);
      }
      else {
        oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
          options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
          options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
      }
      element.dispatchEvent(oEvent);
    }
    else {
      options.clientX = options.pointerX;
      options.clientY = options.pointerY;
      oEvent = Object.extend(document.createEventObject(), options);
      element.fireEvent('on' + eventName, oEvent);
    }
    return element;
  }

  Element.addMethods({ simulate: Event.simulate });
})()

function printError(string){
    $('result').replace('<span id="result" style="display: none; color: red;"/>'+ string +'</span>');
    var elt = $('result');
    if (!elt.visible()){
	elt.appear({ duration: 0.3 }).pulsate({ duration: 10.0, queue: 'end'}).fade({ duration: 0.3, queue: 'end' });
    }
    return;
}

Ajax.MyRequest = Class.create(Ajax.Request, {
  initialize: function($super, url, options) {
    $super(url,_options(options));
  }
});

Ajax.MyUpdater = Class.create(Ajax.Updater, {
  initialize: function($super, container, url, options) {
    $super({success:container},url,_options(options));
  }
});

function _options(options) {
  return Object.extend({
     method: 'post',
     onException: function(request,exception) {
      	 printError('error "'+ exception +'" append when lunch "'+ request +'"');
      	 return true;
     },
     on401: function(t) {
	 printError('401 : Your session expired. reload image !');
	 return true;
     },
     on404: function(t) {
	 printError('404 : Not Found !');
	 return true;
     },
     on500: function(t) {
	 printError('500 : Internal server error !');
	 return true;
     },
     on503: function(t) {
	 printError('503 : Service unavailable !');
	 return true;
     },
     onFailure: function(t) {
	 printError('Unatended error occur on : ' + t.status + ' => ' + t.statusText);
	 return true;
     }
  }, options || {});
}

Ajax.PeriodicalRequester = Class.create(Ajax.Base, {
    initialize: function($super, url, options) {
    $super(options);
    this.onComplete = this.options.onComplete;

    this.frequency = (this.options.frequency || 2);
    this.decay = (this.options.decay || 1);
    this.maxFrequency = (this.options.maxFrequency || 3600);

    this.updater = { };
    this.url = url;
    this.change = false;

    this.start();
  },

  start: function() {
    this.options.onComplete = this.updateComplete.bind(this);
    this.onTimerEvent();
  },

  stop: function() {
    this.updater.options.onComplete = undefined;
    clearTimeout(this.timer);
    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
  },

  updateComplete: function(response) {
    if (this.options.decay) {
      this.decay = (!this.change ?
        this.decay * this.options.decay : 1);
      this.change = false;
      this.lastText = response.responseText;
    }
    this.timer = this.onTimerEvent.bind(this).delay((this.decay * this.frequency) >= this.maxFrequency ?
	    this.maxFrequency : this.decay * this.frequency );
  },

  onTimerEvent: function() {
    this.updater = new Ajax.MyRequest(this.url, this.options);
  }
}); // Ajax.PeriodicalRequester

Effect.MoveX = Class.create(Effect.Base, {
    initialize: function(element) {
      this.element = $(element);
      if (!this.element) throw(Effect._elementDoesNotExistError);
      var options = Object.extend({
        x:    0,
        mode: 'relative'
      }, arguments[1] || { });
      this.start(options);
    },
    setup: function() {
      this.element.makePositioned();
      this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
      if (this.options.mode == 'absolute') {
        this.options.x = this.options.x - this.originalLeft;
      }
    },
    update: function(position) {
      this.element.setStyle({
        left: (this.options.x  * position + this.originalLeft).round() + 'px'
      });
      var minX = document.viewport.getWidth()-$('layer0').getWidth();
      var delta = ($('layer0').positionedOffset().left).abs()/minX.abs();
      document.scrollSlider.setValue(delta);
    }
});

Position.withinViewport = function(element, x, y) {
    this.xcomp = x;
    this.ycomp = y;
    this.offset = Element.viewportOffset(element);

    return (y >= this.offset[1] &&
            y <  this.offset[1] + element.offsetHeight &&
            x >= this.offset[0] &&
            x <  this.offset[0] + element.offsetWidth);
};

var parallaxScroll = Class.create({

    initialize: function(layers, time) {
    	this.time = time;
    	this.layers = $$(layers)
    	this.nbLayers = this.layers.size();
    	this.direction = true;
    	this.scrollOn = false;
    	this.startScroll();
    },

    startScroll: function() {
	if (!this.scrollOn) {
	    this.scrollOn = true;
	    	this.layers.each(function(layer, index){
        	    var minX = document.viewport.getWidth()-layer.getWidth();
        	    var delta = (layer.positionedOffset().left).abs()/minX.abs();
        	    var moveObj = {
        		x: ((this.direction)?minX:0),
        		mode: 'absolute',
        		duration: (this.time*(((this.direction)?1-delta:delta))),
        		transition: Effect.Transitions.linear,
        		queue: { scope: 'parallaxMove', position: 'parallel', limit: this.nbLayers }
        	    };
        	    if (index==0) Object.extend( moveObj, { afterFinish: this.reverseScroll.bind(this) });
        	    new Effect.MoveX(layer, moveObj);
        	}.bind(this));
	}
    },

    reverseScroll: function() {
	this.stopScroll();
	(this.direction)? this.direction = false : this.direction = true;
	this.startScroll();
    },

    stopScroll: function() {
	Effect.Queues.get('parallaxMove').each(function(effect){ effect.cancel(); });
	if (this.scrollOn) this.scrollOn = false;
    }
});

var showContext = Class.create({

    initialize: function(element, event) {
    	this.elem = element;
    	this.event = event;
    	this.container = new Element('div', { className: 'context', style: 'display:none' });
    	this.anch = new Element('a', { href: this.elem.href, title: this.elem.down().innerHTML, className: 'contextA' }).insert('Télécharger "'+this.elem.down().innerHTML+'"');
	$(document.body).insert(this.container.insert(this.anch));
	var x = this.event.pointerX(),
		y = this.event.pointerY(),
		vpDim = document.viewport.getDimensions(),
		elDim = this.container.getDimensions(),
		elOff = {
			left: ((x + elDim.width) > vpDim.width
				? (vpDim.width - elDim.width) : x) + 'px',
			top: ((y + elDim.height) > vpDim.height
				? (y - elDim.height) : y) + 'px'
		};
	this.container.setStyle({ position: 'absolute', zIndex: '9000' }).setStyle(elOff);
    	this.container.appear({ duration: 0.4 });
    	document.observe('click', function(e) {
    	    if (this.container.visible() && e.target != this.anch) {
    		this.container.fade({ duration: 0.4, afterFinish: this.container.remove() });
    	    }
	}.bind(this));
    	$('mask').observe('click', function(e) {
    	    if (this.container.visible() && e.target != this.anch) {
    		this.container.fade({ duration: 0.4, afterFinish: this.container.remove() });
    	    }
	}.bind(this));
    }

});

var starField = Class.create({

    initialize: function(element, nbStar, timeOut){
    	this.x = [];
    	this.y = [];
    	this.z = [];
    	this.R = Math.random;
    	this.nbStar = nbStar;
    	this.timeOut = timeOut;
	for (i = this.nbStar; i--; )
	    $(element).insert('<span id="star_'+ i +'" class="star"></span>');
	setInterval(this.moveStars.bind(this), this.timeOut);
     },

     moveStars: function() {
	 for (i = this.nbStar; i--; ) {
	     var a = 50 + this.x[i] * this.z[i];
	     var b = 50 + this.y[i] * this.z[i]++;
	     if (! a | a < 0 | a > 99 | b < 0 | b > 99) {
		 this.x[i] = this.R() * 2 - 1;
		 this.y[i] = this.R() * 2 - 1;
		 this.z[i] = 9;
	     } else {
		 $('star_'+ i).setStyle({
		 	left: a +'%',
		 	top: b +'%'
		 });
	     }
	 }
     }
});

var chatScroll = Class.create({

    initialize: function(scrollContainer){
    	this.bottomThreshold = 20;
    	this.scrollContainer = scrollContainer;
    },

    activeScroll: function(firstScroll){
	var scrollDiv = $(this.scrollContainer);
	var currentHeight = 0;
	if (scrollDiv.scrollHeight > 0)
	    currentHeight = scrollDiv.scrollHeight;
	else if (scrollDiv.offsetHeight > 0)
            currentHeight = scrollDiv.offsetHeight;
	if ((currentHeight - scrollDiv.scrollTop - ((scrollDiv.style.pixelHeight) ? scrollDiv.style.pixelHeight : scrollDiv.offsetHeight) < this.bottomThreshold)||firstScroll)
            scrollDiv.scrollTop = currentHeight;
        scrollDiv = null;
    }
});

function periodicalyCheckUpdate() {
    document.periodicalRequest = new Ajax.PeriodicalRequester('ajax/ajaxCheckChatUpdt.php', {
	frequency: 1.5,
	maxFrequency: 20,
	decay: 1.2,
	postBody: $H({ lastCheck: $F('loadedAt'), checkChatUpdt: 'TRUE' }).toQueryString(),
	requestHeaders: {Accept: 'application/json'},
	onSuccess: function(transport) {
	    var resultUpdt = transport.responseText.evalJSON(true);
	    document.periodicalRequest.options.postBody = $H({ lastCheck: resultUpdt.lC, checkChatUpdt: 'TRUE' }).toQueryString();
	    if (resultUpdt.nMsg) {
		document.periodicalRequest.change = true;
		updtMsg(resultUpdt.pC);
	    }
    	}
    });
} // periodicalyCheckUpdate()

function updtMsg(lastCheck){
    new Ajax.MyUpdater('msgDiv', 'ajax/ajaxGetNewMsg.php', {
	postBody: $H({ lastCheck: lastCheck, getNewMsg: 'TRUE' }).toQueryString(),
	insertion: 'bottom',
    	onComplete: function() {
		document.divScroll.activeScroll(false);
    	}
    });
}

function setCookie(sName, sValue) {
    var today = new Date(), expires = new Date();
    expires.setTime(today.getTime() + (365*24*60*60*1000));
    document.cookie = sName + "=" + sValue + ";expires=" + expires.toGMTString();
}

function getCookie(sName) {
    var oRegex = new RegExp("(?:; )?" + sName + "=([^;]*);?");

    if (oRegex.test(document.cookie)) {
            return decodeURIComponent(RegExp["$1"]);
    } else {
            return null;
    }
}

function getChatColorFromCookie() {
    if(navigator.cookieEnabled){
	var chatColor = getCookie('chatColor');
	if (chatColor != null) {
	    $('colorField').value = chatColor;
	    var fieldStyle = { color: "#"+chatColor };
	    $('pseudoField').setStyle(fieldStyle);
	    $('msgField').setStyle(fieldStyle);
	}
    }
}

function setChatColorToCookie(chatColor) {
    if(navigator.cookieEnabled && chatColor != null && chatColor != '')
	setCookie('chatColor', chatColor);
}

function startChat(){
    getChatColorFromCookie();
    $('chatBox').setStyle({
	width: document.viewport.getWidth()+"px",
	height: document.viewport.getHeight()+"px",
	top: document.viewport.getHeight()+"px",
	opacity: "0.9"
    });
    var msgDivHeight = document.viewport.getHeight()-($('chatFormDiv').getHeight()+$('closeChat').getHeight()+120);
    $('msgDiv').setStyle({ height: msgDivHeight+"px" });
    $('chatBox').show();
    new Effect.Move('chatBox', { x: 0, y: 0, mode: 'absolute', duration: 0.8 });
    periodicalyCheckUpdate();
    new Control.ColorPicker('colorField', { swatch: 'colorBox', onUpdate: function(value){
	var fieldStyle = { color: "#"+value };
	$('pseudoField').setStyle(fieldStyle);
	$('msgField').setStyle(fieldStyle);
	setChatColorToCookie(value);
    } });
    document.divScroll = new chatScroll('msgDiv');
    document.divScroll.activeScroll(true);
    if($('chatForm')){
	var pseudoFieldLv = new LiveValidation('pseudoField', { validMessage: '', onlyOnSubmit: true, insertAfterWhatNode: 'submitMsg' });
	pseudoFieldLv.add( Validate.Presence, { failureMessage: '' } );
	pseudoFieldLv.add( Validate.Format, { pattern: /^[a-z0-9\-_\.@éèçàùëïâîô]+$/i, failureMessage: 'Pseudo : charactère(s) invalide(s).' } );
	pseudoFieldLv.add( Validate.Length, { minimum: 3, maximum: 15, tooShortMessage: 'Pseudo : 3 charactères min.', tooLongMessage: 'Pseudo : 15 charactères max.' } );
	var msgFieldLv = new LiveValidation('msgField', { validMessage: '', onlyOnSubmit: true, insertAfterWhatNode: 'submitMsg' });
	msgFieldLv.add( Validate.Presence, { failureMessage: '' } );
	msgFieldLv.add( Validate.Format, { pattern: /^[a-z0-9 '\-_@\!\.,;\?\:\(\)\#\^éèêçàùëïâîô€]+$/i, failureMessage: 'Message : charactère(s) invalide(s).' } );
	msgFieldLv.add( Validate.Length, { minimum: 2, maximum: 255, tooShortMessage: 'Message : 2 charactères min.', tooLongMessage: 'Message : 255 charactères max.' } );
	$('chatForm').observe('submit', function(e) {
	    e.stop();
	    if (pseudoFieldLv.validate() && msgFieldLv.validate()) {
		new Ajax.MyRequest('ajax/ajaxSendMsg.php', {
		    requestHeaders: {Accept: 'application/json'},
		    parameters: $('chatForm').serialize(),
		    onCreate: function() {
			$('chatForm').disable();
			document.periodicalRequest.stop()
		    },
		    onComplete: function(transport) {
			var sendMsg = transport.responseText.evalJSON(true);
			if (!sendMsg.submited) {
			    printError('Erreur de soumission !');
			} else {
			    document.periodicalRequest.start()
			    pseudoFieldLv.removeMessageAndFieldClass();
			    msgFieldLv.removeMessageAndFieldClass();
			    $('chatForm').enable();
			    $('msgField').value = '';
			}
		    }
		});
	    }
	});
	$('closeChat').observe('click',function(e){
	    e.stop();
	    new Effect.Move('chatBox', { x: 0, y: document.viewport.getHeight(), mode: 'absolute', duration: 0.8, afterFinish: function(){ $('chatBox').hide(); } });
	});
    }
}

document.observe('dom:loaded', function(e){
    e.stop();
    window.bp = new boxPlayer();
    viewportW = document.viewport.getWidth();
    viewportH = document.viewport.getHeight();
    var xpos = Math.floor((viewportW - $('loading').getWidth())/2);
    var ypos = Math.floor((viewportH - $('loading').getHeight())/2);
    $('loading').setStyle({
	left: xpos+"px",
	top: ypos+"px"
    });
    var setDivStrenth = {
	width: viewportW+"px",
	height: viewportH+"px"
    };
    $('starField').setStyle(setDivStrenth);
    $('mainDiv').setStyle(setDivStrenth);
    $('mask').setStyle(setDivStrenth);
    $('contactPage').setStyle(setDivStrenth);
    $('contactPage').setStyle({ opacity: "0.9" });
    $('mentionsLegales').setStyle(setDivStrenth);
    $('mentionsLegales').setStyle({ opacity: "0.9", top: (viewportH)+"px" });
    $('topBar').setStyle({
	width: (viewportW-2)+"px"
    });
    $('scrollControls').setStyle({
	top: (viewportH)+"px"
    });
    $('scrollTrack').setStyle({
	width: (viewportW-50)+"px"
    });
    $('scrollReverse').setStyle({
	left: (viewportW-22)+"px"
    });
    $('loading').appear({ duration: 0.3 });
    document.observe("sm2:loaded",function(e){
	var insertElem = $('mainDiv');
	new Ajax.MyUpdater(insertElem, '/ajax/ajaxLoadStage.php', {
	    parameters: $H({
		viewportW: viewportW,
		viewportH: viewportH,
		loadViewport: 'TRUE'
	    }).toQueryString(),
	    onComplete: function() {
	    	$('mainDiv').fire('stage:loaded');
	    }
	});
    });
    $('contactMail').replace('<a href="mailto:contact@reactionpowertrio.net" id="contactMail">Nous contacter par Mail</a>');
});
document.observe("bp:inited", function() {
    document.scrollPaused = false;
    document.topBarShowed = false;
    document.topBarMoved = false;
    document.scrollControlsShowed = false;
    document.scrollControlsMoved = false;
    $('loading').fade({ duration: 0.3 });
    $('starField').show();
    $('mainDiv').show();
    document.scrollSlider = new Control.Slider('scrollHandle','scrollTrack', {
	onSlide: function(value){
		if(document.scrolling.scrollOn) document.scrolling.stopScroll();
		document.scrolling.layers.each(function(layer){
		    var minX = document.viewport.getWidth()-layer.getWidth();
		    var moveToX = (minX*value).round();
		    layer.setStyle({ left: moveToX+'px' });
		});
    	},
    	onChange: function(value, slider){
    	    if(slider.event != null){
    		if(slider.event.target == $('scrollTrack')){
    		    if(document.scrolling.scrollOn) document.scrolling.stopScroll();
    		    document.scrolling.layers.each(function(layer, index){
    			var minX = document.viewport.getWidth()-layer.getWidth();
    			var moveToX = (minX*value).round();
    			var moveObj = {
    				x: moveToX,
        			mode: 'absolute',
        			duration: 1*((layer.positionedOffset().left.abs()-moveToX.abs()).abs()/minX.abs()),
        			transition: Effect.Transitions.linear,
        			queue: { scope: 'parallaxMoveSlider', position: 'parallel', limit: document.scrolling.nbLayers }
    			};
    			if (index==0) Object.extend( moveObj, { afterFinish: function(){ if(!document.scrollPaused) document.scrolling.startScroll(); } });
    			new Effect.MoveX(layer, moveObj);
    		    });
    		} else {
    		    if(!document.scrollPaused) document.scrolling.startScroll();
    		}
    	    }
    	}
    });
    $('mask').observe('mousemove',function(e){
	e.stop();
	if(e.pointerY() <= 20){
	    if(!$('topBar').visible() && !document.topBarShowed && !document.topBarMoved && !document.contactPageShowed){
		document.topBarMoved = true;
		Effect.toggle('topBar', 'slide', { duration: 0.5, afterFinish: function(){ document.topBarShowed = true; document.topBarMoved = false; } });
	    }
	} else {
	    if($('topBar').visible() && document.topBarShowed && !document.topBarMoved){
		document.topBarMoved = true;
		Effect.toggle('topBar', 'slide', { duration: 0.5, afterFinish: function(){ document.topBarShowed = false; document.topBarMoved = false; } });
	    }
	}
	if(e.pointerY() >= (document.viewport.getHeight()-22)){
	    if(!$('scrollControls').visible() && !document.scrollControlsShowed && !document.scrollControlsMoved && !document.contactPageShowed){
		document.scrollControlsMoved = true;
		$('scrollControls').show();
		new Effect.Move('scrollControls', { x: 0, y: -22, mode: 'relative', duration: 0.5, afterFinish: function(){ document.scrollControlsShowed = true; document.scrollControlsMoved = false; } });
	    }
	} else {
	    if($('scrollControls').visible() && document.scrollControlsShowed && !document.scrollControlsMoved){
		document.scrollControlsMoved = true;
		new Effect.Move('scrollControls', { x: 0, y: 22, mode: 'relative', duration: 0.5, afterFinish: function(){ document.scrollControlsShowed = false; document.scrollControlsMoved = false; $('scrollControls').hide(); } });
	    }
	}
    });
    $('mask').observe('click',function(e){
	if(!e.isRightClick()){
        	e.stop();
        	$$('span.mp3').each(function(el){
        	    if(Position.withinViewport(el, e.pointerX(), e.pointerY())) {
        		if(document.scrolling.scrollOn) {
        		    document.scrolling.stopScroll();
        		    $('spph').replace('<a id="spph" href="#Play">&raquo;</a></div>');
        	    	    document.scrollPaused = true;
        		}
        		el.up().simulate('click');
        		throw $break;
        	    }
        	});
        	if(document.scrolling.scrollOn) document.scrolling.reverseScroll();
	}
    });
    $('mask').observe('contextmenu',function(e){
	$$('span.mp3').each(function(el){
	    if(Position.withinViewport(el, e.pointerX(), e.pointerY())) {
		e.stop();
		if(document.scrolling.scrollOn) {
		    document.scrolling.stopScroll();
		    $('spph').replace('<a id="spph" href="#Play">&raquo;</a></div>');
	    	    document.scrollPaused = true;
		}
		new showContext(el.up(),e);
		throw $break;
	    }
	});
    });
    document.observe("sm2sound:finish", function(e) {
	e.stop();
	if(!document.scrolling.scrollOn) {
	    document.scrolling.startScroll();
	    $('spph').replace('<a id="spph" href="#Pause">||</a>');
    	    document.scrollPaused = false;
	}
    });
    $('scrollReverse').observe('click',function(e){
	e.stop();
	document.scrolling.reverseScroll();
    });
    $('scrollPlayPause').observe('click',function(e){
    	e.stop();
    	if(document.scrollPaused && !document.scrolling.scrollOn){
    	    document.scrolling.startScroll();
    	    $('spph').replace('<a id="spph" href="#Pause">||</a>');
    	    document.scrollPaused = false;
    	} else {
    	    document.scrolling.stopScroll();
    	    $('spph').replace('<a id="spph" href="#Play">&raquo;</a></div>');
    	    document.scrollPaused = true;
    	}
    });
    document.contactPageShowed = false;
    $('topBar').observe('click',function(e){
	e.stop();
	document.contactPageShowed = true;
	Effect.toggle('contactPage', 'slide', { duration: 0.8 });
	document.topBarMoved = true;
	Effect.toggle('topBar', 'slide', { duration: 0.5, afterFinish: function(){ document.topBarShowed = false; document.topBarMoved = false; } });
    });
    $('contactPage').observe('click',function(e){
	var elem = Event.element(e);
	if (elem.tagName != 'A') {
	    e.stop();
	    Effect.toggle('contactPage', 'slide', { duration: 0.8, afterFinish: function(){ document.contactPageShowed = false; } });
	}
    });
    $('legualClick').observe('click',function(e){
	e.stop();
	Effect.toggle('contactPage', 'slide', { duration: 0.8, afterFinish: function(){	document.contactPageShowed = false; } });
	$('mentionsLegales').show();
	new Effect.Move('mentionsLegales', { x: 0, y: 0, mode: 'absolute', duration: 0.8 });
    });
    $('mentionsLegales').observe('click',function(e){
	var elem = Event.element(e);
	if (elem.tagName != 'A') {
	    e.stop();
	    new Effect.Move('mentionsLegales', { x: 0, y: document.viewport.getHeight(), mode: 'absolute', duration: 0.8, afterFinish: function(){ $('mentionsLegales').hide(); } });
	}
    });
    $('chatLink').observe('click',function(e){
	e.stop();
	if($('chatFormDiv')){
	    Effect.toggle('contactPage', 'slide', { duration: 0.8, afterFinish: function(){ document.contactPageShowed = false; } });
	    startChat();
	} else {
	    Effect.toggle('contactPage', 'slide', { duration: 0.8, afterFinish: function(){ document.contactPageShowed = false; } });
	    new Ajax.MyUpdater('chatBox', '/ajax/ajaxLoadChatBox.php', {
		parameters: $H({ loadChatBox: 'TRUE' }).toQueryString(),
		onComplete: function() {
			startChat();
	    	}
	    });
	}
    });
    document.scrolling = new parallaxScroll('div.layers', 100);
    new starField('starField', 50, 50);
});
Event.observe(window, 'unload', function(){
	Event.unloadCache;
});