// JavaScript Document
// menu
// ==================================================
//             ----- menu 3D -----
// script written by Gerard Ferrandez - May 2007
// http://www.dhteumeuleu.com
// ==================================================

/* ==== mouse position event ==== */
var xm = 0;
var ym = 0;
document.onmousemove = function(e){
	if (window.event) e=window.event;
	xm = e.clientX;
	ym = e.clientY;
}

/* ==== resize event ==== */
function resize() {
	tdm.resize();
}
onresize = resize;



var tdm = {
//////////////////////
	FOCAL : 250,
	ZOOM  : .03,
//////////////////////
	CX : 0,
	CY : 0,

	/* ==== resize ==== */
	resize : function()
	{
		tdm.nw = this.scr.offsetWidth;
		tdm.nh = this.scr.offsetHeight;
		tdm.nx = 0;
		tdm.ny = 0;
		for (var o = tdm.scr; o != null; o = o.offsetParent)
		{
			tdm.nx += o.offsetLeft;
			tdm.ny += o.offsetTop;
		}
	},

	/* ==== main loop ==== */
	run : function ()
	{
		tdm.CX += (xm - tdm.CX) * .1;
		tdm.CY += (ym - tdm.CY) * .1;
		for (var i = 0, o; o = tdm.obj[i]; i++)
		{
			var dx = o.X - tdm.CX + tdm.nx;
			var dy = o.Y - tdm.CY + tdm.ny;
			var d  = Math.sqrt(dx * dx + dy * dy);
			var z  = (tdm.FOCAL - d) / tdm.FOCAL * (o.S * .1);
		<!--	var s  = Math.max(0, o.S + (50 - d * .1) * (o.S * tdm.ZOOM)); -->
			var s  = Math.max(1, o.S + (70 - d * 0.4) * (o.S * tdm.ZOOM));
			var x  = o.X + dx * z - s * .5;
			var y  = o.Y + dy * z - s * .5;
			if(x > -s * .5 && x < tdm.nw && y > -s && y < tdm.nh){
				o.style.left     = Math.round(x)  + 'px';
				o.style.top      = Math.round(y)  + 'px';
				o.style.fontSize = Math.round(s) + 'px';
				o.style.zIndex   = Math.round(z);
			} else o.style.left  = '-1000px';
		}
		setTimeout(tdm.run, 16);
	},

	/* ==== initialization ==== */
	init : function (container, objects)
	{
		this.scr = document.getElementById(container);
		this.obj = [];
		var k = 0;
		for (var i = 0; i < objects.length; i++)
		{
			var o = objects[i];
			var x = o[1];
			var y = o[2];
			var f = o[3];
			var d = o[4];
			var css = o[5];
			for (var j = 0; j < o[0].length; j++)
			{
				var c = o[0].charAt(j);
				if (c != ' ')
				{
					var s = this.obj[k++] = document.createElement(o[6] ? 'a' : 'div');
					s.appendChild(document.createTextNode(c));
					s.X = x;
					s.Y = y;
					s.S = f;
					if (css) for (var l in css) s.style[l] = css[l];
					if (o[6])
					{
					<!--s.href = o[6]; -->
						s.onclick = new Function(o[6]);
						<!--s.onmouseover = new Function(o[6]); -->
						s.style.cursor = 'pointer';
					}
					this.scr.appendChild(s);
				}
				if (d == 1) y += f * 1.2;
				else if (d == 3)
				{
					if (c != ' ') s.S = f;
					f *= 1.5;
				}
				else x += f;
			}
		}
		/* ==== go! ==== */
		this.resize();
		xm = this.nx + this.nw / 2;
		ym = this.ny + this.nh / 2;
		this.run();
	}
}

onload = function () {
	/* ==== menu ==== */
	tdm.init("screen", [
	/* "texte", posX, pos Y, posZ, d, {css} */
		['?', 110, 110, 12, 0, {'color':'#F00'}, "bascule('quoi')"], ['{}', 100, 110, 24],
		
		[" diDhoC", 250, 260, 30, 2, {'border': '1px solid #fff','color':'#fff', 'padding':'20px'}],
		["design interactivo", 250, 280, 12, 2 , {'color':'#fff','background':'#f00'}],
		
		['websites', 480, 330, 12, 0, {'color':'#F00'}, "bascule('websites')"], ['{  }', 480, 330, 24],
		['animações', 480, 350, 8, 0, {'color':'#F00'}, "bascule('animations')"], ['{   }', 480, 350, 16],
		['cd-rom/dvd', 450, 370, 10, 0, {'color':'#F00'}, "bascule('cd')"], ['{   }', 455, 370, 20],
		['visitas virtuais', 500, 390, 8, 0, {'color':'#F00'}, "bascule('vr')"], ['{     }', 510, 390, 16],
		['+', 580, 360, 12, 0, {'color':'#F00'}, "bascule('divers')"], ['{}', 571, 360, 20],
		['contacto', 550, 120, 12, 0, {'color':'#F00'}, "bascule('contact')"], ['{  }', 555, 120, 24]
		
	]);
	// couleur de fond aleatoire
	couleur();
}
// affichage et masquage DIV
function bascule(elem)
{
// Quel est l'état actuel ?
etat=document.getElementById(elem).style.visibility;
if(etat=="hidden"){document.getElementById(elem).style.visibility="visible";}
else{document.getElementById(elem).style.visibility="hidden";}
}
// drag
//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
  
    dragObj.elNode = document.getElementById(id);
	
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
   	dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  //dragObj.elNode.style.zIndex = ++dragObj.zIndex; //incompatible avec boxOver

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {
  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

//]]>
<!--slideShow -->
thisImg = 1
function slideShow(nom, ext, total) {
if (document.images) {
thisImg = thisImg + 1
if (thisImg < 1) { thisImg = total }
if (thisImg > total) { thisImg=1 }
document.slider.src = 'content/'+ nom + '_' + thisImg + '.'+ ext }
}
//pop-Up
function popup(url,popupname,parameters)
{
	window.open(url,popupname,parameters);
}
function openJavaLow(theURL,winName,features) { //v2.0
  window.open(theURL,'javaLow','toolbar=0, menubar=0, location=0, scrollbars=0, width=440,height=350, left=50, top=50');
}
function openJavaHi(theURL,winName,features) { //v2.0
  window.open(theURL,'javaHi','toolbar=0, menubar=0, location=0, scrollbars=0, width=840,height=570, left=50, top=50');
}
function openQtLow(theURL,winName,features) { //v2.0
  window.open(theURL,'qtLow','toolbar=0, menubar=0, location=0, scrollbars=0, width=440,height=350, left=50, top=50');
}
function openQtHi(theURL,winName,features) { //v2.0
  window.open(theURL,'qtHi','toolbar=0, menubar=0, location=0, scrollbars=0, width=840,height=570, left=50, top=50');
}

function openFlash(theURL,winName,features) { //v2.0
  window.open(theURL,'flash','toolbar=0, menubar=0, location=0, scrollbars=0, width=840,height=570, left=50, top=50');
}
function couleur() {
	
	// couleur de fond aleatoire
	var bgcolorlist=new Array("#9DDEFF", "#B6E998", "#DD0")
	document.getElementById('screen').style.backgroundColor =bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)];
}