/* Loïc Pennamen pour Magnana.com */





var toucheDesac=255; //la touche 255 est inusitée ; touche enter = 13
var focusSuivant="nom"; // le premier champ de formulaire ou n'importe quel id
var gk=window.Event?1:0; 
function toucheenter(e) {
	var touche=gk?e.which:window.event.keyCode; //pour compatibilité FF IE
	if (touche == toucheDesac){
		document.getElementById(focusSuivant).focus();
		return false;
	}
}
document.onkeydown = toucheenter; 





function antiselect(etat){
	/* */
	if(etat == 'on'){
		document.onselectstart=new Function("return false");
		if(window.sidebar){
			document.onmousedown=new Function("return false");
			document.onclick=new Function("return true");
		}
	}
	else{
		document.onselectstart=new Function("return true");
		if(window.sidebar){
			document.onmousedown=new Function("return true");
			document.onclick=new Function("return true");
		}
	}
	/* */
}

function deroulerH(cible, debut, fin, vitesse){
	if(debut<fin){
		debut+=vitesse;
		bloc = document.getElementById(cible);
		//alert(bloc.style.display);
		//bloc.style.width = debut + 'px';
		bloc.style.height= debut + 'px';
		mouvement = window.setTimeout("deroulerH('"+cible+"', "+debut+", "+fin+", "+vitesse+")", 10);
		if(bloc.style.display == 'none'){
			bloc.style.display = 'block';
			//alert('passage en bloc');
		}
	}
	else{
		clearTimeout(); 
	}
}

// lors de l'envoi d'une adresse PARTAGER CE SITE...
function partager(){
	alert('submit');
	return(false);
}

// verifier les dates entrees lors d'une reservation
function verifierDates(){
	// selection des deux dates données
	
	return(confirm('Les dates que vous avez entrées semblent correspondre à une réservation existante. Voulez-vous quand même demander cette réservation ?'));
}

function upImage(image, ext){
	image.src=image.src.substr(0, image.src.length - 4) + "-up." + ext;
}
function downImage(image, ext){
	image.src=image.src.substr(0, image.src.length - 7) + "." + ext;
}

///////////
function changerImage(idImage, srcImage){
	idImage.src=srcImage;
}
///////////
var newWin = null;
function closeWin(){
	if (newWin != null){
		if(!newWin.closed)
		newWin.close();
	}
}
///////////
function popUp(strURL,strType,strHeight,strWidth,absolute) {
if(!absolute) var absolute = '';
closeWin();
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
newWin = window.open(absolute + strURL, 'newWin', strOptions);
newWin.focus();
} 
// limiter le nombre de caracteres d'un textarea
function limiterTA(monTA,nbCaracteres,temoin){
	nbActuel=monTA.value.length;
	if(nbActuel>=nbCaracteres+1){
		alert('Vous ne pouvez entrer que '+nbCaracteres+' caractères maximum');
		monTA.value=monTA.value.substr(0,nbCaracteres-2);
	}
	document.getElementById(temoin).innerHTML='<sup>'+ (nbCaracteres-nbActuel) + ' caractères restants</sup>';
}
// onOffBlock fonctionne comme un interrupteur sur un bloc donné par son id
function onOffBlock(afficher){
	if(document.getElementById(afficher).style.display=='block') {		document.getElementById(afficher).style.display='none';	}
	else if(document.getElementById(afficher).style.display=='none') {	document.getElementById(afficher).style.display='block';	}
	//return(true);
}
function onOffBlockInline(afficher){
	if(document.getElementById(afficher).style.display=='inline') {		document.getElementById(afficher).style.display='none';	}
	else if(document.getElementById(afficher).style.display=='none') {	document.getElementById(afficher).style.display='inline';	}
}

function preview(img){
	document.getElementById('previewImg').src=img;
	document.getElementById('previewImg').style.display='block';
	document.getElementById('previewImg').style.position='absolute';
	document.getElementById('previewImg').style.width=60;
	document.getElementById('previewImg').style.left=mouse_x + 20;
	document.getElementById('previewImg').style.top=mouse_y;
	//alert(mouse_x);
	position();
}
		
function register_position(){
	mouse_x = 0;
	mouse_y = 0;
	document.onmousemove = position;
	//alert(mouse_x);
}

function position(evt){
	if(!evt) evt = window.event;	
	mouse_x = evt.clientX;
	mouse_y = evt.clientY;
	//alert(mouse_x);
}

function masquer(idAMasquer){
	if(document.getElementById(idAMasquer)) document.getElementById(idAMasquer).style.display='none';
}
function afficher(idAAfficher){
	if(document.getElementById(idAAfficher)) document.getElementById(idAAfficher).style.display='block';
}
function afficherInline(idAAfficher){
	document.getElementById(idAAfficher).style.display='inline';
}






















