/*
	Brachard & Cie
	Common javascript functions

	Author: David Roessli (david dot roessli at cybmed dot com)
	Created on 2006-06-09
	Version: 1
	Revision: 0

	History:

		200606091508: genesis

	Terms
	You may adapt and learn from the elements of this CSS to use in your own
	projects, but you may not copy the design (the unique combination of images,
	colors, sizes, typography, and positioning) since this is copyright of
	Xstrata plc and may not be reproduced.

*/


/*
	::: preload images
*/
image = new Image();
image.src = "/img/ajax-loader_16.gif";


function checkfeedbackform(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

// ** START **
if (form.prenom.value == "") {
	// Effect.Shake('prenom');
	$('input#prenom').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre prénom est manquant.\nVeuillez ressayer." );
	$('input#prenom').focus();
	return false ;
}
if (form.nom.value == "") {
	// Effect.Shake('nom');
	$('input#nom').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre nom est manquant.\nVeuillez ressayer." );
	form.nom.focus();
	return false ;
}
if (form.email.value == "") {
	// Effect.Shake('email');
	$('input#email').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre adresse email est manquant.\nVeuillez ressayer." );
	form.email.focus();
	return false ;
}
if (form.msg.value == "") {
	// Effect.Shake('msg');
	$('input#msg').effect('shake', { times:3 }, 150);
	alert( "Tsk tsk! Votre message est manquant.\nVeuillez ressayer." );
	form.msg.focus();
	return false ;
}
// ** END **

showLoading();
return true ;
}

function checksubscriptionform(form)
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website

// ** START **
if ((form.c25.checked == false) && (form.ccash.checked == false) && (form.ccredit.checked == false) && (form.conline.checked == false)) {
	alert( "Oops! Veuillez sélectionner au moins un mode de paiement souhaité.\nVeuillez ressayer." );
	form.ccash.focus();
	return false ;
}
if ((form.ctype.value == "Société") && (form.company.value == "")) {
	// Effect.Shake('company');
	$('input#company').effect('shake', { times:3 }, 150);
	alert( "Oops! Le nom de la société est manquant.\nVeuillez ressayer." );
	form.company.focus();
	return false ;
}
if (form.prenom.value == "") {
	// Effect.Shake('prenom');
	$('input#prenom').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre prénom est manquant.\nVeuillez ressayer." );
	form.prenom.focus();
	return false ;
}
if (form.nom.value == "") {
	// Effect.Shake('nom');
	$('input#nom').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre nom est manquant.\nVeuillez ressayer." );
	form.nom.focus();
	return false ;
}
if ((form.bday_day.selectedIndex == 0) || (form.bday_month.selectedIndex == 0) || (form.bday_year.selectedIndex == 0)) {
	// Effect.Shake('bday_day');
	$('input#bday_day').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre date de naissance est imcomplète.\nVeuillez ressayer." );
	form.bday_day.focus();
	return false ;
}
if (form.rue1.value == "") {
	// Effect.Shake('rue1');
	$('input#rue1').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre adresse est manquante.\nVeuillez ressayer." );
	form.rue1.focus();
	return false ;
}
if (form.npa.value == "") {
	// Effect.Shake('npa');
	$('input#npa').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre adresse est manquante (NPA).\nnVeuillez ressayer." );
	form.npa.focus();
	return false ;
}
if ((form.tel.value == "") && (form.mob.value == "")) {
	// Effect.Shake('tel');
	$('input#tel').effect('shake', { times:3 }, 150);
	alert( "Oops! Il faut spécifier au moins un numéro de téléphone.\nVeuillez ressayer." );
	form.tel.focus();
	return false ;
}
if (form.email.value == "") {
	// Effect.Shake('email');
	$('input#email').effect('shake', { times:3 }, 150);
	alert( "Oops! Votre adresse email est manquant.\nVeuillez ressayer." );
	form.email.focus();
	return false ;
}
// ** END **

showLoading();
return true ;
}

function showLoading() {
		
	if (!document.getElementById) return false;
	var button = document.getElementById("buttons");	// submit button
/*
	var image = document.getElementById("progress");	// animated GIF

	button.style.display = "none";	// hide button
	image.style.display = "block";	// show loading animated GIF
*/
	button.innerHTML = '<img src="/img/ajax-loader_16.gif" alt="Uploading file and related information to server.." title="Uploading file and related information to server.."  /> Envoi des informations vers le serveur..';

	return true;
}

function showhide(id) {

	if (!document.getElementById) return true;			// do it the php way
	if (!document.getElementById(id)) return true;		// do it the php way
	if (Element.visible(id)) {

		new Effect.BlindUp(id);
	}
	else {
		new Effect.BlindDown(id);
	}

	return false;
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

//addLoadEvent(prepareHovers);

$(document).ready(function(){
	$("li#sbra").hover(
		function(){
            $("li#sbra a strong").hide().css("left", "70px").fadeIn("fast");
            // $("li#sbra a strong").hide().css("left", "55px").fadeIn("fast");
		},
		function(){
			$("li#sbra a strong").css("left", "-9999px");
		}
	);
	$("li#ssho").hover(
		function(){
            $("li#ssho a strong").hide().css("left", "70px").fadeIn("fast");
            // $("li#ssho a strong").hide().css("left", "55px").fadeIn("fast");
		},
		function(){
			$("li#ssho a strong").css("left", "-9999px");
		}
	);
	$("li#scon").hover(
		function(){
            $("li#scon a strong").hide().css("left", "70px").fadeIn("fast");
            // $("li#scon a strong").hide().css("left", "55px").fadeIn("fast");
		},
		function(){
			$("li#scon a strong").css("left", "-9999px");
		}
	);
	$("li#scah").hover(
		function(){
            $("li#scah a strong").hide().css("left", "70px").fadeIn("fast");
            // $("li#scah a strong").hide().css("left", "55px").fadeIn("fast");
		},
		function(){
			$("li#scah a strong").css("left", "-9999px");
		}
	);
	
	/* Lightbox */
	$('a[rel=lightbox]').lightBox();
});     

