// Script validation email et informations et submit du formulaire si ok
	var isNav = (navigator.appName.indexOf("Netscape") !=-1);
	if (isNav)
	{
	
	}
	else
	{
	}
	
	
	
	function verifmail(email)
	{
		if (isNav){
		
			// vérif validité email par STRING
                               var arobase = email.indexOf("@")
                                var point = email.lastIndexOf(".")
                                 if((arobase < 3)||(point + 2 > email.length) ||(point < arobase+3)) { 
                                 	return false;}
                                 else {                                 	
                                  	return true;}
			}
		else{
			var reg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/
			return (reg.exec(email)!=null)
		}
	}
					
	function inscription()	
	{
	var bad_enter = new Array();
    var j         = 0;
    var y         = "";
    var missing_fields = new Array();
    var i              = 0;
    var x              = "";
	         
    /* check for missing fields */
    
    // email checking
    if (document.fInscription.iEmail.value ==''){
		missing_fields[i] = "E-mail";
        i = i + 1;
	} else {
	
		
		 if ( verifmail(document.fInscription.iEmail.value)!=true){
			missing_fields[i] = "email must have the form : xxx @ xxx. xx";
			 i = i + 1;
		}
	}
    
    /* check for missing fields */
    if (document.fInscription.last_name.value == ''){
        missing_fields[i] = "Last name";
        i = i + 1;
    }
    
     if (document.fInscription.first_name.value == ''){
        missing_fields[i] = "First name";
        i = i + 1;
    }
	
    // controle saisie password
    if (document.fInscription.iPassword.value == '' || document.fInscription.confirm_password.value == '' || document.fInscription.iPassword.value.length<3 ){
        missing_fields[i] = "Password must be at least 4 characters long";
        i = i + 1;
    }
    else {
    if (document.fInscription.iPassword.value != document.fInscription.confirm_password.value ){
        missing_fields[i] = "Error in password confirmation";
        i = i + 1;
		}
    } 
    
    // controle si CGU acceptées
    if(document.fInscription.termsofuse.checked) {}
    else {
    	missing_fields[i] = "You have to accept terms of use";
        i = i + 1;
    	}
    	
    // controle date de naissance
/**  
   if (isNaN(document.fInscription.naissanceJour.value) || isNaN(document.fInscription.naissanceMois.value) || isNaN(document.fInscription.naissanceAn.value)){
	missing_fields[i] = "date de naissance incorrecte format JJ / MM /AAAA";
        i = i + 1;
	}
    if(document.fInscription.naissanceJour.value==''||document.fInscription.naissanceJour.value<1 ||document.fInscription.naissanceJour.value>31 ||document.fInscription.naissanceMois.value<1 ||document.fInscription.naissanceMois.value > 12 || document.fInscription.naissanceAn.value<1900 || document.fInscription.naissanceAn.value >2002)
    {
    	missing_fields[i] = "date de naissance incorrecte format JJ / MM /AAAA";
        i = i + 1;
    	}
  **/  
    // alert sending
    if ((i > 0) || (j >0)){
        for (var i=0; i<missing_fields.length; i++)
		    var x = x + "\t" + missing_fields[i] + "\n";
		for (var j=0; j<bad_enter.length; j++)
		    var y = y + "\t" + bad_enter[j] + "\n";
		var message = "";
		if (x!="") { message = "Following informations are missing or incorrect:\n" + x; }
		if ((x!="") && (y!="")) { message = message + "\n"; }
		if (y!="") { message = message + "Following informations are incorrect :\n" + y; }
		alert(message);
        return(false);
    }
	document.fInscription.submit();
	return 0 ; 
					}
					
function showDiv(d){
	var st = document.getElementById(d).style.display;
	
		if (document.getElementById(d).style.display != 'block') {document.getElementById(d).style.display = 'block';}
		else {document.getElementById(d).style.display = 'none';}
}

function freeLesson(L){
	if(L=='') {L='fr';}
	url = 'http://elearning-services.com/free/' + L + '/assimil_index.asp';
	var options = 'top=0,left=0,resizable=yes, toolbar=no, scrollbars=yes, menubar=no, location=no, statusbar=no';
	options = options + ' , width=' + screen.width + ', height=' + screen.height ;
	var freeWindow = window.open(url,'Lesson',options);
}
function validFormLogin(){

	email = document.getElementById('email').value;
	passw = document.getElementById('password').value; 
	if(email.length<6 || passw.length<4){
		alert('Please complete form');
	}
	else{
		document.getElementById('loginBox').submit();
	}
}
function clearInput(i){
	document.getElementById(i).value='';
}
function importantEmail(){
	document.getElementById('importantEmail').style.display = 'block';
}
function commande(){
	document.getElementById('fCommande').submit();
}
function showLogin(){
	document.getElementById('email').style.backgroundColor = '#EBEBEB';
	document.getElementById('email').focus();
}
function launch(u,n,c){

	//url = 'http://cours.toutapprendre.com/' + c + '/common/ELS/launch.asp?c=' + u + '&n=' + n;
	url = 'http://cours.toutapprendre.com/common/ELS/launch.asp?c=' + u + '&n=' + n;
	var options = 'top=0,left=0,resizable=yes, toolbar=no, scrollbars=yes, menubar=no, location=no, statusbar=no';
	options = options + ' , width=' + screen.width + ', height=' + screen.height ;
	var LancementCoursTA = window.open(url,'assimil',options);

}
function wGetJava(){
	if(navigator.javaEnabled ()){
		return false;
	}
	else {
		 var tGetJava = '<p class="java"><a href="http://www.java.com/en/download/download_the_latest.jsp" title="get Java here - free download" onclick="window.open(this.href); return false;"><img src="img/get_java.gif" alt="get Java here - free download" /></a>Java wasn\'t detect on your system<br /><a href="http://www.java.com/en/download/download_the_latest.jsp" title="get Java here - free download">Download and install Java now</a></p>';
		 document.write (tGetJava);
		}
}
function getHTTPObject() {
	httpObj = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			httpObj = new XMLHttpRequest();
        } catch(e) {
			httpObj = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	httpObj = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		httpObj = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		httpObj = false;
        	}
		}
    }
    if(!httpObj){
    	alert('httpRequest n\'est pas supporté par votre navigateur');
    }
	return httpObj;
} 
function convertUSD(p, div, d){
	var host = window.location.host;

	var url = 'http://' + host + '/convertisseur/convertUsd.asp?devise=' + d ;
	var taux = 0;
	var conv = 0;
	var xhr_object = getHTTPObject();
	xhr_object.open("GET", url, true);
	xhr_object.onreadystatechange = function() {
	   if(xhr_object.readyState == 4) 
	   {
	  taux = xhr_object.responseText ;
	   }
	   conv = Math.round(p*taux*100)/100 ;
	   if(conv==0) conv=' ';
	  document.getElementById(div).innerHTML = conv; //Math.round(p*taux*100)/100 ;
	}
	xhr_object.send(null);

}