<!--
var JS_ERR_1 = "Not enough money to withdraw ";
var JS_ERR_2 = "Email not valid";
var JS_ERR_3 = "IP domain not valid";
var JS_ERR_4 = "You must fill in follow fields \n\n\t";
var JS_ERR_5 = "You must to agree the terms and conditions";
var JS_ERR_11 = "Do you really want to delete your account ?";
var JS_ERR_12 = "Your request is sent.\nPlease be patient.";
var JS_ERR_13 = "Credit Card infos";

function AlertDel(form)
{
	if(confirm(JS_ERR_11) == true)
	{
	form.webmas_ent.value = "Delete";
	form.submit();
	}
	else
	{
	form.webmas_ent.value = "";
	return false;
	}
}

function OpFen(loc,name,larg,haut,resize)
{
window.open(loc,name,'toolbar=no,locationbar=no,statusbar=yes,menubar=no,scrollbars=no,status=yes,resizable='+resize+',titlebar=no,width='+larg+',height='+haut)
}

var submitcount = 3;
function patience(input)
{
   if (submitcount < 4)
      {  
      submitcount += 1;  	  
      return input.submit();	
	  }
   else 
      {
	  alert(JS_ERR_12);
      return false;         
      }
}

function CheckRequiredFields( requiredFields, fieldNames, input, fieldOk, method)
{
	var 	focusSet = false;
	var 	fieldCheck = true;
	var 	fieldsNeeded = JS_ERR_4;

	for (var fieldNum=0; fieldNum < requiredFields.length; fieldNum++) {
		if (input.elements[requiredFields[fieldNum]].value  == "") {
			if (!focusSet) {
				input.elements[requiredFields[fieldNum]].focus();
				focusSet = true;
			}
			fieldsNeeded += fieldNames[fieldNum] + "\n\t";
			fieldCheck = false;
		}
	}
	// tous les champs remplis ?	
	if (fieldCheck == true)
	{
	 if(fieldOk == true)
	 {
	 		var invalid = " "; // Invalid character is a space
			//if (input.file1.value.indexOf(invalid) > -1 || input.file2.value.indexOf(invalid) > -1)
			//{
			//alert("Les espaces dans les noms de fichiers ou chemin ne sont pas autorisés.");
			//return false;
			//}
			//else
			//{
			if(method == "but")
			{			
	 		patience(input);
   			}
			else if(method == "sub")
			{
			   if (submitcount < 4)
      			{
     			submitcount += 1;  
	  			//return document.FileUpload.submit(document,input,true);	    
      			return true;
	  			}
				else
				{
				alert(JS_ERR_12);
				return false;
				}
			}
			//} 
	 }
	 else
	 {
	 return false;
	 }
	}
	// Des champs obligatoires non remplis ?
	else {
		alert(fieldsNeeded);
		return false;
	}
}

function CheckRequiredSelect(requiredFields, fieldNames, input, method)
{
	var 	focusSet = false;
	var 	fieldCheck = true;
	var 	fieldsNeeded = JS_ERR_4;
	
	for (var fieldNum=0; fieldNum < requiredFields.length; fieldNum++) {
		if ((input.elements[requiredFields[fieldNum]].selectedIndex) == "")  {
			if (!focusSet) {
				input.elements[requiredFields[fieldNum]].focus();
				focusSet = true;
			}
			fieldsNeeded += fieldNames[fieldNum] + "\n\t";
			fieldCheck = false;
		}
	}
	// tous les champs remplis ?	
	if (fieldCheck == true)
	{
	var fieldOk = true;
	return CheckRequiredFields( requiredFields, fieldNames, input, fieldOk, method)
	}
	// Des champs obligatoires non remplis ?
	else {
	alert(fieldsNeeded);
	return false;
	}
}

var blank = "../images/changing/blank.gif";
topedge = 100;  // location of news box from top of page
if (navigator.appName == 'Netscape')
{
leftedge =  105;  // location of news box from left edge
}
else if (navigator.appName == 'Microsoft Internet Explorer')
{
leftedge =  186;  // location of news box from left edge
}
boxheight = 27;  // height of news box
boxwidth = 650;  // width of news box
scrollheight = 180; // total height of all data to be scrolled

function scrollnews(cliptop)
{

	if (document.layers)
	{
	newsDiv = document.news;
	newsDiv.clip.top = cliptop;
	newsDiv.clip.bottom = cliptop + boxheight;
	newsDiv.clip.left = 0;
	newsDiv.clip.right = boxwidth + leftedge;
	newsDiv.left = leftedge;
	newsDiv.top = topedge - cliptop;
	}
	else
	{
	newsDiv = news.style;
	newsDiv.clip = "rect(" + cliptop + "px " + (boxwidth + leftedge) + "px " + (cliptop + boxheight) + "px 0px)";
	newsDiv.pixelLeft = leftedge;
	newsDiv.pixelTop = topedge - cliptop;
	}
cliptop = (cliptop + 1) % (scrollheight + boxheight);
newsDiv.visibility='visible';
setTimeout("scrollnews(" + cliptop + ")", 200);
}

function emailCheck (requiredFields)
{
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


   /* Finally, let's start trying to figure out if the supplied address is
   valid. */
  for (var field=0; field < requiredFields.length; field++)
  {
   /* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
	var matchArray=requiredFields[field].match(emailPat)
	if (matchArray==null)
	{
  	/* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert(JS_ERR_2)
	return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	// See if "user" is valid 
	if (user.match(userPat)==null)
	{
    // user is not valid
    alert(JS_ERR_2)
    return false
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null)
	{
    // this is an IP address
	  for (var i=1;i<=4;i++)
	  {
	    if (IPArray[i]>255)
		{
	    alert(JS_ERR_3)
		return false
	    }
      }
      return true
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null)
	{
	alert("Le nom de domaine n'est pas valide.")
    return false
	}

	/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

	/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
	{
    // the address must end in a two letter or three letter word.
    alert(JS_ERR_2)
    return false
	}

	// Make sure there's a host name preceding the domain.
	if (len<2)
	{
    var errStr="hostname misses !"
    alert(errStr)
    return false
	}
  }
// If we've gotten this far, everything's valid!
	if (submitcount < 4)
    {
    submitcount += 1;  
	//return document.FileUpload.submit(document,input,true);	    
    return true;
	}
	else
	{
	alert(JS_ERR_12);
	return false;
	}
}

// Ancre automatique

function reserv(nem)
{
num = nem;
}

stopreal = 0;
function anch_it()
{
	if(stopreal<1)
	{
	this.location.hash = num;
	}
stopreal = 1;
}
		
function affect_check_procs(form, check_list) {
	for(check_type in check_list) {
		field_list = check_list[check_type];
		for(obj_idx in field_list) {	
			obj_name = "html_fields[" + field_list[obj_idx] + "]";
			affect_check_proc(form[obj_name], check_type);
		}
	}
return false;
}

			
err_msgs = {
	alphabetic: "This field must be alphabétic.",
	alphanumeric: "This field must be alphanuméric.",
	numeric: "This field must be numéric.",
	adress: "This field must be alphanuméric.",
	mail: "This field must be formatted as 'user@server.domain'."
};

format_ok = true;

/*required_fields = {
		nom: "votre nom", 
		prenom: "votre prénom", 
		societe: "votre société",
		pays: "votre pays", 
		ville: "votre ville",
		code_postal: "votre code postal", 
		telephone: "votre téléphone", 
		mail: "votre e-mail"
	};*/

function affect_check_proc(text_obj, format_name) {
	text_obj.onblur = function ()
	{
	
		format_ok = ((text_obj.value == "") || is(format_name, text_obj.value));
		if(!format_ok)
		{
			if(!window.confirm(err_msgs[format_name] + "\n\n" + 
						"Click on 'OK' to retry or on 'Annul' to delete."))
			{
			text_obj.value = "";
			}
			text_obj.focus();
			text_obj.select();
		}
	/*if(text_obj.name == "html_fields[payment_type]")
	{	
		if(text_obj.options.selectedIndex == 6)
		{
		alert('We accept International cheque only.\n\r Your credit will be accepted after we receive the cheque');
		}
		if(text_obj.options.selectedIndex == 7)
		{
		alert('You must to phone us at 0-000-000-000 and we \'ll give you our bank settings.\n\r Your credit will be accepted after we receive the bank transfer.');
		}
	}*/
	return false;
	} 		
}

regex_formats = {
	alphabetic: "^[a-zçàâéèêëîïôöùû]+([ '-][a-zçàâéèêëîïôöùû]+)*$",
	numeric: "^[0-9]+$",
	alphanumeric: "^[0-9a-zçàâéèêëîïôöùû]+([ '-_][0-9a-zçàâéèêëîïôöùû]+)*$",
	//alphanumeric: "^[0-9a-zA-Z]+([0-9a-zA-Z]+)*$",
	adress: "^[ '°,;./a-zçàâéèêëîïôöùû0-9-]*$", /*  attention : peu retrictif */
	mail: "^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)?$",
	web: "^((http://|www\.)[a-z0-9-]+(\.[a-z0-9-]+)+)?$"
};

function is(format_name, str) { 
	return((new RegExp(regex_formats[format_name], "i")).test(str));
}	

function affect_submit_check(form, required_fields) {
	form.onsubmit = function ()
	{
		if(!format_ok) {
			// inv : au moins un champ n'a pas le bon format (ie on est en cours de vérification)
			// => pas de submit ;  
			return false; 
		}
		
        var empty_fields_str = "";
        for(field_name in required_fields)
		{
			obj_name = "html_fields[" + field_name + "]";
			
			if(form[obj_name].type == "select-one")
			{
				if(form[obj_name].selectedIndex == "")
				{
				empty_fields_str += "   - " + required_fields[field_name] + "\n";
				}
        	}
        	else if(form[obj_name].value == "")
			{
        	empty_fields_str += "   - " + required_fields[field_name] + "\n";
        	}
			
			if(field_name == "payment_mode")
			{
				if(form[obj_name][0].checked == false && form[obj_name][1].checked == false)
				{
				empty_fields_str += "   - " + required_fields[field_name] + "\n";
				}
				else if(form[obj_name][1].checked == true)
				{
					if(form.bankcard_name.value == "" || form.bankcard_number.value == "" || form.payment_type.selectedIndex == "" || form.bankcard_exp_month.selectedIndex == "" || form.bankcard_exp_year.selectedIndex == "" || form.bankcard_cvv.value =="")
					{
					empty_fields_str += "   - " + JS_ERR_13 + "\n";
					}
				}
			}
		}
        
        var ok_to_submit = (empty_fields_str == "");

        if(!ok_to_submit)
		{
        alert("Before to continue, thanks to fill in :\n" + empty_fields_str);
		return ok_to_submit;
		}
		else
		{	
			if(submitcount < 4)
			{
			submitcount++;			
			}
			else
			{
			alert(JS_ERR_12);
			return false;
			}
		}
	}
}

/*function OwnerSelect()
{
	if(document.inscription.card_owner.checked == true)
	{
	 document.inscription['html_fields[bankcard_name]'].value = document.inscription['html_fields[nom]'].value;
	 document.inscription['html_fields[bankcard_surname]'].value = document.inscription['html_fields[prenom]'].value;
	}
	else
	{
	 document.inscription['html_fields[bankcard_surname]'].value = "";
	 document.inscription['html_fields[bankcard_name]'].value = "";
	}	
}*/	

//-->