function copyCompanyFacturationAddressToShippingAddress(theFrm){
	theFrm.OrganisationShippingName.value = theFrm.OrganisationFacturationName.value;
	theFrm.OrganisationShippingAddress.value = theFrm.OrganisationFacturationAddress.value;
	theFrm.OrganisationShippingZipCode.value = theFrm.OrganisationFacturationZipCode.value;
	theFrm.OrganisationShippingCity.value = theFrm.OrganisationFacturationCity.value;
	theFrm.OrganisationShippingCountry.value = theFrm.OrganisationFacturationCountry.value;
}


function checkPublicationFormStep(theFrm,fieldsArray){
	var errors = "";
	for (var i=0; i < theFrm.length; i++) 
	{
		var element = theFrm.elements[i];
		for (var j in fieldsArray) {
			//alert(element.name + ' == ' + fieldsArray[j]);
			if (element.name == fieldsArray[j]){
				
				if(!isFilled(element)){
					switch(element.name) {
						
						case 'OrganisationFacturationName':		errors += "- Donn\u00E9es de facturation: nom\n";
																break;
						case 'OrganisationFacturationAddress':	errors += "- Donn\u00E9es de facturation: adresse\n";
																break;	
						case 'OrganisationFacturationZipCode':	errors += "- Donn\u00E9es de facturation: code postal\n";
																break;
						case 'OrganisationFacturationCity':		errors += "- Donn\u00E9es de facturation: localit\u00E9\n";
																break;
						case 'OrganisationFacturationCountry':	errors += "- Donn\u00E9es de facturation: pays\n";
																break;
																
						case 'OrganisationShippingName':		errors += "- Donn\u00E9es de livraison: nom\n";
																break;	
						case 'OrganisationShippingAddress':	errors += "- Donn\u00E9es de livraison: adresse\n";
																break;	
						case 'OrganisationShippingZipCode':	errors += "- Donn\u00E9es de livraison: code postal\n";
																break;
						case 'OrganisationShippingCity':	errors += "- Donn\u00E9es de livraison: localit\u00E9\n";
																break;										
						case 'OrganisationShippingCountry':		errors += "- Donn\u00E9es de livraison: pays\n";
																break;									
																
						default:								errors += "Veuillez remplir les champs obligatoires\n";
					}
				}
				
				
			}
		}
	}
	
	
	if(errors != ""){
		alert("Veuillez remplir les champs suivants:\n"+errors);	
	} else {
		theFrm.submit();
	}
}

var requiredfields=new Array("");

function isFilled(field)
{
	if (field.value.length < 1)	{
		return false;
	} else {
		return true;
	}
}

function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function copyCompanyAddressToFacturationAddress(theFrm){
	theFrm.OrganisationFacturationName.value = theFrm.OrganisationName.value;
	theFrm.OrganisationFacturationAddress.value = theFrm.OrganisationAddress.value;
	theFrm.OrganisationFacturationZipCode.value = theFrm.OrganisationZipCode.value;
	theFrm.OrganisationFacturationCity.value = theFrm.OrganisationCity.value;
	theFrm.OrganisationFacturationCountry.value = theFrm.OrganisationCountry.value;
	
}
									
function copyCompanyFacturationAddressToShippingAddress(theFrm){
	theFrm.OrganisationShippingName.value = theFrm.OrganisationFacturationName.value;
	theFrm.OrganisationShippingAddress.value = theFrm.OrganisationFacturationAddress.value;
	theFrm.OrganisationShippingZipCode.value = theFrm.OrganisationFacturationZipCode.value;
	theFrm.OrganisationShippingCity.value = theFrm.OrganisationFacturationCity.value;
	theFrm.OrganisationShippingCountry.value = theFrm.OrganisationFacturationCountry.value;
}

function isNumber(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function IsNumeric2(strString){
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++){
      strChar = strString.charAt(i);
	  if (strValidChars.indexOf(strChar) == -1)  blnResult = false;
         
   }
   return blnResult;
}
