function popup(nom_de_la_page, nom_interne_de_la_fenetre, largeur, hauteur)
{
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;

    window.open (nom_de_la_page, nom_interne_de_la_fenetre, 
    'toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no, top='+top+',left='+left+',width='+largeur+',height='+hauteur);

}

function ControleVideRecherche()
{
    if ((document.search.keywords.value==' Mots-clés' || document.search.keywords.value=='') && document.search.category.value=='')
        alert('Entrez un mot-clé ou une catégorie !');
        
    else
    {
        document.search.method = "post";
        document.search.action = "http://www.doctorama.com/fr/recherche";
        document.search.submit();
    }
}

function ControlePass()
{
    if (document.register.password1.value != document.register.password2.value)
    {    
        alert('Les mots de passe sont différents !');
        document.search.password1.focus();
    }
    else if (document.register.password1.value.length < 4)
        alert('Votre mot de passe doit contenir au moins 4 caractères !');
}

function IsEmptyMult(object)
{
    var isEmpty = 1;
    for (i = 0; i < object.options.length; i++)
    {
        if (object.options[i].selected)
            isEmpty = 0;
    }
    return isEmpty;
}

function ControleVideEvent(object)
{
    if((object.start_date.value=='') || (object.end_date.value=='') 
         || (object.title.value=='') 
         || ((object.city.value==' Ville') || (object.city.value=='')))
    {
        alert('Vous n\'avez pas rempli tous les champs obligatoires !');
        return false;
    }
	return true;
}

function ConfirmRed(Msg, Url1, Url2)
{
    if (confirm(Msg))
        window.location=Url1;
    else
        window.location=Url2;
}

function verifMail(a)
{
    testm = false ;
    
    for (var j=1 ; j<(a.length) ; j++) 
    {
        if (a.charAt(j)=='@') 
        {
            if (j<(a.length-4))
            {
                for (var k=j ; k<(a.length-2) ; k++) 
                {
                    if (a.charAt(k)=='.') 
                        testm = true;
                }
            }
        }
    }
    
    if (testm==false)
    {
        alert('Votre adresse e-mail est incorrecte.\nElle doit comporter un \'@\' et un point');
        document.event.ContactEmail.focus();   
    }
    
    return testm ;

}

function verifMail2(a)
{
    testm = false ;
    
    for (var j = 1 ; j < (a.length) ; j++) 
    {
        if (a.charAt(j) == '@') 
        {
            if (j < (a.length - 4))
            {
                for (var k = j ; k < (a.length-2) ; k++) 
                {
                    if (a.charAt(k) == '.') 
                        testm = true;
                }
            }
        }
    }

    return testm ;

}

function isMail()
{
    testm = false ;
    
    for (var j = 1 ; j < (a.length) ; j++) 
    {
        if (a.charAt(j) == '@') 
        {
            if (j < (a.length - 4))
            {
                for (var k = j ; k < (a.length-2) ; k++) 
                {
                    if (a.charAt(k) == '.') 
                        testm = true;
                }
            }
        }
    }
    
    return testm ;
}

function strReplace(s, r, w)
{
     return s.split(r).join(w);
}
    
function verifLogin(a)
{
    testlog = false;
    var car_inter = new Array ('&','é','\"','\'','(','-','è','ç','à',')','=','~','#','{','[','|','`','\\','^',']','}','$','ù','*','¨','£','%','µ','¤',';',':','!','?','/','§');
    for (var j = 0 ; j < (car_inter.length) ; j++) 
    {
        if (a.indexOf(car_inter[j]) != -1)
        {
            alert('Mauvais identifiant !\nVotre identifiant ne peut être composé que de lettres, chiffres, . et _');
            a = strReplace(a, car_inter[j], '');
            document.register.login.value = a;
        }
        
    }
    
    return testlog;
}
function verifLogin2(a)
{
    testlog = true;
    var car_inter = new Array ('&','é','\"','\'','(','-','è','ç','à',')','=','~','#','{','[','|','`','\\','^',']','}','$','ù','*','¨','£','%','µ','¤',';',':','!','?','/','§',' ');
    for (var j = 0 ; j < (car_inter.length) ; j++) 
    {
        if (a.indexOf(car_inter[j]) != -1)
        {
			testlog = false;
        }
        
    }
    
    return testlog;
}

function favoris() { 
	if (navigator.appName != 'Microsoft Internet Explorer')
		window.sidebar.addPanel("Doctorama - Congrès médical, Formation médicale continue, Conférence médicale ...","http://www.doctorama.com","");
	else 
		window.external.AddFavorite("http://www.doctorama.com","Doctorama - Congrès médical, Formation médicale continue, Conférence médicale ..."); 
}

function IsDateValide(sDate,sDateStyle) {
	var re=/^\d{1,2}\/\d{1,2}\/\d{4}$/;
	if (re.test(sDate)) {
		var dArr = sDate.split("/");
		if (sDateStyle=="US") {
			var d = new Date(dArr[2],Number(dArr[0])-1,dArr[1]);
			return d.getMonth() +1 == dArr[0] && d.getDate() == dArr[1] && d.getFullYear() == dArr[2];
		}
		else {
			var d = new Date(dArr[2],Number(dArr[1])-1,dArr[0]);      	
			return d.getMonth() + 1 == dArr[1] && d.getDate() == dArr[0] && d.getFullYear() == dArr[2];
		}
	}
  return false;
}	
