/*====================
JS generique CMS
====================*/

var scroll = 1;

/*==== Focus sur les fields ====*/
function GetFocus(field) {
	if (field.value==field.title) {field.value=''}
}

/*==== Blur sur les fields ====*/
function GetBlur(field) {
	if (field.value=='') {
		field.value=field.title;
	}
}

/*==== Scroll a l'ID correspondant ====*/
function scrollCtn(cible)
{
	var viewer  = $('list_news_home');
	var scroller = new Fx.Scroll(viewer, {  
		onComplete: function() {
			//alert('ok');
		}  
	}).toElement(cible);
}
function scrollCtnImg(cible)
{
	var viewer  = $('cont_bande_images');
	var scroller = new Fx.Scroll(viewer, {  
		onComplete: function() {
			//alert('ok');
		}  
	}).toElement(cible);
}

function scrolltoTop(elmt)
{
	var myFx = new Fx.Scroll(document.body,{
		offset: {
			'x':0,
			'y':-200
		}
	}).toElement(elmt);
}

// Cache les msg d'erreur
function hide_error () {
	div  = (document.layers) ? document.layers['errorPad'] : document.getElementById('errorPad');
	div2  = (document.layers) ? document.layers['erlogPad'] : document.getElementById('erlogPad');
	div.style.display = "none";
	div2.style.display = "none";
}

// recupere données shop (from FLASH)
function getShopData(dept) {
	function success(res)
	{
		document.getElementById('text-shop').innerHTML = res;
		//scrolltoTop('text-shop');
		
	}
	var req = new Request.HTML({
			method: 'post',
			url: 'plugins/carte_magasins/ajaxShopData.php',
			data: { 'dept' : dept },
			//onRequest: function() { alert('Request made. Please wait...'); },
			//update: $('text-shop'),
			onComplete: function() {success(this.response.text);}
	});
	
	req.send();
}

function getShopData2(dept) {
	function success(res)
	{
		document.getElementById('text-shop2').innerHTML = res;
		//scrolltoTop('text-shop');
		
	}
	var req = new Request.HTML({
			method: 'post',
			url: 'plugins/carte_magasins/ajaxShopData2.php',
			data: { 'dept' : dept },
			//onRequest: function() { alert('Request made. Please wait...'); },
			//update: $('text-shop'),
			onComplete: function() {success(this.response.text);}
	});
	
	req.send();
}



window.addEvent('domready', function() {
	if ( ($('actus_prev') != "") && ($('actus_prev') != null) ) {
		$('actus_prev').style.visibility='hidden';
		$('actus_prev').addEvent('click', function() {
			if ( (scroll - 2) >= 1 ) {
				scroll = scroll - 2;
				lequel = 'ctn'+scroll;
				scrollCtn(lequel);
				if ( scroll == 1 ) {
					$('actus_prev').style.visibility='hidden';
					$('actus_next').style.visibility='visible';
				}
				if ( scroll + 2 >= maxi ) {
					$('actus_next').style.visibility='visible';
				}
			}
		} );
	}
	if ( ($('actus_next') != "") && ($('actus_next') != null) ) {
		$('actus_next').addEvent('click', function() {
			if ( (scroll + 2) <= maxi ) {
				scroll = scroll + 2;
				lequel = 'ctn'+scroll;
				scrollCtn(lequel);
				if ( scroll > 1 ) {
					$('actus_prev').style.visibility='visible';
				}
				if ( scroll + 2 > maxi ) {
					$('actus_next').style.visibility='hidden';
				}
			}
		} );
	}
	if ( $$('.highlight_1') != "" ) {
	}
	
	//scroll images
	if ( ($('precedente') != "") && ($('precedente') != null) ) {
		$('precedente').addEvent('click', function() {			   
			$('suivante').style.visibility='visible';
			if ( (scroll - 1) >= 0 ) {
				scroll = scroll - 1;
				lequel = 'ctn'+scroll;
				scrollCtnImg(lequel);
				if (scroll == 0 ) {
					$('precedente').style.visibility='hidden';
				}
				else{
					$('precedente').style.visibility='visible';
				}
			}
		} );
	}
	if ( ($('suivante') != "") && ($('suivante') != null) ) {
		$('suivante').addEvent('click', function() {
			$('precedente').style.visibility='visible';
			if ( (scroll + 1) <= (maxi - 1) ) {
				scroll = scroll + 1;
				lequel = 'ctn'+scroll;
				scrollCtnImg(lequel);
				if ( scroll == (maxi - 1) ) {
					$('suivante').style.visibility='hidden';
				}
				else{
					$('suivante').style.visibility='visible';
				}
			}
		} );
	}
	
});




function showhide(rep)
{
	if(document.getElementById(rep).style.display=='none')
		document.getElementById(rep).style.display='block';
	else
		document.getElementById(rep).style.display='none';	
}


function magRollOn() {
	document.getElementById("magasins").src = 'templates/eau-vive/images/accueil/trouver_magasin_eau_vive_on.png';
}

function magRollOut() {
	document.getElementById("magasins").src = 'templates/eau-vive/images/accueil/trouver_magasin_eau_vive.png';
}
function nouvRollOn() {
	document.getElementById("nouv_promo").src = 'templates/eau-vive/images/accueil/nouv_promo_on.jpg';
}

function nouvRollOut() {
	document.getElementById("nouv_promo").src = 'templates/eau-vive/images/accueil/nouv_promo.jpg';
}


/*******




// Cache les msg d'erreur
function hide_error () {
	div  = (document.layers) ? document.layers['errorPad'] : document.getElementById('errorPad');
	div2  = (document.layers) ? document.layers['erlogPad'] : document.getElementById('erlogPad');
	div.style.display = "none";
	div2.style.display = "none";
}






window.addEvent('domready', function() {
	if ( $$('.highlight_1') != "" ) {
		$$('.highlight_1').each(function(toggler, i) {
			toggler.onmouseover = function() {
				this.addClass('sfhover');
				if ( (deployed != undefined) && (deployed != "") && (activated != this.id) && (activated != "")  ) {
					$(deployed).style.display = 'none';
				}
			}
			toggler.onmouseout = function() {
				this.toggleClass('sfhover');
				if ( (deployed != undefined) && (deployed != "") && (activated != this.id) && (activated != "")  ) {
					$(deployed).style.display = 'block';
				}
			}
		});
	}
	if ( $$('.count') != "" ) {
		$$('.count').each(function(toggler, i) {
			toggler.onmouseover = function() {
				this.addClass('sfhover');
			}
			toggler.onmouseout = function() {
				this.toggleClass('sfhover');
			}
		});
	}
	if ( $$('.count_0') != "" ) {
		$$('.count_0').each(function(toggler, i) {
			toggler.onmouseover = function() {
				this.addClass('sfhover');
			}
			toggler.onmouseout = function() {
				this.toggleClass('sfhover');
			}
		});
	}
});********/
