function init_js(){
	//if (self.parent.frames.length != 0) self.parent.location='/';	
	rollOvers();
	prel('menu-on-01.gif','menu-on-02.gif','menu-on-03.gif','menu-on-04.gif','menu-on-05.gif','top-on.gif');	
}

function prel() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=prel.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src='/images/'+a[i];}}
}

function rollOvers(){
	if (!document.getElementById) return
	
	var imgOriginSrc;
	var MouseOverHappened;
	var oldtop;
	var imgTemp = new Array();
	var imgarr = document.getElementsByTagName('img');
	
	for (var i = 0; i < imgarr.length; i++) {
		//Attribut hsrc pour Rollovers
		if (imgarr[i].getAttribute('hsrc')) {
			imgTemp[i] = new Image();
			imgTemp[i].src = imgarr[i].getAttribute('hsrc');
			imgarr[i].onmouseover = function() {
				imgOriginSrc = this.getAttribute('src');			
				this.setAttribute('src',this.getAttribute('hsrc'));
				MouseOverHappened=true;
			}
			imgarr[i].onmouseout = function() {
				if(MouseOverHappened)
					this.setAttribute('src',imgOriginSrc);
			}
		}
	
		//Attribut csrc pour action de click comme boutons
		if (imgarr[i].getAttribute('csrc')) {
			imgTemp[i] = new Image();
			imgTemp[i].src = imgarr[i].getAttribute('csrc');
			imgarr[i].onmousedown = function() {
				imgOriginSrc = this.getAttribute('src');			
				this.setAttribute('src',this.getAttribute('csrc'));
				MouseOverHappened=true;
			}
			imgarr[i].onmouseup = function() {
				if(MouseOverHappened)
					this.setAttribute('src',imgOriginSrc);
			}
		}
	}
}

window.onload=init_js;

function submitNewMembre(hndl){
	returnFunction = function () {
		if (ajaxOk()) {
			if(objAjax.responseText=='0'){
				killAjax();
				hndl.submit();
			}else{
				alert('Votre adresse courriel a déjà été enregistré.\n Cliquez sur "J\'ai un compte, mais j\'ai oublié mon mot de passe" pour recevoir votre mot de passe par courriel')
			}
		}
	}
	if(validForm(hndl)){
		if(hndl.password.value==hndl.password2.value){
			callAjax(url+'_validateEmail.php?email='+hndl.courriel.value,returnFunction);
		}else{
			alert('votre mot de passe et votre confirmation de mot de passe ne sont pas identique');
		}
	}
}

function updateProvince2(prov){
	if(typeof(prov) !='undefined'){
		selected = prov;
	}else{
		selected=0;
	}
	pays = document.formPanierFinal.pays.options[document.formPanierFinal.pays.selectedIndex].value;
	callAjax(url+'_provinces.php?lan='+lan+'&pays='+pays+'&selected='+selected,null,document.getElementById('provincesb'));
}

function updateProvince(prov){
	if(typeof(prov) !='undefined'){
		selected = prov;
	}else{
		selected=0;
	}
	try {
		pays = document.getElementsByTagName('form')[0].pays.options[document.getElementsByTagName('form')[0].pays.selectedIndex].value;
	} catch(e) {
		pays = document.formNewClient.pays.options[document.formNewClient.pays.selectedIndex].value;
	}
	callAjax(url+'_provinces.php?lan='+lan+'&pays='+pays+'&selected='+selected,null,document.getElementById('provincesb'));
}

function confirmCommande() {
		document.formCart.action="/panier.php?confirmTout=true";
		document.formCart.submit();
	}

function confirmCommandeEn() {
		document.formCart.action="/panier.php?confirmTout=true&lan=en";
		document.formCart.submit();
	}
	var curlang = 'fr';
function sendFormJulie(hndl,lan){
	var strurl = '/sendfrm.php?lan='+lan;
	strurl += '&nom='+escape(hndl.nom.value);
	strurl += '&courriel='+escape(hndl.courriel.value);
	strurl += '&nomanimal='+escape(hndl.nomanimal.value);
	strurl += '&typeani='+escape(hndl.typeani.value);
	strurl += '&race='+escape(hndl.race.value);
	strurl += '&age='+escape(hndl.age.value);
	strurl += '&allergies='+escape(hndl.allergies.value);
	strurl += '&condition='+escape(hndl.condition.value);
	strurl += '&nourriture='+escape(hndl.nourriture.value);
	curlang = lan;
	//alert(strurl);
	callAjax(strurl,sendFormJulie2);
}

function sendFormJulie2() {
	if (!ajaxOk()) return;
	
	if (curlang == 'fr') alert('Votre demande a été envoyé!');
	else alert('Your request was sent !');
	document.getElementById('julie').reset();
	killAjax();
	
}

function resetpass(lan) {
	var strurl = '/lostpass.php?lan='+lan;
	strurl += '&mail='+document.getElementById('lostpassmail').value;
	callAjax(strurl,resetpass2);
}

function resetpass2() {
	if (!ajaxOk()) return;
	//alert(objAjax.responseText);
	if (objAjax.responseText.match(/OK/)) {
		document.getElementById('lostpassbox').style.display='none';
		document.getElementById('connbox').style.display='';
		document.getElementById('resetpassok').style.display='';
	}
	else {
		document.getElementById('resetpasserror').style.display='';
	}
	killAjax();
}

function sendjulieform(lan) {
	
}