var SITE_ROOT;
var SITE_LANG;
var SB = [];

var Sk_TablePager = new Class({
	table : null,
	first : null,
	prev : null,
	pgs : null,
	next : null,
	last : null,
	nbperpg : 10,
	curpage : 1,
	nbpgs : 0,
	initialize : function(table,first,prev,pgs,next,last,nbperpg){
		this.table = table;
		this.first = first;
		this.prev = prev;
		this.pgs = pgs;
		this.next = next;
		this.last = last;
		this.nbperpg = nbperpg;
		
		var trs = this.table.getElements('tr');
		
		if ( trs.length <= nbperpg){
			return;
		}
		
		var nbpgs = Math.ceil(trs.length/this.nbperpg);
		this.nbpgs = nbpgs;
		for(var i=0,j=nbpgs;i<j;i++){
			var a = new Element('a', {text:(i+1)}).inject(this.pgs);
			if (i<nbpgs-1)	new Element('span', {text:'.'}).inject(this.pgs);
			a.addEvent('click', this.chgPage.bind(this,a) );
		}
		this.first.addEvent('click', this.setPageFirst.bind(this) );
		this.prev.addEvent('click', this.setPagePrev.bind(this) );
		this.next.addEvent('click', this.setPageNext.bind(this) );
		this.last.addEvent('click', this.setPageLast.bind(this) );
		
		this.refreshTable();
	},
	
	chgPage : function(a){
		var newpage = a.innerHTML;
		this.curpage = parseInt(newpage);
		this.refreshTable();
	},
	
	setPage : function(nb){
		var newpage = nb;
		this.curpage = parseInt(newpage);
		this.refreshTable();
	},
	
	setPageFirst : function(){
		if ( this.first.hasClass('disable') ) return;
		this.curpage = 1;
		this.refreshTable();
	},
	
	setPagePrev : function(){
		if ( this.prev.hasClass('disable') ) return;
		this.curpage--;
		this.refreshTable();
	},
	
	setPageNext : function(){
		if ( this.next.hasClass('disable') ) return;
		this.curpage++;
		this.refreshTable();
	},
	
	setPageLast : function(){
		if ( this.last.hasClass('disable') ) return;
		this.curpage = this.nbpgs;
		this.refreshTable();
	},
	
	refreshTable : function(){
		var trs = this.table.getElements('tr');
		trs.setStyle('display','none');
		var first = (this.curpage-1) * this.nbperpg;
		var last = first + this.nbperpg;
		var islastpage = false;
		if ( last >= trs.length ) {
			last = trs.length;
			islastpage = true;
		}
		for(var i=first,j=last;i<j;i++){
			trs[i].style.display = 'block';
		}
		var as = this.pgs.getElements('a');
		as.removeClass('selected');
		var id = parseInt(this.curpage-1);
		as[id].addClass('selected');
		//alert(islastpage);
		if ( id == 0 ){
			this.first.addClass('disable');
			this.prev.addClass('disable');
			this.next.removeClass('disable');
			this.last.removeClass('disable');
		}
		else if ( islastpage == true ){
			this.first.removeClass('disable');
			this.prev.removeClass('disable');
			this.next.addClass('disable');
			this.last.addClass('disable');
		}
		else {
			this.first.removeClass('disable');
			this.prev.removeClass('disable');
			this.next.removeClass('disable');
			this.last.removeClass('disable');
		}
	}
	
});



var Sk_ItemsPager = new Class({
	divs : null,
	prev : null,
	next : null,
	nbperpg : 10,
	curpage : 1,
	nbpgs : 0,
	initialize : function(divs,prev,next,nbperpg){
		this.divs = divs;
		this.prev = prev;
		this.next = next;
		this.nbperpg = nbperpg;
		
		if ( this.divs.length <= nbperpg){
			return;
		}
		
		var nbpgs = Math.ceil(this.divs.length/this.nbperpg);
		this.prev.addEvent('click', this.setPagePrev.bind(this) );
		this.next.addEvent('click', this.setPageNext.bind(this) );
		
		this.refreshDivs();
	},
	
	setPagePrev : function(){
		if ( this.prev.hasClass('disable') ) return;
		this.curpage--;
		this.refreshDivs();
	},
	
	setPageNext : function(){
		if ( this.next.hasClass('disable') ) return;
		this.curpage++;
		this.refreshDivs();
	},
	
	refreshDivs : function(){
		this.divs.setStyle('display','none');
		var first = (this.curpage-1) * this.nbperpg;
		var last = first + this.nbperpg;
		var islastpage = false;
		if ( last >= this.divs.length ) {
			last = this.divs.length;
			islastpage = true;
		}
		for(var i=first,j=last;i<j;i++){
			this.divs[i].style.display = 'block';
		}
		var id = parseInt(this.curpage-1);
		
		if ( id == 0 ){
			this.prev.addClass('disable');
			this.next.removeClass('disable');
		}
		else if ( islastpage == true ){
			this.prev.removeClass('disable');
			this.next.addClass('disable');
		}
		else {
			this.prev.removeClass('disable');
			this.next.removeClass('disable');
		}
	}
	
});



window.addEvent('domready', function(){
	
		
});

var geocoder;
var map;
function initialize() {
	geocoder = new google.maps.Geocoder();
	var latlng = new google.maps.LatLng(-34.397, 150.644);
	var myOptions = {
      zoom: 15,
	  center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

function showMap(a){
	adr = a;
	var co = a.split('@#@');
	var latlng = new google.maps.LatLng(co[0],co[1]);
	
	map.setCenter(latlng);
	var marker = new google.maps.Marker({
		map: map, 
		position: latlng
	});
	$('deptsmapdivc').style.height = '270px';
	$('map_canvas').style.visibility = 'visible';
	//adr = a.getParent('div').getElement('p.query').innerHTML;
	/*
	geocoder.geocode( { 'address': adr}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
		map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map, 
            position: results[0].geometry.location
        });
		$('deptsmapdivc').style.height = '270px';
		$('map_canvas').style.visibility = 'visible';
      } else {
        //alert("Geocode was not successful for the following reason: " + status);
		$('map_canvas').style.visibility = 'hidden';
		$('deptsmapdivc').style.height = '0px';
		
      }
    });
	*/
	//alert(escape(adr));
	//window.open (SITE_ROOT+'gmap.php?adr='+escape(adr));
	return false;
}

function closePopup(){
	$('popupmask').style.display = 'none';
	$('popupinsc').style.display = 'none';
}

function initInscForm(id, kind){ // kind 1 = prod, 2 = service
	$('popupmask').style.display = 'block';
	var maskheight = (Browser.Engine.trident) ? document.documentElement.clientHeight : document.body.clientHeight;
	$('popupmask').style.height = maskheight+'px';
	if ( Browser.Engine.trident ){
		$('popupmask').style.top = window.getScroll().y+'px';
	}
	var y = window.getSize().y;
	var ypos = 0;
	if (y >550 ) ypos = (y - 530) / 2;
	$('popupinsc').style.top = (ypos+window.getScroll().y)+'px';
	$('popupinsc').style.display = 'block';
	new Request.HTML({onComplete: ajaxComplete}).get(SITE_ROOT+'inscform.php?id='+id+'&lang='+SITE_LANG+'&kind='+kind);
}

function submitInsc(){
	var d = $('inscform');
	$('popupsubmitbutton').style.visibility = 'hidden';
	new Request.HTML({url: SITE_ROOT+'inscform.php?lang='+SITE_LANG, onComplete: ajaxComplete}).post(d);
	return false;
}

function ajaxComplete(responseTree, responseElements, responseHTML, responseJavaScript){
	//alert(responseHTML);
	$('forminscbody').innerHTML = responseHTML;
	//var bloc = responseTree[0].getElements('bloc');
}

onload = function(){
	if($('map_canvas')){
		initialize();

	}
	
	if ( $('homeswf') ){
		new Swiff(SITE_ROOT+'voeux.swf', {
			id: 'voeuxswf',
			width: 750,
			height: 400
		}).inject($('homeswf'));
	}
	
	if($('occtable')){
		var trs = $('occtable').getElements('tr');
		for(var i=0,j=trs.length;i<j;i++){
			if(i%2==1) trs[i].addClass('odd');
		}
	}
	
	if ( $('jsmenu') ){
		var as = $('jsmenu').getElements('a');
		for(var i=0,j=as.length;i<j;i++){
			as[i].onmouseover = function(){
				var a = $('jsmenu').getElement('a.on');
				if ( a ){
					a.removeClass('on');
					a.addClass('off');
				}
			}
			as[i].onmouseout = function(){
				var a = $('jsmenu').getElement('a.off');
				if ( a ){
					a.removeClass('off');
					a.addClass('on');
				}
			}
		}
	}
	
	var ts = $$('div.toscroll');
	for(var i=0,j=ts.length;i<j;i++){
		
		SB[ts[i].getProperty('id')] = new ScrollBar(ts[i], {
			'arrows': false,
			'hScroll': false,
			'maxThumbSize': 1,
			'wheel': 30
		});
	}
	
	ts = $$('div.toscroll2');
	for(var i=0,j=ts.length;i<j;i++){
		//alert(ts[i].id);
		SB = new ScrollBar(ts[i], {
			'arrows': true,
			'hScroll': true,
			'maxThumbSize': 1,
			'wheel': 30
		});
	}
	
	var selects = $$('div.fakeselect');
	for(var i=0,j=selects.length;i<j;i++){
		//alert(ts[i].id);
		var options = selects[i].getElements('p.option');
		for(var m=0,n=options.length;m<n;m++){
			options[m].onclick = function(){
				var p = $(this).getParent('div.fakeselect');
				var val = p.getElement('div.fakeselectvalue');
				val.innerHTML = this.innerHTML;
				val.setProperty('name', this.getProperty('name'));
				p.getElement('div.options').style.display = 'none';
				eval(p.getProperty('name')+'();');
			}
			options[m].onmouseover = function(){
				var d = $(this);
				d.addClass('hover');
			}
			options[m].onmouseout = function(){
				var d = $(this);
				d.removeClass('hover');
			}
		}
		
		if ( options.length > 10 ){
			var d = selects[i].getElement('div.options');
			d.addClass('optionsscroll');
		}
		selects[i].getElement('div.options').style.display = 'none';
		var val = selects[i].getElement('div.fakeselectvalue');
		val.innerHTML = options[0].innerHTML;
		val.setProperty('name', options[0].getProperty('name'));
		var arrow = selects[i].getElement('div.fakeselectarrow');
		arrow.onclick = function(){
			var p = $(this).getParent('div.fakeselect');
			var opt = p.getElement('div.options');
			toggleDisplay(opt);
		};
		val.onclick = function(){
			var p = $(this).getParent('div.fakeselect');
			var opt = p.getElement('div.options');
			toggleDisplay(opt);
		};
	}
	//$('paysform').getElement('div.fakeselectvalue').setProperty('name','france')
	if ( $('conceptcontent') ){
		//filtreVilles();
		$('conceptcontent').style.visibility = 'visible';
	}
	
	if ( $('prodcontent') ){
		//filtreVilles();
		$('prodcontent').style.visibility = 'visible';
	}
	
	if ( $('actifbrcontent') ){
		//filtreVilles();
		$('actifbrcontent').style.visibility = 'visible';
	}
	
	if ( $('paysform') ){
		filtreVilles();
		$('shopscontent').style.visibility = 'visible';
	}
	
	if ( $('presseform') ){
		filtrePresse();
		$('pressecontent').style.visibility = 'visible';
	}
	
	if ( $('faq') ){
		$('faq').style.visibility = 'visible';
		//faqtoggle( $('faq').getElements('div.faq')[0].getElement('div.faq-question') );
	}
	
	$$('div.scrollmask').setStyle('visibility', 'visible');
	
	var t = 'test';
	
	var deroul = $('deroulcontent');
	if ( deroul ){
		var tds = deroul.getElements('td.lastart');
		var arts_nb = tds.length;
		
		if ( arts_nb > 1 ){
			$('deroularrowleft').style.display = 'block';
			$('deroularrowright').style.display = 'block';
			var options = {
				nbItems : arts_nb,
				itemVisible : 1,
				itemSize : 229,
				deroulWay : 'horizontal',
				deroulSpeed : 600,
				deroulFx : Fx.Transitions.Quad.easeInOut,
				posInfo : 'deroulcompte',
				autoPlay : 5000,
				zoom : $('deroularrowzoom')
			};
			smallderoul = new SkDeroul( $('deroulcontent'), $('deroularrowleft'), $('deroularrowright'), options );
		}
	}
	
	var deroul = $('deroulhomecontent');
	if ( deroul ){
		var tds = deroul.getElements('td.lastart');
		var arts_nb = tds.length;
		
		if ( arts_nb > 1 ){
			$('deroularrowleft').style.display = 'block';
			$('deroularrowright').style.display = 'block';
			var options = {
				nbItems : arts_nb,
				itemVisible : 1,
				itemSize : 500,
				deroulWay : 'horizontal',
				deroulSpeed : 600,
				deroulFx : Fx.Transitions.Quad.easeInOut,
				autoPlay : 5000,
				contentDisplay : 'txtdiv'
			};
			smallderoul = new SkDeroul( $('deroulhomecontent'), $('deroularrowleft'), $('deroularrowright'), options );
		}
	}
	
	var deroul = $('deroulprodcontent');
	if ( deroul ){
		var tds = deroul.getElements('td.lastart');
		var arts_nb = tds.length;
		
		if ( arts_nb > 1 ){
			$('deroularrowleft').style.display = 'block';
			$('deroularrowright').style.display = 'block';
			
		}
		var options = {
			nbItems : arts_nb,
			itemVisible : 1,
			itemSize : 500,
			deroulWay : 'horizontal',
			deroulSpeed : 600,
			deroulFx : Fx.Transitions.Quad.easeInOut,
			autoPlay : 5000,
			zoom : $('deroularrowzoom')
		};
		smallderoul = new SkDeroul( $('deroulprodcontent'), $('deroularrowleft'), $('deroularrowright'), options );
	}
	
	
	depts = $$('div.deptdiv');
	
	if ( depts.length > 0 ){
		//alert('ha');
		var deptsfound = [];
		for(var i=0,j=depts.length;i<j;i++){
			var id = 'sel'+(i+1);
			depts[i].set('id', id);
			//alert(depts[i]);
			/*
			var cp = depts[i].get('name');
			found = false;
			for(var m=0,n=deptsfound.length;m<n;m++){
				if ( deptsfound[m] == cp ){
					found = true;
				}
			}
			if (found == false){
				deptsfound.push(cp);
			}
			*/
			var d = new Element('p', {'text':depts[i].getFirst('p').get('text')}).inject($('deptoptions'));
			d.store('matchid', id);
			d.onclick = function(){showDept(this);};
		}
		/*
		deptsfound.sort();
		for(var i=0,j=deptsfound.length;i<j;i++){
			var d = new Element('p', {'text':deptsfound[i]}).inject($('deptoptions'));
			d.onclick = function(){showDept(this);};
		}
		*/
		if ( depts.length > 8 ){
			$('deptoptions').addClass('scrollv');
		}
	}
	
	if ( $('menubluemoving') ){
		var dim = $('menubluemoving').getSize().y;
		$('menubluemoving').setStyle('height','0');
		var a = $('jsmenu').getElement('a.on');
		$('menubluemoving').inject(a, 'after');
		$('menubluemoving').setStyle('visibility','visible');
		var myEffect = new Fx.Morph($('menubluemoving'), {duration: 1000, transition: Fx.Transitions.Sine.easeOut});
 
		//The styles of myClassName will be applied to the target Element.
		myEffect.start({
			'height': dim
		});



		//alert(dim);
	}
	
	
	var toshow = 0;
	var tgs = $$('div.toggler');
	for(var i=0,j=tgs.length;i<j;i++){
		if ( tgs[i].hasClass('on') ){
			toshow = i;
		}
	}
	
	var myAccordion = new Accordion($('accordion'), 'a.togon', 'div.elon', {
		opacity: false
	});
	
	//$$('div.element').setStyle('display','block');
	
	/*
	var myAccordion2 = new Accordion($('jsmenu'), 'a.on', 'div.ssmenuprodblue', {
		opacity: false
	});
	*/
	if ( $('occtable') ){
		occatable = new Sk_TablePager($('occtable'),$('pgfirst'),$('pgprev'),$('pgsnb'),$('pgnext'),$('pglast'),5);
	}
	
	var ds = $$('div.actuthumb');
	if ( ds.length > 0){
		new Sk_ItemsPager(ds,$('pgprev'),$('pgnext'),2);
	}
	
	var deroul2 = $('calderoulcontent');
	if ( deroul2 ){
		var tds = deroul2.getElements('td.calmois');
		var arts_nb = tds.length;
		
		var options = {
			nbItems : arts_nb,
			itemVisible : 1,
			itemSize : 241,
			deroulWay : 'horizontal',
			deroulSpeed : 600,
			deroulFx : Fx.Transitions.Quad.easeInOut,
			nameDiv : $('calmois')
		};
		new SkDeroul( $('calderoulcontent'), $('calslide').getElement('div.arrowleft'), $('calslide').getElement('div.arrowright'), options );
		//alert('hop');
	
	
	
	}
	
	if ( $('newscontentscroll') ){
		var newsblocs = $$('div.newsscrolldiv');
		news_nb = newsblocs.length - 1;
		
		setInterval('scrollNews();', 7000);
	}
	
	if ( $('actifcontentscroll') ){
		var divs = $$('div.actiftxtdiv');
		if ( divs.length > 0){
			var id = divs[0].getProperty('id');
			id = id.substring(5);
			showActif(id);
		}
		
	}
	
	var cfs = $$('.customfont');
	for(var i=0,j=cfs.length;i<j;i++){
		customFont(cfs[i]);
	}
	//alert(cfs.length);
	//$('bigmenu').addEvent('click',function(event){this.updateDate(event.target);}.bind(this))
	/*
	mainarrowselected = $('headmenu2').getElement('div.mainhover');
	
	var mainmenuas = $('headmenu').getElements('a');
	for(var i=0,j=mainmenuas.length;i<j;i++){
		var d=mainmenuas[i];
		d.onmouseover = function(){
			var id = this.className.toLowerCase().split(' ');
			id = (id[0]=='on') ? id[1] : id[0];
			$('headmenu2').getElements('div.menu2box').setStyle('display','none');
			var t = $('menu2'+id);
			if (t) t.setStyle('display','block');
			var d = $('arrow'+id);
			if ( d.hasClass('mainhover'))
				return;
			$('headmenu2').getElements('div.arrow').removeClass('mainhover');
			d.addClass('mainhover');
			
		}
	}
	*/
		
	/*
	$('content').onmouseover = resetMainMenu;
	$('headhead').onmouseover = resetMainMenu;
	var seps = $('headmenu').getElements('img.sep');
	seps[0].onmouseover = resetMainMenu;
	var i = (seps.length-1);
	seps[i].onmouseover = resetMainMenu;
	*/
		
	if ( $('posteselector') ){ //page contact
		var ps = $('posteselector');
		var pos = $('qualiteform').getPosition($('contactform'));
		ps.style.marginLeft = (133+pos.x)+'px';
		ps.style.marginTop  = pos.y+'px';
		ps.style.display = 'block';
		var pp = $('posteselect');
		pp.style.marginTop  = (21+pos.y)+'px';
		$('qualiteform').onclick = toggleSelector;
		
		var btn = $('submitbtn');
		btn.onmouseover = function(){
			var d= $(this);
			d.addClass('hover');
		}
		btn.onmouseout = function(){
			var d= $(this);
			d.removeClass('hover');
		}
	}
	
	if ( $('logboxbtn') ){
		var btn = $('logboxbtn');
		btn.onmouseover = function(){
			var d= $(this);
			d.addClass('hover');
		}
		btn.onmouseout = function(){
			var d= $(this);
			d.removeClass('hover');
		}
	}
	
	$$('div.situationrep').each(function(el, i){
		var slider = new Slider(el, el.getElement('.knob'), {
			steps: 799,  // Steps from 0 to 255
			//wheel: true, // Using the mousewheel is possible too
			//snap:true,
			onChange: function(){
				// Based on the Slider values set an RGB value in the color array
				var nb = (this.step / 200).floor(0);
				el.getParent().getParent().getElement('input').value = nb;
				//color[i] = this.step;
				el.getParent().getElement('div.situationrepbgie').setStyle('margin-left', (250/4)*nb+19+8);
				// and update the output to the new value
				//updateColor();
			},
			onComplete: function(){
				// Based on the Slider values set an RGB value in the color array
				var nb = (this.step / 200).floor(0);
				el.getParent().getParent().getElement('input').value = nb;
				//color[i] = this.step;
				this.set(nb * 200 + 100);
				el.getParent().getElement('div.situationrepbgie').setStyle('margin-left', (250/4)*nb+19+8);
				// and update the output to the new value
				//updateColor();
			}
		}).set(100);
		//el.getElement('.knob').setStyle('opacity', 0.1);
	});
	
	
	//visits
	new Element('img', {'style':'position:absolute;top:-10px;left:0;width:1px;height:1px;','src':SITE_ROOT+'site/visits/visits.php?ref='+encodeURIComponent(document.referrer)+'&url=' + encodeURIComponent(document.URL)}).inject(document.body);
	/*
	if ( $('nlform') ){
		var d= $('nlform');
		d.action = window.location.toString() + '#nl';
		alert(d.action);
	}
	*/	
	//makeAjaxRequest(SITE_ROOT + "visits.php","GET",null);
}

var occatable;
var smallderoul;
var depts;

function showDepts(){
	$('deptoptions').style.display = ($('deptoptions').style.display == 'block') ? 'none' : 'block';
}

function showDept(d){
	var cp = d.innerHTML;
	depts.setStyle('display', 'none');
	var el = $(d.retrieve('matchid'));
	el.setStyle('display', 'block');
	$('deptoptions').style.display = 'none';
	showMap(el.getElement('p.query').innerHTML);
	//$('map_canvas').style.visibility = 'hidden';
	//$('deptsmapdivc').style.height = '0px';
}

function showOcca(){
	$('occaoptions').style.display = ($('occaoptions').style.display == 'block') ? 'none' : 'block';
}

function sortOcca(d, nb){
	$('occaselectlabeltxt').innerHTML = ' '+d.innerHTML;
	var trs = $('occtable').getElements('tr');
	if ( nb == 0 ) trs.sort(nomsort);
	if ( nb == 1 ) trs.sort(typesort);
	if ( nb == 2 ) trs.sort(datesort);
	for(var i=0,j=trs.length;i<j;i++){
		trs[i].getParent().appendChild(trs[i]);
		trs[i].removeClass('odd');
		if ( i%2 != 0 ) trs[i].addClass('odd');
	}
	$('occaoptions').style.display = 'none';
	occatable.setPage(1);
}

function nomsort(a, b){
	var nameA=a.getElement('div.nom').innerHTML;
	var nameB=b.getElement('div.nom').innerHTML;
	if (nameA < nameB)
		return -1;
	if (nameA > nameB)
		return 1;
	return 0;
}

function typesort(a, b){
	var nameA=a.getElement('div.type').innerHTML;
	var nameB=b.getElement('div.type').innerHTML;
	if (nameA < nameB)
		return -1;
	if (nameA > nameB)
		return 1;
	return 0;
}

function datesort(a, b){
	var nameA=a.getElement('div.date').get('name');
	var nameB=b.getElement('div.date').get('name');
	return nameB - nameA;
}

function submitQuizz(){
	var pt = 8;
	for(var i=1,j=9;i<j;i++){
		pt += parseInt($('rep'+i).value);
	}
	$('blocrep1').style.display = 'none';
	$('blocrep2').style.display = 'none';
	var repbloc = (pt > 15) ? 2 : 1;
	$('blocrep'+repbloc).style.display = 'block';
}

function toggleSelector(){
	var d = $('posteselect');
	d.style.display = ( d.style.display == 'block' ) ? 'none' : 'block';

}

function selectPoste(d){
	$('qualiteform').value = d.innerHTML;
	$('posteselect').style.display = 'none';
}

function hideSelector(){
	$('posteselect').style.display = 'none';
}

var mainarrowselected;

function resetMainMenu(){
	$('headmenu2').getElements('div.arrow').removeClass('mainhover');
	$('headmenu2').getElements('div.menu2box').setStyle('display','none');
	if(mainarrowselected)
		mainarrowselected.addClass('mainhover');
}

function filledInput(input, action, value){
	if(action=='blur'){
		if(input.value=='') input.value = value;
	}
	else if(action=='focus'){
		if(input.value==value) input.value = '';
	}
}

function filledPwdInput(input, action, value){
	if(action=='blur'){
		if(input.value=='') {
			input.type = 'text';
			input.value = value;
		}
	}
	else if(action=='focus'){
		input.type = 'password';
		if(input.value==value) input.value = '';
	}
}

function customFont(d){
	var cls = d.className.split(' ');
	var action = '';
	for(var i=0,j=cls.length;i<j;i++){
		if ( cls[i].indexOf('action') == 0){
			var t = cls[i].split('-');
			action = t[1];
		}
	}
	var txt = d.get('text');
	d.empty();
	new Element('img', {'style':'','title':txt,'alt':txt,'src':SITE_ROOT+'getimgtxt/'+action+'/'+encodeURIComponent(txt)}).inject(d);
	//alert(action+' '+txt);
}

var news_nb = 0;
var news_current = 0;

function scrollNews(){

	if ( news_current == news_nb ){
		news_current = 0;
		$('newscontentscroll').style.marginTop = '0px';
	}
	
	var start_pos = news_current * 94;
	news_current++;
	var final_pos = news_current * 94;
	
	new Fx.Morph($('newscontentscroll'), {
		wait: false,
		duration: 2000,
		transition: Fx.Transitions.Quad.easeInOut
	}).start({
		marginTop: [-start_pos,-final_pos]
	});
	
	
}

function toggleDisplay(d){
	var display = (d.style.display == 'none') ? 'block' : 'none';
	if ( display == 'block' ){
		$('boutiques').getElements('div.options').setStyle('display','none');
	}
	d.style.display = display;
}

function faqtoggle(d){
	d = $(d);
	$('faq').getElements('div.faq').removeClass('black');
	var c = d.getNext();
	var style = (c.style.display == 'block') ? 'none' : 'block';
	$$('div.faq-reponse]').setStyle('display', 'none');
	d.getParent().addClass('black');
	c.style.display = style;
	
	SB['faq-content'].update();
	$$('a.faq-question').removeClass('qhover');
	d.addClass('qhover');
}

function filtreVilles(){
	var pays = $('paysform').getElement('div.fakeselectvalue').getProperty('name'); //value;
	
	$('villeslistes').getElements('div.villesform').setStyle('display', 'none');
	$('villes-'+pays).setStyle('display', 'block');
	filtreBoutiques();
}

function filtreBoutiques(){
	var pays = $('paysform').getElement('div.fakeselectvalue').getProperty('name');
	var ville = $('villes-'+pays).getElement('div.fakeselectvalue').getProperty('name');
	
	$('shops').getElements('div').setStyle('display', 'none');
	$('shops').getElements('div[name='+pays+'-'+ville+']').setStyle('display', 'block');
	SB['shopsbg'].update();
	
	var pays_txt = $('paysform').getElement('div.fakeselectvalue').innerHTML;
	var ville_txt = $('villes-'+pays).getElement('div.fakeselectvalue').innerHTML;
	$('shoptitre').innerHTML = pays_txt.toUpperCase() + ' - ' + ville_txt.toUpperCase();
}

function filtrePresse(){
	var id = $('presseform').getElement('div.fakeselectvalue').getProperty('name');
	var titre = $('presseform').getElement('div.fakeselectvalue').innerHTML;
	$('pressetitre').innerHTML = titre.toUpperCase();
	$$('div.pimg').setStyle('display', 'none');
	$('presseimg'+id).style.display = 'block';
	$$('div.part').setStyle('display', 'none');
	$('presseart'+id).style.display = 'block';
	SB['pressebg'].update();
}

function showImgBig(src){
	//
	//var src = TALENTS_PHOTOSLIST[id];
	//alert(src);
	Slimbox.open(src);
}

function showActif(id){
	$$('div.actiftxtdiv').setStyle('display','none');
	$('actif'+id).setStyle('display','block');
	SB['actifcontentbg'].update();
	$$('a.linkactif').removeClass('hover');
	$('linkactif'+id).addClass('hover');
}


var over_menu = false;
function moverSsMenu(id, a){
	over_menu = true;
	var d = $('ssmenubloc'+id);
	if ( d.style.display == 'block' ) return;
	$$('ul.ssmenubloc').setStyle('display','none');
	var pos = a.getPosition();
	d.style.left = pos.x + 'px';
	d.style.top = (pos.y+27) + 'px';
	d.style.display = 'block';
}

function moutSsMenu(id, a){
	over_menu = false;
	setTimeout('hideSsmenu();', 100);
}

function hideSsmenu(){
	if ( over_menu == false ){
		$$('ul.ssmenubloc').setStyle('display','none');
	}
}

function moverSsMenuBloc(id){
	over_menu = true;
}

function moutSsMenuBloc(id){
	over_menu = false;
	setTimeout('hideSsmenu();', 200);
}

function toggleQuizz(id){
	$$('ul.quizzdiv').setStyle('display', 'none');
	var idd = id.split('-');
	if ( idd[0] == 'QA' ){
		$('quizzB'+idd[1]).style.display = 'block';
		$('quizzB'+idd[2]).style.display = 'block';
	}
	else if ( idd[0] == 'QB' ){
		$('quizzC'+idd[1]).style.display = 'block';
	}
	SB['quizzcontent'].update();
}

