
/*
An object-oriented Typing Text script, to allow for multiple instances.
A script that causes any text inside any text element to be "typed out", one letter at a time. Note that any HTML tags will not be included in the typed output, to prevent them from causing problems. Tested in Firefox v1.5.0.1, Opera v8.52, Konqueror v3.5.1, and IE v6.
Browsers that do not support this script will simply see the text fully displayed from the start, including any HTML tags.
Functions defined:
TypingText(element, [interval = 100,] [cursor = "",] [finishedCallback = function(){return}]):
Create a new TypingText object around the given element. Optionally
specify a delay between characters of interval milliseconds.
cursor allows users to specify some HTML to be appended to the end of
the string whilst typing. Optionally, can also be a function which
accepts the current text as an argument. This allows the user to
create a "dynamic cursor" which changes depending on the latest character
or the current length of the string.
finishedCallback allows advanced scripters to supply a function
to be executed on finishing. The function must accept no arguments.
TypingText.run():
Run the effect.
static TypingText.runAll():
Run all TypingText-enabled objects on the page.
*/
TypingText = function(element, interval, cursor, finishedCallback) {
if((typeof document.getElementById == "undefined") || (typeof element.innerHTML == "undefined")) {
this.running = true; // Never run.
return;
}
this.element = element;
this.finishedCallback = (finishedCallback ? finishedCallback : function() { return; });
this.interval = (typeof interval == "undefined" ? 100 : interval);
this.origText = this.element.innerHTML;
this.unparsedOrigText = this.origText;
this.cursor = (cursor ? cursor : "");
this.currentText = "";
this.currentChar = 0;
this.element.typingText = this;
if(this.element.id == "") this.element.id = "typingtext" + TypingText.currentIndex++;
TypingText.all.push(this);
this.running = false;
this.inTag = false;
this.tagBuffer = "";
this.inHTMLEntity = false;
this.HTMLEntityBuffer = "";
}
TypingText.all = new Array();
TypingText.currentIndex = 0;
TypingText.runAll = function() {
for(var i = 0; i < TypingText.all.length; i++) TypingText.all[i].run();
}
TypingText.prototype.run = function() {
if(this.running) return;
if(typeof this.origText == "undefined") {
setTimeout("document.getElementById('" + this.element.id + "').typingText.run()", this.interval); // We haven't finished loading yet. Have patience.
return;
}
if(this.currentText == "") this.element.innerHTML = "";
// this.origText = this.origText.replace(/<([^<])*>/, ""); // Strip HTML from text.
if(this.currentChar < this.origText.length) {
if(this.origText.charAt(this.currentChar) == "<" && !this.inTag) {
this.tagBuffer = "<";
this.inTag = true;
this.currentChar++;
this.run();
return;
} else if(this.origText.charAt(this.currentChar) == ">" && this.inTag) {
this.tagBuffer += ">";
this.inTag = false;
this.currentText += this.tagBuffer;
this.currentChar++;
this.run();
return;
} else if(this.inTag) {
this.tagBuffer += this.origText.charAt(this.currentChar);
this.currentChar++;
this.run();
return;
} else if(this.origText.charAt(this.currentChar) == "&" && !this.inHTMLEntity) {
this.HTMLEntityBuffer = "&";
this.inHTMLEntity = true;
this.currentChar++;
this.run();
return;
} else if(this.origText.charAt(this.currentChar) == ";" && this.inHTMLEntity) {
this.HTMLEntityBuffer += ";";
this.inHTMLEntity = false;
this.currentText += this.HTMLEntityBuffer;
this.currentChar++;
this.run();
return;
} else if(this.inHTMLEntity) {
this.HTMLEntityBuffer += this.origText.charAt(this.currentChar);
this.currentChar++;
this.run();
return;
} else {
this.currentText += this.origText.charAt(this.currentChar);
}
this.element.innerHTML = this.currentText;
this.element.innerHTML += (this.currentChar < this.origText.length - 1 ? (typeof this.cursor == "function" ? this.cursor(this.currentText) : this.cursor) : "");
this.currentChar++;
setTimeout("document.getElementById('" + this.element.id + "').typingText.run()", this.interval);
} else {
this.currentText = "";
this.currentChar = 0;
this.running = false;
this.finishedCallback();
}
}

// MenuBar Scroller - By Alcantor's script
// Ce code à été inspiré de "Page Scroller (aka custom scrollbar)" de http://www.dynamicdrive.com

// Valeur par défaut

var posX=0;
var posY=0;
var rightcorner=0;
var bottomcorner=0;

var thespeed=3; //Vitesse de défilement (Entre: 1-3)

var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1;
var myspeed=0;

var ieHoffset_extra=document.all? 15 : 0;
var cross_obj=0;

function IEcompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function SetData(div_id,X,Y,right,bottom){
	posX=X+5; // Distance Horizontal à partir du bord
	posY=Y+55; // Distance Vertical à partir du bord
	rightcorner=right; // 1 si le menu doit s'afficher à droite
	bottomcorner=bottom; // 1 si le menu doit s'afficher en bas
	
	cross_obj=document.getElementById(div_id);
	
	if (document.all||document.getElementById||document.layers)
		setInterval("Initialize()",20);
}
	
function Position(){
	var dsocleft=document.all? IEcompattest().scrollLeft : pageXOffset;
	var dsoctop=document.all? IEcompattest().scrollTop : pageYOffset;
	var window_width=ieNOTopera? IEcompattest().clientWidth+ieHoffset_extra : window.innerWidth+ieHoffset_extra;
	var window_height=ieNOTopera? IEcompattest().clientHeight : window.innerHeight;
	
	if(rightcorner==1) f_posX=window_width-posX; else f_posX=posX;
	if(bottomcorner==1) f_posY=window_height-posY; else f_posY=posY;
	
	if (document.all||document.getElementById){
		cross_obj.style.left=parseInt(dsocleft)+f_posX+"px";
		cross_obj.style.top=dsoctop+f_posY+"px";
	}else if (document.layers){
		cross_obj.left=dsocleft+f_posX;
		cross_obj.top=dsoctop+f_posY;
	}
}

function ScrollWindow(){
	window.scrollBy(0,myspeed);
}

function Initialize(){
	Position();
	if (myspeed!=0){
		ScrollWindow();
	}
}

// image voile et zoom - By kazma
// Ce code à été inspiré de "voile version 05.10.2009" de http://www.javascriptfr.com/


function MM_preloadImages() { //v3.0
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}


var imag = new Image();
var bobo=1
var hou=0
var rar=true

		//fonction pour la creation du voile et de l'image de precharge avec leur attributs ainsi que le prechargement

function precharge(ii){

if(bobo==1){
document.documentElement.childNodes[1].appendChild(document.createElement('div')).setAttribute("id",'voile');
document.documentElement.childNodes[1].appendChild(document.createElement('img')).setAttribute("id",'imadiv');
var imad=document.getElementById('imadiv');
imad.setAttribute("src", "res/animation.gif");
(navigator.appName.substring(0,3)=="Mic") ?  imad.style.filter='alpha(opacity=100)' : imad.style.opacity =100
imad.style.position='absolute';
imad.style.height=100+"px";
sscro()
var vo=document.getElementById('voile');
vo.style.position='absolute';
vo.style.top=0+"px";
vo.style.left=0+"px";
vo.style.backgroundColor="white";
if(document.all && !window.opera){ 
vo.style.filter = 'alpha(opacity=10)';
window.attachEvent("onresize", sscro);
window.attachEvent("onscroll", sscro);
} 
else{ 
vo.style.opacity =0.1;
window.addEventListener("resize", sscro, false);
window.addEventListener("scroll", sscro, false);
}
sscro()
imag.setAttribute("src", "PHOTOS/"+ii+".jpg") ;
bobo=2
}
if(navigator.oscpu||navigator.vendor){
imag.onload=function(){
inimage()}
bobo=1
} 
else{
if(imag.complete==true){
bobo=1
inimage()
return false
}
setTimeout(precharge,100)
}
} 

		//fonction de suppression de l'image du voile et des evenement lie au document

function quit(){

if(navigator.appName.substring(0,5)=="Micro"){
window.detachEvent("onresize", sscro);
window.detachEvent("onscroll", sscro);
}
else{
window.removeEventListener("resize", sscro, false);
window.removeEventListener("scroll", sscro, false);
}
document.getElementById('voile').parentNode.removeChild(document.getElementById('voile'));
document.getElementById('imadiv').parentNode.removeChild(document.getElementById('imadiv'));
}

		//fonction pour le positionne de l'image et du voile

function sscro(){

var dde=document.documentElement;
var vo=document.getElementById('voile')
var imad=document.getElementById('imadiv')
imad.style.left=((dde.clientWidth-imad.offsetWidth)/2)+'px';
if(navigator.vendor){
imad.style.top=(dde.clientHeight-imad.offsetHeight)/2+dde.lastChild.scrollTop+"px";
vo.style.height=dde.clientHeight+dde.lastChild.scrollTop+"px";
vo.style.width=dde.clientWidth+dde.lastChild.scrollLeft+"px";
} 
else{
imad.style.top=(dde.clientHeight-imad.offsetHeight)/2+dde.scrollTop+"px";
vo.style.height=dde.clientHeight+dde.scrollTop+"px";
vo.style.width=dde.clientWidth+dde.scrollLeft+"px";
}
}

		//fonction pour l'initialisation de l'image et des evenements

function inimage(){

var imad=document.getElementById('imadiv');
var vo=document.getElementById('voile')
if(hou==0){
imad.parentNode.removeChild(imad);
document.documentElement.childNodes[1].appendChild(document.createElement('img')).setAttribute("id",'imadiv');
var imad=document.getElementById('imadiv');
(navigator.appName.substring(0,3)=="Mic") ?  imad.style.filter='alpha(opacity=0)' : imad.style.opacity =0
imad.src=imag.getAttribute('src');
imad.style.position='absolute';
if (navigator.userAgent.indexOf('MSIE 6')!=-1){ 
imad.style.height=(document.body.clientHeight/100)*55+"px";
}
else{
imad.style.height=90+"%";
}
sscro()
} 

if(hou<1){

if(document.all && !window.opera){
hou+=0.2
vo.style.filter = 'alpha(opacity='+(hou*50)+')';
imad.style.filter = 'alpha(opacity='+(hou*100)+')';
} 
else{
hou+=0.1
vo.style.opacity =hou/2;
imad.style.opacity =hou;
}
setTimeout(inimage,1)
}
else{
vo.onclick=quit
if(navigator.appName.substring(0,5)=="Micro"){
imad.attachEvent('onmousedown',function(){sp(event)});
imad.attachEvent('onmouseup',function(){sp()});
imad.attachEvent('onmousewheel',dirizoom);
imad.attachEvent("onmousemove",souris);
imad.attachEvent("oncontextmenu", function(){return false});
imad.attachEvent('onmousewheel', selecte)
}
else{
imad.setAttribute("onmousemove","souris(event)");
imad.setAttribute("onmousedown","sp(event)");
imad.setAttribute("onmouseup","sp()");
document.addEventListener("mouseup", selecte, false)
document.addEventListener("contextmenu", selecte, false)

if (navigator.userAgent.indexOf("Firefox") != -1){
imad.addEventListener('DOMMouseScroll', dirizoom, false);
imad.addEventListener("DOMMouseScroll", selecte, false)
}
else{
imad.addEventListener('mousewheel', dirizoom, false);
imad.addEventListener("mousewheel", selecte, false)
}
}
sscro()
hou=0
}
}

		//fonction pour la detection du mouvement de souris

function souris(s){

var dde=(navigator.vendor) ? document.documentElement.childNodes[1] : document.documentElement;
setX =((navigator.appName.substring(0,3)=="Mic") ? event.clientX : s.clientX) + dde.scrollLeft;
setY =((navigator.appName.substring(0,3)=="Mic") ? event.clientY : s.clientY) + dde.scrollTop;
return false;
}

		//fonction pour annuler l'action  par default du navigateur

function selecte(ev){
(navigator.appName.substring(0,3)=="Mic") ? event.returnValue = false : ev.preventDefault();
}

		//fonction pour le zoom directionnel

function dirizoom(e){
var delta = 0;
if (!e) e = window.event;
if (e.wheelDelta) {
delta = e.wheelDelta/120; 
} else if (e.detail) {
delta = -e.detail/3;
}
if(delta<0){
val=-0.15;
}
else{
val=0.15;
}
imad=document.getElementById('imadiv');
var dirle=(imad.offsetWidth/2)-(setX-(imad.parentNode.offsetLeft+imad.offsetLeft));
var dirto=(imad.offsetHeight/2)-(setY-(imad.parentNode.offsetTop+imad.offsetTop));
var lf=imad.offsetWidth;
var rf=imad.offsetHeight;
imad.style.width=lf+(lf*val)+'px';
imad.style.height=rf+(rf*val)+'px';
imad.style.left=imad.offsetLeft-((imad.offsetWidth-lf)/2)+(dirle*val)+'px';
imad.style.top=imad.offsetTop-((imad.offsetHeight-rf)/2)+(dirto*val)+'px';
}

		//partie drag

function sp(evt){
if(rar && arguments.length!=0){
var dde=(navigator.vendor) ? document.documentElement.childNodes[1] : document.documentElement;
var cen=(navigator.appName.substring(0,3)=="Mic") ? event.srcElement : evt.currentTarget;
(navigator.appName.substring(0,3)=="Net") ? document.addEventListener("mousedown", selecte, false) : null;
setX=evt.clientX + dde.scrollLeft;
setY=evt.clientY + dde.scrollTop;
var px=setX-cen.offsetLeft;
var py=setY-cen.offsetTop;
dragval=setInterval("posi("+px+","+py+",'"+cen.id+"')",10);
rar=false;
}
if(rar==false && arguments.length==0){
(navigator.appName.substring(0,3)=="Net") ? document.removeEventListener("mousedown", selecte, false) : null;
clearInterval(dragval);
rar=true;
}
}

function posi(decx,decy,fen){
document.getElementById(fen).style.left=(setX-decx)+"px";
document.getElementById(fen).style.top=(setY-decy)+"px";
}

