//MENU plusieurs niveaux
function expandMenuL1(divSelected,activesouscurrent){
	
	var defaultSelected='menuli_1_menusousmenu_1';
	
	document.getElementById(defaultSelected).style.display='none';
	
	var alreadySelectedMenu=document.getElementById('selectedmenu').value;
	var alreadySelectedSousMenu=document.getElementById('selectedsousmenu').value;
	var alreadyActiveMenu=document.getElementById('activesousmenu').value;
	
	if(alreadySelectedMenu!=""){
		document.getElementById(alreadySelectedMenu).style.display='none';
	}
	
	if(alreadySelectedSousMenu!=""){
		document.getElementById(alreadySelectedSousMenu).style.display='none';
	}
	
	if(alreadyActiveMenu!=""){
			//document.getElementById(alreadyActiveMenu).className="";
		}
	
	//alert(divSelected);
	//alert(alreadySelectedMenu);
	document.getElementById('selectedmenu').value=divSelected;
	document.getElementById('activesousmenu').value=activesouscurrent;
	
	//document.getElementById(activesouscurrent).className="active";
	document.getElementById(divSelected).style.display='block';
	//document.getElementById(activesouscurrent).className="";
	
	}
	
	
function expandSousMenu(divMenuSelected,divSSMenuSelected,activesouscurrent){
	
	
	var alreadySelectedMenu=document.getElementById('selectedmenu').value;
	var alreadySelectedSousMenu=document.getElementById('selectedsousmenu').value;
	
	var alreadyActiveMenu=document.getElementById('activesousmenu').value;
	//var alreadyActiveSousMenu=document.getElementById('activesoussousmenu').value;
	
		if(alreadySelectedMenu!=""){
			document.getElementById(alreadySelectedMenu).style.display='none';
		}
		if(alreadySelectedSousMenu!=""){
			document.getElementById(alreadySelectedSousMenu).style.display='none';
		}
		if(alreadyActiveMenu!=""){
			document.getElementById(alreadyActiveMenu).className="";
		}
		//if(alreadyActiveSousMenu!=""){
		//	document.getElementById(alreadyActiveSousMenu).className="";
		//}

	document.getElementById('selectedmenu').value=divMenuSelected;
	document.getElementById('selectedsousmenu').value=divSSMenuSelected;
	document.getElementById('activesousmenu').value=activesouscurrent;
	//document.getElementById('activesoussousmenu').value=activesoussouscurrent;
	

	//alert(divSSMenuSelected);
	document.getElementById(divMenuSelected).style.display='block';
	document.getElementById(divSSMenuSelected).style.display='block';
	
	//document.getElementById(activesouscurrent).className="active";
	//document.getElementById(activesoussouscurrent).className="select";
	
	}

// News Slider
var SLIDETIMER = 20;
var SLIDESPEED = 2;
var SCROLLTIMER = 3;
var SCROLLSPEED = 3;
var STARTINGOPACITY = 40;

// handles section to section scrolling of the content //
function slideContent(id,prefix,timer) {
  var div = document.getElementById(id);
  var slider = div.parentNode;
  clearInterval(slider.timer);
  slider.section = parseInt(id.replace(/\D/g,''));
  slider.target = div.offsetTop;
  slider.style.top = slider.style.top || '0px';
  slider.current = slider.style.top.replace('px','');
  slider.direction = (Math.abs(slider.current) > slider.target) ? 1 : -1;
  slider.style.opacity = STARTINGOPACITY * .01;
  slider.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
  slider.timer = setInterval( function() { slideAnimate(slider,prefix,timer) }, SLIDETIMER);
}

function slideAnimate(slider,prefix,timer) {
  var curr = Math.abs(slider.current);
  var tar = Math.abs(slider.target);
  var dir = slider.direction;
  if((tar - curr <= SLIDESPEED && dir == -1) || (curr - tar <= SLIDESPEED && dir == 1)) {
    slider.style.top = (slider.target * -1) + 'px';
	slider.style.opacity = 1;
	slider.style.filter = 'alpha(opacity=100)';
    clearInterval(slider.timer);
	if(slider.autoscroll) {
	  setTimeout( function() { autoScroll(slider.id,prefix,timer) }, timer * 1000);
	}
  } else {
	var pos = (dir == 1) ? parseInt(slider.current) + SLIDESPEED : slider.current - SLIDESPEED;
    slider.current = pos;
    slider.style.top = pos + 'px';
  }
}

// handles manual scrolling of the content //
function scrollContent(id,dir) {
  var div = document.getElementById(id);
  clearInterval(div.timer);
  var sections = div.getElementsByTagName('div');
  var length = sections.length;
  var limit;
  if(dir == -1) {
    limit = 0;
  } else {
    if(length > 1) {
      limit = sections[length-1].offsetTop;
    } else {
      limit = sections[length-1].offsetHeight - div.parentNode.offsetHeight + 20;
    }
  }
  div.style.opacity = STARTINGOPACITY * .01;
  div.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
  div.timer = setInterval( function() { scrollAnimate(div,dir,limit) }, SCROLLTIMER);
}

function scrollAnimate(div,dir,limit) {
  div.style.top = div.style.top || '0px';
  var top = div.style.top.replace('px','');
  if(dir == 1) {
	if(limit - Math.abs(top) <= SCROLLSPEED) {
	  cancelScroll(div.id);
	  div.style.top = '-' + limit + 'px';
	} else {
	  div.style.top = top - SCROLLSPEED + 'px';
	}
  } else {
	if(Math.abs(top) - limit <= SCROLLSPEED) {
	  cancelScroll(div.id);
	  div.style.top = limit + 'px';
	} else {
	  div.style.top = parseInt(top) + SCROLLSPEED + 'px';
	}
  }
}

// cancel the scrolling on mouseout //
function cancelScroll(id) {
  var div = document.getElementById(id);
  div.style.opacity = 1;
  div.style.filter = 'alpha(opacity=100)';
  clearTimeout(div.timer);
}

// initiate auto scrolling //
function autoScroll(id,prefix,timer,restart) {
  var div = document.getElementById(id);
  div.autoscroll = (!div.autoscroll && !restart) ? false : true;
  if(div.autoscroll) {
    var sections = div.getElementsByTagName('div');
    var length = sections.length;
    div.section = (div.section && div.section < length) ? div.section + 1 : 1;
    slideContent(prefix + '-' + div.section,prefix,timer);
  }
}

// cancel automatic scrolling //
function cancelAutoScroll(id) {
  var div = document.getElementById(id);
  div.autoscroll = false;
}



// dvdp - volll - iphone alert

var agent=navigator.userAgent.toLowerCase();
var is_iphone = (agent.indexOf('iphone')!=-1);


//  TJP - volll

var stispace=new Array();
var jumpspace=new Array();
var skyspace=new Array; skyspace['dir']=-1; skyspace['place']=0;
var smokespace=0;
var shipspace=0;
var cloudspace=new Array();
var stagespace = screen.width;
var fishspace=new Array();
var dogspace=new Array();

dogspace['s']=0; dogspace['u']=0;
fishspace[1]=new Array(); fishspace[1]['s']=0; fishspace[1]['e']=5; fishspace[1]['t']=Math.floor(490+26*Math.random());
fishspace[2]=new Array(); fishspace[2]['s']=0; fishspace[2]['e']=8; fishspace[2]['t']=Math.floor(490+26*Math.random());
fishspace[3]=new Array(); fishspace[3]['s']=0; fishspace[3]['e']=5; fishspace[3]['t']=Math.floor(490+26*Math.random());
fishspace[4]=new Array(); fishspace[4]['s']=0; fishspace[4]['e']=3; fishspace[4]['t']=Math.floor(490+26*Math.random());
fishspace[5]=new Array(); fishspace[5]['s']=0; fishspace[5]['e']=5; fishspace[5]['t']=Math.floor(490+26*Math.random());
cloudspace[1]=new Array(); cloudspace[1]['w']=219; cloudspace[1]['p']=630;
cloudspace[2]=new Array(); cloudspace[2]['w']=128; cloudspace[2]['p']=350;
cloudspace[3]=new Array(); cloudspace[3]['w']=51; cloudspace[3]['p']=900;
cloudspace[4]=new Array(); cloudspace[4]['w']=88; cloudspace[4]['p']=120;
cloudspace[5]=new Array(); cloudspace[5]['w']=219; cloudspace[5]['p']=130;

var movespace='';
var scrollspace=0;
pag_sections_height=new Array( 200,		750,				750,			750,				750					);
pag_sections_name=new Array(   'top',	'section_about',	'section_main',	'section_works',	'section_goodies'	);

function $(id) {
 return document.getElementById(id);
}

function setTI(todos,interval) {
 if(stispace[todos].length == 0) {delete stispace[todos];return false;}
 eval(stispace[todos].shift());
  setTimeout('setTI('+todos+','+interval+')',interval);
}

function setevent(id,event,fn) {
  $(id).setAttribute(event,fn+'(event,this);');
  if(navigator.userAgent.indexOf('MSIE')>-1) {
   eval("$('"+id+"')."+event+" = function() {"+fn+"(event,this);}");
   //$('id').onclick = function() {TJPhandlemouse(event,this);}
  }
}

function smoothto(whereto) {
wheretoreal=whereto;
 if(scrollspace == 1) {return false;}
 if(whereto == 'section_about_who') { whereto='section_about';}
 if(whereto == 'section_about_contact') { whereto='section_about';}
 scrollspace=1;
 wheretoscroll=0;
 wherefromscroll=topget();
 for(smt=0;smt<pag_sections_name.length;smt++) {
  if(smt>0) {wheretoscroll+=pag_sections_height[smt-1]}
  if(pag_sections_name[smt] == whereto) {smt=pag_sections_name.length;}
 }
 if(wherefromscroll==wheretoscroll) {
  scrollspace=0;
  window.location='#'+wheretoreal;
  return false;
 }else{
	 window.paused=1;
	clearInterval(int_TJPfloat);
	clearInterval(int_TJProllsky);
 }

 $('vollltv').style.height='0';
 tmp=new Array();
 steps=20;
 for(smt=1;smt<=steps;smt++) {
  pt=smt/steps;
  if(pt == .5) {
   multi=1.5
  } else {
   multi=(Math.sqrt(Math.abs(2*pt-1))*(2*pt-1)/Math.abs(2*pt-1)+1)/2;
  }
  multi=Math.sqrt(smt/steps);
  tmp[smt]='window.scroll(0,'+(wherefromscroll+(wheretoscroll-wherefromscroll)*multi)+');';
 }
 tmp[steps]+="window.location='#"+wheretoreal+"';$('vollltv').style.height='278px'; scrollspace=0;";
  tmp[steps]+=" window.int_TJProllsky=undefined; window.int_TJProllsky=setInterval('TJProllsky();',200);";
tmp[steps]+="window.int_TJPfloat=undefined; window.int_TJPfloat=setInterval('TJPfloat();',50);";
tmp[steps]+="window.paused=0; ";
 //alert(tmp.join("\n"));
 ttt=Math.random();
 stispace[ttt]=tmp;
 setTI(ttt,10);
 return false;
}

function topget() {
 return (self.pageYOffset)?(self.pageYOffset):((document.documentElement && document.documentElement.scrollTop)?(document.documentElement.scrollTop):(document.body.scrollTop));
}


function volllresize() {
  
  d = document.body.clientWidth;
  if(d && d < 1000) 
  {
    stagespace = 1000;
  }
  else
  {
	  stagespace = d;
  }
  
}


function volllinit() {
	  
	volllresize();
	window.int_TJProllsky = setInterval("TJProllsky();",200);
	window.int_TJPfloat = setInterval("TJPfloat();",50);
}
window.paused=0;
function volllpapratio(vpr) {

		 ratios=new Array('16by10','4by3');
		 for(r in ratios) {
		  $('wpb_'+ratios[r]).className=((ratios[r] == vpr)?('active'):(''));
		 }
		 for(i=1;i<=8;i++) {
		  $('volllpaper_'+i).href='images/goodies/volllpaper'+i+'_-_'+vpr+'.png';
		 }
		 //$('volllpaper_9').href='images/goodies/volllpapers_-_'+vpr+'.zip';
		 return false;
		}
		function TJPmovecloud(cid,pos) {
		 if(pos > stagespace && window.paused>0 ) {
		  return;
		 }
		 if(pos+cloudspace[cid]['w']>stagespace) {
		  $('s_cloud'+cid).style.width=stagespace-pos+'px';
		 } else {
		  $('s_cloud'+cid).style.width=cloudspace[cid]['w']+'px';
		 }
		 $('s_cloud'+cid).style.left=pos+'px';

}

function TJPhandlemouse(evt,obj) {
 var evt = evt?evt:window.event?window.event:null; if(!evt) { return false; }
      if(obj.id == 's_spaceboy') { TJPjump('s_spaceboy',0,0,8,24,15); }
 else if(obj.id == 's_spacegirl') { TJPjump('s_spacegirl',0,0,5,10,15); }
 else if(obj.id.substr(0,7) == 's_sheep') {TJPjump(obj.id,0,0,0,-10-10*Math.random(),7);}
 else if(obj.id == 's_boy_octopus') { TJPjump(obj.id,0,0,0,-20-20*Math.random(),15); }
 else if(obj.id == 's_girl_octopus') { TJPjump(obj.id,0,0,-55,0,15); }
 else if(obj.id == 's_king_octopus') { TJPjump(obj.id,0,parseInt($('s_king_octopus').style.marginTop),0,-50,25);}
 else if(obj.id == 's_landing_unit') { TJPjump(obj.id,0,0,0,-10,50); }
 else if(obj.id == 's_astronaut') {TJPjump(obj.id,0,0,0,-20,9);}
 else if(obj.id == 's_scubadog') {dogspace['u']=1; TJPjump(obj.id,0,0,-270,0,100);}
}

function TJProllsky() {
 skyspace['place']+=skyspace['dir'];
 if(skyspace['place']<-400) {skyspace['place']+=400;}
 skyspace['place']%=400;
 if(Math.random()>.998) {skyspace['dir']*=-1;}
}


function TJPfloat() {
 sy=Math.floor(Math.sin(smokespace)*10+10);
 sx=Math.floor(Math.cos(smokespace)*3+3);
 //if(smokespace==0) {alert('about.css-be belerakni:'+sy+'px 0 0 '+sx+'px');}
 $('s_robot').style.margin=sy+'px 0 0 '+sx+'px';
 smokespace+=.05; if(smokespace>2*Math.PI) {smokespace-=2*Math.PI;}
 if($('inter1')) {
  for(i=1;i<cloudspace.length;i++) {
   if(cloudspace[i]['p'] >= stagespace) {cloudspace[i]['p']=-cloudspace[i]['w'];}
   else if(cloudspace[i]['p'] <= -cloudspace[i]['w']) {cloudspace[i]['p']=stagespace;}
   cloudspace[i]['p']-=1+cloudspace[i]['w']/200;
   TJPmovecloud(i,cloudspace[i]['p']);
  }
 }
 if($('s_ship')) {
  sy=Math.floor(Math.sin(shipspace)*3+3);
  sx=Math.floor(Math.cos(shipspace)*1+1);
  //if(shipspace==0) {alert('about.css-be belerakni:'+sy+'px 0 0 '+sx+'px');}
  $('s_ship').style.margin=-sy+'px 0 0 '+sx+'px';
  $('s_ship_top').style.height=(80+sy)+'px';
  shipspace+=.1; if(shipspace>2*Math.PI) {shipspace-=2*Math.PI;}
  if(Math.random()>.8) {
   for(si=1;si<=6;si++) {
     if(Math.random() > .97) {
      $('s_sheep'+si).style.backgroundPosition=-(si-1)*16+'px -32px';
     } else
     if(Math.random() > .7) {
      $('s_sheep'+si).style.backgroundPosition=-(si-1)*16+'px -16px';

     }
    //TJPjump('s_sheep'+si,0,0,0,-10-10*Math.random(),7);
   }
  }
 }
 if($('s_fish5')) {
  for(i=1;i<=5;i++) {
  if(dogspace['u']==1) {fishspace[i]['s']=1;}
   if(fishspace[i]['t'] < 490-fishspace[i]['e'] && fishspace[i]['s'] == 1) {
    fishspace[i]['s'] = 0;
   }
   else if(fishspace[i]['t'] >516+fishspace[i]['e']  && fishspace[i]['s'] == 0) {
    fishspace[i]['s'] = 1;
   } else if(Math.random()>0.95) {
    fishspace[i]['s'] = 1-fishspace[i]['s'];
   }
   
   $('s_fish'+i).style.backgroundPosition=-(i-1)*46+'px -'+fishspace[i]['s']*22+'px';
   tmp=.5; if(dogspace['u']==1) {tmp=2;}
   if(fishspace[i]['s'] == 0) {fishspace[i]['t']+=tmp;} else {fishspace[i]['t']-=tmp;}
   $('s_fish'+i).style.top=fishspace[i]['t']+'px';
   $('s_fish'+i).style.left=(i*50+Math.cos(shipspace+i)*3)+'px'
  }
  if(dogspace['u'] == 1) {
   dogspace['s']+=1/4; dogspace['s']%=3;
   if(Math.abs(dogspace['s']-Math.floor(dogspace['s'])) < .1) {
    $('s_scubadog').style.backgroundPosition='0 -'+dogspace['s']*38+'px';
   }
  }
 }
 if($('s_king_octopus')) {
  sy=Math.floor(Math.sin(shipspace)*4+4);
  sx=Math.floor(Math.cos(shipspace)*0+0);
  if(!jumpspace['s_king_octopus']) {
   $('s_king_octopus').style.margin=-sy+'px 0 0 '+sx+'px';
  }
 }
}

function TJPjump(id,xmin,ymin,xmax,ymax,steps) {
 if(jumpspace[id]) {return false;}
 if(id.indexOf('sheep') > -1) { $(id).style.backgroundPosition=-(id.substr(7,1)-1)*16+'px 0'; }
 tmp=new Array();
 out='';
 for(i=0;i<steps;i++) {
  ts=Math.sin((i/(steps-1))*Math.PI);
  tx=Math.floor(xmin+(xmax-xmin)*ts);
  ty=Math.floor(ymin+(ymax-ymin)*ts);
  tmp[i]="$('"+id+"').style.marginLeft='"+tx+"px'; $('"+id+"').style.marginTop='"+ty+"px';";
  if($(id+'_shadow')) {tmp[i]+="$('"+id+"_shadow').style.marginLeft='"+tx+"px';"}
  if(i == 0) {
   tmp[i]+="jumpspace['"+id+"']=1;";
  }
  if(i == steps-1) {
   tmp[i]+="delete jumpspace['"+id+"'];";
   if(id=='s_scubadog') {tmp[i]+="$('s_scubadog').style.backgroundPosition='0 0';dogspace['u']=0;";}
   if(id.indexOf('sheep') > -1) { tmp[i]+="$('"+id+"').style.backgroundPosition='-"+(id.substr(7,1)-1)*16+"px -16px';"; }
  }
 }
 ttt=Math.random();
 stispace[ttt]=tmp;
 //alert(tmp);
 setTI(ttt,50);
}

function tab_select_about(objid) {
 tid=objid.substr(5);
 tsatmp=$('abouttext').getElementsByTagName('div');
 for(j=0;j<tsatmp.length;j++) {
  if(tsatmp[j].className.indexOf('abouttextbox') > -1) {
   if(tsatmp[j].id == tid) {
    tsatmp[j].style.display='block';
    $('link_'+tsatmp[j].id).className='active';
   } else {
    tsatmp[j].style.display='none';
    $('link_'+tsatmp[j].id).className='';
   }
  }
 }
 return false;
}


//SWAP IMAGES MENU

function swap_m(tag_img_name,to_what_img_path) 
{
 var swap, towhat, ext;
 swap = eval('document.images.'+tag_img_name);
 swap.src = to_what_img_path;
}	



//PAGE CLIENT
// =================================================================
//                 ===== grid-html =====
// Script written by Gerard Ferrandez - January 9, 2009
// http://www.dhteumeuleu.com
// license: CC-BY-NC - do not remove this notice
// -----------------------------------------------------------------
// texts by Pola
// All sounds and images are credited to their respective authors
// =================================================================


/* ==== Easing function ==== */
function Ease (position) {
	this.position = position;
}
Ease.prototype = {
	// ---- ease ----
	ease : function () {
		if (this.m == 0 && this.s == -1) {
			this.moving = false;
			return this.position;
		}
		this.moving = true;
		this.m += this.s;
		this.position += (this.d * this.m * .0025);
		if (this.m == 20) this.s = -1;
		return this.position;
	},
	// ---- set target value ----
	setTarget : function (target) {
		this.target = target;
		this.m = 0;
		this.s = 1;
		this.d = target - this.position;
	}
}

var grid = {
	// ---- variables ----
	O : [],
	M : [],
	D : {},
	screen : {
		w : 0,
		h : 0
	},
	m : false,
	moving: false,

	/* ==== create HTML Elements ==== */
	createHTML : function (id, x, y) {
		// ---- resizable container ----
		var o = document.createElement('span');
		o.className = 'gridSpan';
		var p = document.getElementById(id);
		// ---- injection from HTML source ----
		if (p) o.innerHTML = p.innerHTML;
		grid.screen.obj.appendChild(o);
		// ---- variables ----
		grid.O.push(o);
		o.m = false;
		o.X = x;
		o.Y = y;
		o.c = o.childNodes[o.firstChild.nodeType == 3 ? 1 : 0]
		if (!grid.M[y]) grid.M[y] = [];
		grid.M[y][x] = o;
		grid.D[id] = o;
		// ---- create easing params ----
		o.w = new Ease(10);
		o.h = new Ease(10);
		o.x = new Ease(grid.screen.w / 2);
		o.y = new Ease(grid.screen.h / 2);

		/* ==== click event ==== */
		o.onmousedown = function (e) {
			if (window.event) e = window.event;
			var tg = (e.target) ? e.target : e.srcElement;
			// ---- different div ----
			if (this != grid.m) {
				if (grid.m) grid.m.m = false;
				grid.m = this;
				grid.position();
			} else {
				// ---- same div - protect clicks ----
				if ((tg.tagName == "IMG" || tg.className.indexOf('click') >= 0) && tg.parentNode.tagName != "A") {
					grid.m = false;
					grid.position();
				}
			}
			return false;
		}

		/* ==== HTML rendering ==== */
		o.animate = function () {
			var o   = this.style;
			o.left   = Math.round(this.x.ease()) + 'px';
			o.top    = Math.round(this.y.ease()) + 'px';
			o.width  = Math.round(this.w.ease()) + 'px';
			o.height = Math.round(this.h.ease()) + 'px';
			// ---- moving or not moving that's the question ----
			if (this.x.moving || this.y.moving) grid.moving = true;
		}
	},

	/* ==== init script ==== */
	init : function (ids, marg, nw, nh) {
		this.screen.obj = document.getElementById('screen');
		this.ids = ids;
		this.H = ids.length;
		this.L = 0;
		// ---- dimensions ----
		this.marg = marg;
		this.nw = nw;
		this.nh = nh;
		this.resize();
		// ---- click on background event ----
		this.screen.obj.onmousedown = function (e) {
			if (window.event) e = window.event;
			var tg = (e.target) ? e.target : e.srcElement;
			if (tg.id == "screen") {
				grid.m = false;
				grid.position();
			}
			return false;
		}
	},

	/* ==== build structure ==== */
	structure : function () {
		for (var i = 0; i < this.H; i++) this.L = Math.max(this.L, this.ids[i].length);
		for (var i = 0; i < this.H; i++) {
			var l = this.ids[i];
			for (var j = 0; j < l.length; j++) {
				var id = l[j];
				if (id) this.createHTML(id, j, i);
			}
		}
		// ---- Init complete ----
		grid.init = false;
		this.resize();
	},

	/* ==== set position targets ==== */
	position : function () {
		// ---- collapsed position ----
		var x = (grid.screen.w - (grid.L * grid.nw)) / 2;
		var y = (grid.screen.h - (grid.H * grid.nh)) / 2;
		var i = 0, o;
		while( o = grid.O[i++] ) {
			o.w.setTarget(grid.nw - grid.marg);
			o.h.setTarget(grid.nh - grid.marg);
			o.x.setTarget(x + grid.marg + o.X * grid.nw);
			o.y.setTarget(y + grid.marg + o.Y * grid.nh);
		}
		// ---- expanded div ----
		if (grid.m) {
			// ---- expanded position ----
			grid.m.w.setTarget(grid.m.c.offsetWidth);
			grid.m.h.setTarget(grid.m.c.offsetHeight);
			grid.m.x.setTarget(grid.marg + (grid.screen.w - grid.m.w.target) / 2);
			grid.m.y.setTarget(grid.marg + (grid.screen.h - grid.m.h.target) / 2);
			// ---- bottom y ----
			var y = grid.m.y.target;
			for (var i = grid.m.Y; i < grid.H; i++) {
				for (var j = 0; j < grid.L; j++) {
					var o = grid.M[i][j];
					if (o) o.y.setTarget(y);
				}
				y += grid.nh;
			}
			// ---- top y ----
			var y = grid.m.y.target - grid.nh;
			for (var i = grid.m.Y - 1; i >= 0; i--) {
				for (var j = 0; j < grid.L; j++) {
					var o = grid.M[i][j];
					if (o) o.y.setTarget(y);
				}
				y -= grid.nh;
			}
			// ---- right x y ----
			var y = grid.m.y.target + grid.m.h.target + grid.marg;
			for (var i = 0; i < grid.H; i++) {
				var o = grid.M[i][grid.m.X];
				if (o) {
					o.x.setTarget(grid.m.x.target);
					if (i > grid.m.Y) {
						o.y.setTarget(y);
						y += o.h.target + grid.marg;
					}
				}
			}
			// ---- left x ----
			var x = grid.m.x.target - grid.nw;
			for (var i = grid.m.X - 1; i >= 0; i--) {
				for (var j = 0; j < grid.H; j++) {
					var o = grid.M[j][i];
					if (o) o.x.setTarget(x);
				}
				x -= grid.nw;
			}
			// ---- right x ----
			var x = grid.m.x.target + grid.m.w.target + grid.marg;
			for (var i = grid.m.X + 1; i < grid.L; i++) {
				for (var j = 0; j < grid.H; j++) {
					var o = grid.M[j][i];
					if (o) o.x.setTarget(x);
				}
				x += grid.nw;
			}
		}
		// ---- start animation if not already running ----
		if (!grid.sid) grid.sid = setInterval(grid.run, 32);
	},

	/* ==== goto id ==== */
	goto : function (id) {
		if (grid.D[id]) {
			if (grid.m) grid.m.m = false;
			grid.m = grid.D[id];
			grid.position();
		}
	},

	/* ==== resize event ==== */
	resize : function () {
		var o = grid.screen.obj;
		if (o && o.offsetWidth) {
			grid.screen.h = o.offsetHeight - grid.marg;
			grid.screen.w = o.offsetWidth - grid.marg;
			// ---- step 1: DOM loaded - step 2: createHTML - step 3: resize ----
			if (!grid.init) grid.position(); else grid.structure();
		} else setTimeout(grid.resize, 32);
	},

	/* ==== main loop ==== */
	run : function () {
		// ---- divs ----
		grid.moving = false;
		var i = 0, o;
		while( o = grid.O[i++] ) o.animate();
		// ---- scroll background ----
		grid.screen.obj.style.backgroundPosition = Math.round(-grid.O[0].x.position * .5) + 'px ' + Math.round(-grid.O[0].y.position * .5) + 'px';
		// ---- stop animation if nothing is moving ----
		if (!grid.moving && grid.sid) {
			clearInterval(grid.sid);
			grid.sid = false;
		}
	}
}

/** Page recrutement **/
var posteToHide = 0;
function showPoste(idJSPoste, idDBPoste, jobName) {
	document.getElementById('poste' + posteToHide).style.visibility = "hidden";
	document.getElementById('poste' + idJSPoste).style.visibility = "visible";
	document.getElementById('idPoste').value = idDBPoste;
	document.getElementById('career').value = jobName;
	document.getElementById('job_name').innerHTML = jobName;
	posteToHide = idJSPoste;
}
function showJobForm() {
	document.getElementById('recrutement').style.display = 'none';
	document.getElementById('formApplic').style.display = 'block';
}
function hideApplicForm() {
	document.getElementById('recrutement').style.display = 'block';
	document.getElementById('formApplic').style.display = 'none';
}
function checkRecrutement(frm,lang){
	message = '';
	error = false;
	if(lang=='1'){
		var msg_surnom='Please enter your surname.';
		var msg_prenom='Please enter your name.';
		var msg_email='Please enter your email.';
		var valid_email = 'Please enter a valid email address.';
		var msg_telephone='Please enter your telephone number and/or mobile number.';
		var msg_numeric = 'Please enter numbers for telephone and/or mobile.';
		var msg_cv='Please browse your cv.';
	}else{
		var msg_surnom='Veuillez entrer votre nom.';
		var msg_prenom='Veuillez entrer votre pr\351nom';
		var msg_email='Veuillez entrer votre adresse d\'email.';
		var valid_email ='Veuillez entrer une adresse email valide.';
		var msg_telephone='Veuillez entrer votre num\351ro de t\351l\351phone et/ou mobile.';
		var msg_numeric = 'Veuillez entrer des chiffres pour votre num\351ro de t\351l\351phone et/ou mobile.';
		var msg_cv='Veuillez joindre votre cv.';
	}

	if(!checkEmpty(frm.surnom)){
		message = message + msg_surnom;
		error = true;
	}
	
	if(!checkEmpty(frm.prenom)){
		message = message + "\n" + msg_prenom;
		error = true;
	}
	
	if(!checkEmpty(frm.email)){
		message = message + "\n" + msg_email;
		error = true;
	}
	
	if(!validateMail(frm.email,lang)){
		message = message + "\n" + valid_email;	
		error = true;	
	}
	
	/*********************************Ajout de Souraksha*****************************/
	
	//either telephone or mobile have to be filled, it is not necessary that both are filled in
	if(!checkEmpty(frm.telephone) && !checkEmpty(frm.mobile)) {
		message = message + "\n" + msg_telephone;
		error = true;
	}			
	if (!IsNumeric(frm.telephone.value) || !IsNumeric(frm.mobile.value)) {
		if (!IsNumeric(frm.telephone.value) && !IsNumeric(frm.mobile.value)) {
		message = message + "\n" + msg_numeric;
		error = true;
		}
		else{
		message = message + "\n" + msg_numeric;
		error = true;
		}
	}
	/********************************************************************************/
	if(!checkEmpty(frm.cv)){
		message = message + "\n" + msg_cv;
			error = true;
	}
								
	if(error == true){
		alert(message);
		return false;
		
	}else{
		return true;
	}	
}

function checkEmpty(input){
	if(trim(input.value)==''){
 		return false;
 	}else{
 		return true;
 	}
}

function validateMail(input,lang){
	var email = input.value;
	var chars = "[^]*\()<>,;:[]$#!%&{}";
	var error = false;
	var index1 = email.indexOf("@");
	var index2 = email.indexOf(".");
	var sub1 =  email.substring(index1+1);
	var sub2 =	email.substring(index2+1);	
	
	
	if(index1 == -1){
		 error = true;
	}	
	if(index2 == -1) {
		 error = true;
	}

	if(index2<index1){
		error = true;
	}
	
	for(i=0; i<email.length; i++){
		if(email.indexOf(chars[i])!= -1){
		   error = true;
		}
	}
	//verifying if there is no two '@' in the email
	if((sub1.indexOf("@")!= -1)){
	   error = true;
	}

	//verifying if there is no two '.' in the email
	if((sub2.indexOf(".")!= -1)){
	   error = true;
	}
	
	if(error == true){
		return false;
	}
	else{
	
	return true;
	}
}

function IsNumeric(sText) {
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
	  Char = sText.charAt(i); 
	  if (ValidChars.indexOf(Char) == -1) 
	  {
		 IsNumber = false;
	  }
   }
   return IsNumber;
}
function trim (str) {
	return str.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, ''); 
}
/** end page recrutement **/


//validation email
function validateMail(input,lang){
	var email = input.value;
	var chars = "[^]*\()<>,;:[]$#!%&{}";
	var error = false;
	var index1 = email.indexOf("@");
	var index2 = email.indexOf(".");
	var sub1 =  email.substring(index1+1);
	var sub2 =	email.substring(index2+1);	
	
	
	if(index1 == -1){
		 error = true;
	}	
	if(index2 == -1) {
		 error = true;
	}

	if(index2<index1){
		error = true;
	}
	
	for(i=0; i<email.length; i++){
		if(email.indexOf(chars[i])!= -1){
		   error = true;
		}
	}
	//verifying if there is no two '@' in the email
	if((sub1.indexOf("@")!= -1)){
	   error = true;
	}

	//verifying if there is no two '.' in the email
	if((sub2.indexOf(".")!= -1)){
	   error = true;
	}
	
	if(error == true){
		return false;
	}
	else{
	
	return true;
	}
}


function checkEmpty(input){
	if(input.value==''){
 		return false;
 	}else{
 		return true;
 	}
}	

function IsNumeric(sText) {
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
	  Char = sText.charAt(i); 
	  if (ValidChars.indexOf(Char) == -1) 
	  {
		 IsNumber = false;
	  }
   }
   return IsNumber;
}

function get_radio_value()
{
for (var i=0; i < document.FormName.rad01.length; i++)
   {
   if (document.FormName.rad01[i].checked)
      {
      var rad_val = document.FormName.rad01[i].value;
      }
   }
}

function valideForm(frm,lang)
{
	message = '';
	error = false;
	if(lang=='1'){
		var msg_surnom='Please enter your surname.';
		var msg_prenom='Please enter your name.';
		var msg_email='Please enter your email.';
		var valid_email = 'Please enter a valid email address.';
		var msg_telephone='Please enter your telephone number.';
		var msg_numeric = 'Please enter numbers for telephone.';
		var msg_url='Please enter the url of your website';
	}else{
		var msg_surnom='Veuillez entrer votre nom.';
		var msg_prenom='Veuillez entrer votre pr\351nom';
		var msg_email='Veuillez entrer votre adresse d\'email.';
		var valid_email ='Veuillez entrer une adresse email valide.';
		var msg_telephone='Veuillez entrer votre num\351ro de t\351l\351phone.';
		var msg_numeric = 'Veuillez entrer des chiffres pour votre num\351ro de t\351l\351phone .';
		var msg_url='Veuillez entrer votre url de votre site.';
	}
	
	
	if(!checkEmpty(frm.nom)){
		message = message + msg_surnom;
		error = true;
	}
	if(!checkEmpty(frm.prenom)){
		message = message + "\n" + msg_prenom;
		error = true;
	}
	if(!checkEmpty(frm.email)){
		message = message + "\n" + msg_email;
		error = true;
	}
	if(!checkEmpty(frm.tel)){
		message = message + "\n" + msg_telephone;
		error = true;
	}
	
	if(!validateMail(frm.email,lang)){
		message = message + "\n" + valid_email;	
		error = true;	
	}
	

	if (!IsNumeric(frm.tel.value)) {
		message = message + "\n" + msg_numeric;
		error = true;
	}



for (var i=0; i < document.FormName.rad01.length; i++)
   {
   if (document.FormName.rad01[i].checked)
      {
      var rad_val = document.FormName.rad01[i].value;
      }
   }
	
	if(rad_val=='1'){
	    if(!checkEmpty(frm.url)){
	    message = message + "\n" + msg_url;
		error = true;
		}
		
	}

	if(error == true){
		alert(message);
		return false;
		
	}else{
		frm.submit();
	}	
	
	
}
var menuGchDefault;
var menuGchToHide;
var arrayImgGch = new Array();

function showMenuDefault() {
	if(document.getElementById('menuli_' + menuGchDefault + '_menusousmenu_1') != null) {
		document.getElementById('menuli_' + menuGchDefault + '_menusousmenu_1').style.display="block";
	}
	for(var i =0;i < arrayImgGch.length;i++) {
		if(arrayImgGch[i] != undefined && i != menuGchDefault){
			addEventMenu('id_m' + i, "mouseover", swap_im);
			addEventMenu('id_m' + i, "mouseout", swap_im);
		}
	}
	if(menuGchDefault != null) {
		menuGchToHide = menuGchDefault;
	}
	document.getElementById("Menu").style.display = "block"
}

function showMenuGch(idMenu) {
	//si l'id du menu select� est pareille comme le menu precedent
	if(idMenu == menuGchToHide) {
		//si le menu n'est pas ouvert
		if(document.getElementById('menuli_' + idMenu + '_menusousmenu_1').style.display == "none") {
			//ouvrir le menu
			if(document.getElementById('menuli_' + idMenu + '_menusousmenu_1') != null) {
				document.getElementById('menuli_' + idMenu + '_menusousmenu_1').style.display = "block";
			}
			//activer le menu
			removeEventMenu('id_m' + idMenu, 'mouseover', swap_im);
			removeEventMenu('id_m' + idMenu, 'mouseout', swap_im);
		}
		else {
			if(document.getElementById('menuli_' + idMenu + '_menusousmenu_1') != null) {
				//cacher le menu
				document.getElementById('menuli_' + idMenu + '_menusousmenu_1').style.display = "none";
			}
			// ajouter le 'rollover effect' au menu deselectionn�
			addEventMenu('id_m' + idMenu, "mouseover", swap_im);
			addEventMenu('id_m' + idMenu, "mouseout", swap_im);
		}
	}
	else {
		if(document.getElementById('menuli_' + menuGchToHide + '_menusousmenu_1') != null) {
			//cacher le menu precedemment select�
			document.getElementById('menuli_' + menuGchToHide + '_menusousmenu_1').style.display="none";
		}
		//remplacer l'image actif, du menu selection� precedemment, par l'image non-actif
		document.getElementById('id_m' + menuGchToHide).src = arrayImgGch[menuGchToHide][1];
		
		//ajout� les 'events' onmouseover et onmouseout pour le menu precedent
		addEventMenu('id_m' + menuGchToHide, "mouseover", swap_im);
		addEventMenu('id_m' + menuGchToHide, "mouseout", swap_im);
		
		//retirer les 'events' onmouseover et onmouseout du menu selection�
		removeEventMenu('id_m' + idMenu, 'mouseover', swap_im);
		removeEventMenu('id_m' + idMenu, 'mouseout', swap_im);
		
		removeEventMenu('id_m' + idMenu, 'mouseover', swap_m);
		removeEventMenu('id_m' + idMenu, 'mouseout', swap_m);
				
		document.getElementById('id_m' + idMenu).src = arrayImgGch[idMenu][0];

		//montrer le menu passer en parametre
		document.getElementById('menuli_' + idMenu + '_menusousmenu_1').style.display="block";

		menuGchToHide = idMenu;
	}
}

function addEventMenu(obj,type,fn){
	if(window.addEventListener){
		document.getElementById(obj).addEventListener(type, fn, false);
	}
	else if(window.attachEvent){
		document.getElementById(obj).attachEvent("on" + type,fn);
	}
}

function removeEventMenu(obj,type,fn){
	if(window.removeEventListener) {
		document.getElementById(obj).removeEventListener(type, fn, false);
	}
	else if(window.detachEvent){
		document.getElementById(obj).detachEvent("on" + type,fn);
	}
}
function swap_im(evt) {
	var img_id = (evt.srcElement != undefined?evt.srcElement:evt.target);
	var img_index = img_id.id.substring(4, img_id.id.length)
	if(img_id.src == arrayImgGch[img_index][0]) {
		img_id.src = arrayImgGch[img_index][1];
	}
	else {
		img_id.src = arrayImgGch[img_index][0];
	}
}

	var path = new Array();
	//path = 'file/logo/';
	var opacity = 80;
	var height = 75;
	var radiusx = 300;
	var radiusy = 35;
	var centerx = 160;
	var centery = 60;
	var base = 0.15;
	var speed = 0.05;
	var clickit = false;
/*************************************************************************************/
/*********  Fonction pour l'effet des logos des clients sur la page home ************/
/*******************************par Souraksha***************************************/
function logoClients(logoArray){
		
	images = new Array();
	
	for(var i=0; i<logoArray.length; i++){
		images.push(logoArray[i][0]);
		path[i] = 'file/logo/' + logoArray[i][1]+ "/";
	}	
	
	carouselRun();
}

/* 
   JavaScript Document
   Written by Ikonic (Pellevillain Cdric)
   Copyright (c) 2008 Piksite.com 
   ---------------------------------------
   Some rights reserved. This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License.
   
   You are free:

    * to Share  to copy, distribute and transmit the work
    * to Remix  to adapt the work

   Under the following conditions:

    * Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
    * Noncommercial. You may not use this work for commercial purposes.

    * For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
    * Any of the above conditions can be waived if you get permission from the copyright holder.
    * Nothing in this license impairs or restricts the author's moral rights.
   
   If you want to include this work in a selling package, mail me : contact@piksite.com        
*/


var counter = 0; 
var tempX = 0;
var elt_posX,elt_posY,b;
var elements = new Array();
var clear="_css/clear.gif" 

// During page on load
function carouselRun() { 
	i = 0 ;
  // create each element
  images.each(function(photo) {
     
      id_div = photo.split(".");
      var id = id_div[0];
      var div = new Element('div', { 'id': id, 'class': 'image', 'styles': { 'position': 'absolute', 'opacity': '0' } }).inject('container'); 
      if(clickit!=false) { 
        div.addEvent('click', Click);
        div.setStyle('cursor', 'pointer');
      }
      var img = new Element('img', { 'src': 'reflect.php?img='+path[i]+photo+'&height='+height+'&start_fade='+opacity }).inject(div);
      elements.include(id);
      i++;	
    });
  
  if(Browser.Engine.trident4) { 
    elements.each(function(element) {
      var el = $(element).getFirst();
      el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";
      el.src = clear;
    });
  }
    
  open();

};

// DropOut Effect
DropOut = function(element) {
  element = $(element);
  var oldtop = element.getStyle('top').toInt();  
  
  var DropOutEffect = new Fx.Morph(element, {duration: 500, transition: Fx.Transitions.Sine.easeOut, onComplete: function() { element.setStyle('top', oldtop) } });
  DropOutEffect.start({'top': [oldtop+'px', oldtop+100+'px'], 'opacity': [1, 0]});
}

// create each element
function open() { 

  // appear each element
  elements.each(function(element) {
  	var appear_effect = new Fx.Morph(element, {duration: 800, transition: Fx.Transitions.Sine.easeOut });
    appear_effect.start({ 'opacity': [0, 1] });  
  });
  
  // start carousel   
  b = setInterval('carousel()',40);
 
  // set mouse events
  function position(e) {
    if (navigator.appName.substring(0,3) == "Net") {
      tempX = e.pageX;
    } else {
      tempX = event.x+document.body.scrollLeft;
    }
 	  move();
  }
  // VANESSA  prevent moving on mouse over
  //document.onmousemove = position;
  //document.onmouseout = out; 
  
}

// on mouse move on main container
function move() {	
	speed = (tempX - centerx) / 2500;
	base = 0.05;	
}

// on mouse out from main container
function out() {	
	speed = speed;	
}

// Change image event to back
function textIt(elt) {
  elt = $(elt);
  elt.removeEvent('click', Click);
  elt.addEvent('click', Back);
}

// Change image event to click
function untextIt(elt) {
  elt = $(elt);
  elt.removeEvent('click', Back);
  elt.addEvent('click', Click);
}

// Back to carousel
function Back(elt) {

  if(typeof elt == 'object') { elt = this.id; }
  
  // define actions
  var appearer = '';
  elements.each(function(photo) {
    if(photo!=elt) { 
      appearer += "var AppearEffect = new Fx.Morph($('"+photo+"'), {duration: 500, transition: Fx.Transitions.Sine.easeOut }); AppearEffect.start({visibility: ['hidden', 'visible'], 'opacity': [0, 1]});";
    } else {
      appearer += "$('"+photo+"').morph({left: "+elt_posx+", top: "+elt_posy+"});";
    }
  });
  appearer += "var TextEffect = new Fx.Morph($('text'), {duration: 500, transition: Fx.Transitions.Sine.easeOut, onComplete: function() { untextIt('"+elt+"'); $('text').innerHTML = ''; b = setInterval('carousel()',40); } }); TextEffect.start({visibility: ['visible', 'hidden'], 'opacity': [1, 0]});";

  // do actions
  eval(appearer);  
  
}

function Click() {

  elt = this.id;
  
  // stop carousel
  $clear(b);
  
  // get clicked element positions
  elt_posx = this.getStyle('left').toInt();
  elt_posy = this.getStyle('top').toInt();
  
  // define actions
 var fader= '';
 elements.each(function(photo) {
    if(photo!=elt) { 
      fader += "DropOut('"+photo+"');";
    } else {
      fader += "$('"+photo+"').morph({left: 0, top: 0});";
    }
  });
  fader += "var TextEffect = new Fx.Morph($('text'), {duration: 500, transition: Fx.Transitions.Sine.easeOut, onStart: function() { requestText('"+elt+"') }, onComplete: function() { textIt('"+elt+"') } }); TextEffect.start({visibility: ['hidden', 'visible'], 'opacity': [0, 1]});";

  // do actions
  eval(fader);
  
}

// request text
function requestText(elt) {
  var url = includes+'page.php';  
  new Request.HTML({url:url, 
    onSuccess: function(html) {
      $('text').adopt(html);
    },
    onFailure: function() {
      $('text').set('html', 'An error occurred. Please re-try.');
    }
  }).get({'item': elt});
}

// carousel 
function carousel() {
 elements.each(function(photo, i) {
		angle = i*2*Math.PI/elements.length;		
		posx = centerx+Math.sin(counter*(base*speed)+angle)*radiusx;
		posy = centery+Math.cos(counter*(base*speed)+angle)*radiusy;
    $(photo).setStyles({ left: posx+'px', top: posy+'px', zIndex: Math.round(posy/3)+100 });
		angle += speed;	
	});	
	counter++
}