function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i>a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i>d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function closeBrWindow() {
  window.close();
}

function nameMe() { 
  self.name = "mainWindow"; 
} 

function cpValide(ctrl,pays){
// Valide le code postal en passant le nom du champs
	var p = pays.value;
	with (ctrl) {
		if (value != "" && p == "CA") { 
			var temp = value.replace(/ /,"");
			var modele= /[a-zA-Z][0-9][a-zA-Z][0-9][a-zA-Z][0-9]/;
			if (!modele.test(temp) || temp.length > 6) {
				alert("Le code postal n'est pas pas valide !\nSVP, inscrivez-le de nouveau.");
				value = "";
				focus();
			}// if
			else { // Formate le code postal validé
				temp = temp.slice(0,3) + " " + temp.slice(3,6);	
				value = temp.toUpperCase();
			}// else
		}// if
	}// with
}// end cpValide

function emailValide(ctrl,f){
//Valide l'adresse de courriel en passant le nom du champs
	with (ctrl){
		var s = value.split(/@/);
		if ((value)&&(value.search(/ /)!=-1||s.length!=2||!(s[0])||!(s[1])||s[1].search(/\.\w/)==-1)){
			if (f.name == "form1" || f.name == "soumF")
				alert("Votre courriel n'est pas valide! \nSVP, inscrivez-le de nouveau.");
			else
				alert("Your email address is not valid! \nPlease, fill correctly.");
			value = "";
			focus();
		}//if							
	}//with
}// end emailValide

function tell(l){
	with (l){
		value = "'" + document.location + "'";
		if (value.indexOf("?") != -1 ) {
			value = value.slice(value.indexOf("?")+1,value.length-1);
		}// if
		else {
		l.value = "";
		}
	}// with
}// end tell

function filled(form,defaut,l){
	if (l == "f"){
		var msg = "Une information requise est manquante. \n  Veuillez SVP compléter";
	}
	else {
		var msg = "A required field is missing. \n  Please make sure they are all filled";	
	}
	with(form){
		if (value == "" || value == null || value == defaut){
		alert (msg);
		focus();
		return false;
		}//if
	}//with
	return true;
}//end filled

function checkAll(form){
	with (form){
	if (name == "orderF") {
//		if (filled(Commentaires,"Commentaires...","f") && filled(Nom,"Votre nom...","f") && filled(Courriel,"Courriel...","f")  && filled(Pays,"","f")){
//			if (Adresse.value == "Adresse...") Adresse.value = "";
//			if (Province.value == "Province...") Province.value = "";
//			if (Ville.value == "Ville...") Ville.value = "";
//			if (Code_postal.value == "Code postal...") Code_postal.value = "";
//			if (Telephone.value == "Téléphone...") Telephone.value = "";
//			submit();
//			}//if
//		} // if
//	else {
		if (filled(Commentaires,"Comments...","a") && filled(Nom,"Name...","a") && filled(Courriel,"Email...","a")  && filled(Pays,"","a") && filled(Adresse,"","a") && filled(Province,"","a") && filled(Ville,"","a") && filled(Code_Postal,"","a") && filled(Telephone,"","a")){
//			if (Adresse.value == "Address...") Adresse.value = "";
//			if (Province.value == "Province / State...") Province.value = "";
//			if (Ville.value == "City...") Ville.value = "";
//			if (Code_postal.value == "Postal code...") Code_postal.value = "";
//			if (Telephone.value == "Phone...") Telephone.value = "";
			submit();
			}//if	
//	}// else
	}//if
	}//with
}// end checkAll

function checkSoum(form){
	with (form){
	if (name == "soumF") {
		if (filled(Nom,"","f") && filled(Courriel,"","f")  && filled(Pays,"","f")){
			submit();
			}//if
		} // if
	else {
		if (filled(Nom,"","a") && filled(Courriel,"","a")  && filled(Pays,"","a")){
			submit();
			}//if	
	}// else	 
	}//with
}// end checkSoum

function resetF(f) {
  with (f) {
		if (name == "form1") {
			Commentaires.value = "Commentaires...";
			Nom.value = "Votre nom...";
			Courriel.value = "Courriel...";
			Adresse.value = "Adresse...";
			Province.value = "Province...";
			Ville.value = "Ville...";
			Pays.value = "Canada";
			Code_postal.value = "Code postal...";
			Telephone.value = "Téléphone...";  
		}
		else {
			Commentaires.value = "Comments...";
			Nom.value = "Name...";
			Courriel.value = "Email...";
			Adresse.value = "Address...";
			Province.value = "Province / State...";
			Ville.value = "City...";
			Pays.value = "Canada";
			Code_postal.value = "Postal code...";
			Telephone.value = "Phone...";		
		} //if
  } // with
} // end resetF

function setRandom() {
	var sr = Math.floor(Math.random()*4);
	if (sr == 0){
		sr=1;
	}
	return sr;
}