//===============================================================
//======BOOKMART=================================================
//===============================================================
//Function bookmark favorites
function bookmark_uk(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Add to your favorites ";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}

function bookmark_fr(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Ajouter aux favoris";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}

function bookmark_es(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Add to your favorites ";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}

function bookmark_de(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Add to your favorites ";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}

function bookmark_it(){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	var url="http://www.easyexpat.com";
	var title="EasyExpat";

	window.external.AddFavorite(url,title);
}
else {
	var msg = "Add to your favorites ";
	if(navigator.appName == "Netscape") msg += "(CTRL+D)";

	window.alert("Press Ctrl+D to bookmark");
}
}
//===============================================================
//==========MENU=================================================
//===============================================================
//For references: http://www.dynamicdrive.com/dynamicindex1/navigate1.htm
//Functions menu

var head="display:''"
img1=new Image()
img2=new Image()

function change(){
	if(!document.all)
	return
	if (event.srcElement.id=="foldheader") {
		var srcIndex = event.srcElement.sourceIndex
		var nested = document.all[srcIndex+1]
		if (nested.style.display=="none") {
			nested.style.display=''
		}
		else {
			nested.style.display="none"
		}
	}
}

document.onclick=change

// end menu
//===============================================================
//======SWAP THE PICTURES========================================
//===============================================================
function MM_findObj(n, d) { //v3.0
  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); return x;
}
/* Functions that swaps images. */
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_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;
}

/* Functions that handle preload. */
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];}}
}
//===============================================================
//==========WINDOWS==============================================
//===============================================================
//Open window email without menu
function windowContact()
{
	wiRef = window.open("","winContact","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,width=540,height=640,left=100,top=10")
}

//Open window privacy policy without menu
function windowPrivacyP()
{
	wiRef = window.open("","winPrivacyP","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=540,height=640,left=100,top=10")
}

//Open window about us without menu
function windowAboutUs()
{
	wiRef = window.open("","winAboutUs","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=540,height=640,left=100,top=20")
}

//Open window ads without menu
function windowAds()
{
	wiRef = window.open("","winAds","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=540,height=640,left=100,top=20")
}

//Open window weather without menu
function windowWeather()
{
	wiRef = window.open("","winWeather","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=850,height=640,left=100,top=20")
}

//Open window quiz without menu
function windowQuiz()
{
	wiRef = window.open("","winQuiz","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=540,height=640,left=100,top=20")
}

//Open window default without menu
function windowDefault()
{
	wiRef = window.open("","winDefault","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=700,height=640,left=100,top=20")
}

//Open window News without menu
function windowNews()
{
	wiRef = window.open("","winNews","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,width=170,height=320,left=750,top=180")
}

//Open window Translate without menu
function windowTranslate()
{
	wiRef = window.open("","winTranslate","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=735,height=675,left=100,top=20")
}

//Open window SendFriend without menu
function windowSendfriend()
{
	wiRef = window.open("","winSendfriend","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,width=500,height=350,left=100,top=20")
}

//Open window Forum 
function windowForum()
{
	wiRef = window.open("","winForum","toolbar=1,location=1,directories=0,menuBar=0,scrollbars=1,resizable=1,width=785,height=590,left=100,top=10")
}

//===============================================================
//==================SCRIPTS======================================
//===============================================================
/*Permet de valider les champs saisis . */
/* 1)dans les envoi de mail pour le form -contact-. */
/* 2)dans les inscriptions individuelles pour form -inscriptions-. */

function valid_fr(leform,nomduform)
{
	var nomduformulaire= nomduform ;
	var course=document.form_inscription.select_cou.value ;
	var sexe=document.form_inscription.sexe.value;
	var nom=document.form_inscription.name.value;
	var prenom=document.form_inscription.prenom.value;
	var annee=document.form_inscription.annee.value;
	var email=document.form_inscription.email_sender.value;
	var club	=document.form_inscription.club.value;
	var tel=document.form_inscription.tel.value;
	var acceptation=document.form_inscription.acceptation.checked;
//alert(leform.name.value + "  leformname.value1 _ " );
//->alert(nomduformulaire + "  est nomduformulaire2_ " );
//alert(course + nom+ prenom + sexe + annee + email + tel + club + "acc:" + acceptation +":" );
//return false;

   if ((nomduformulaire=="form_inscription") && (course=="0"))
   {
		alert("Penser à indiquer la course !");
		leform.select_cou.focus();
		return false;
   }
   if ((nomduformulaire=="form_inscription") && (sexe=="0"))
   {
		alert("Entrez H ou F");
		leform.sexe.focus();
		return false;
	}
	if (leform.name.value=="")
   {
		alert("Le champ -Nom- est non renseigné");
		leform.name.focus();
		return false;
   }
   if ((nomduformulaire=="form_inscription") && (prenom==""))
   {
		alert("Le champ -PreNom- est non renseigné");
		leform.prenom.focus();
		return false;
	}
   if ((nomduformulaire=="form_inscription") && (annee=="0"))
   {
		alert("Entrez annee de naissance");
		leform.annee.focus();
		return false;
	}
	 if ((nomduformulaire=="form_contact") && (leform.msg.value==""))
   {
		alert("'Message' non renseigné");
		//leform.msg.select();
		leform.msg.focus();
		return false;
   }
   if ((nomduformulaire=="form_inscription") && (acceptation==false))
   {
		alert("Veuillez accepter les conditions d'inscription.");
		//leform.annee.select();
		leform.annee.focus();
		return false;
	}
   if (leform.email_sender.value=="")
    {
            alert("Le champ -E-mail- non renseigné");
            leform.email_sender.select();
            leform.email_sender.focus();
            return false;
    }
    else
            {
            if (leform.email_sender.value.indexOf("@")==-1)        {
                    alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                    leform.email_sender.select();
                    leform.email_sender.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email_sender.value.length;
                    position = leform.email_sender.value.indexOf("@");
                    left_str = leform.email_sender.value.substring(0,position);
                    right_str = leform.email_sender.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

							if ((left_len==0) || (right_len==0))
                    {
                    alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                    leform.email_sender.select();
                    leform.email_sender.focus();
                    return false;
                    }
                    else
                    {
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                            leform.email_sender.select();
                            leform.email_sender.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                                    leform.email_sender.select();
                                    leform.email_sender.focus();
                                    return false;
                                    }
                                    else
                                    {
                                            if (l_right_len==0)
                                            {
                                            alert("Veuillez saisir une adresse e-mail correcte, SVP.");
                                            leform.email_sender.select();
                                            leform.email_sender.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function valid_en(leform)
{
   if (leform.email.value=="")
    {
            alert("'E-mail' field empty");
            leform.email.focus();
            return false;
    }
    else
            {
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("Please type a correct e-mail address.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("Please type a correct e-mail address.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("Please type a correct e-mail address.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("Please type a correct e-mail address.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("Please type a correct e-mail address.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function valid_es(leform)
{
   if (leform.email.value=="")
    {
            alert("'E-mail' es incorrecto");
            leform.email.focus();
            return false;
    }
    else
            {
    
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("El email es incorrecto.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("El email es incorrecto.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("El email es incorrecto.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("El email es incorrecto.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("El email es incorrecto.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function valid_it(leform)
{
   if (leform.email.value=="")
    {
            alert("'E-mail' è errato");
            leform.email.focus();
            return false;
    }
    else
            {
    
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("Il email è errato.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("Il email è errato.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("Il email è errato.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("Il email è errato.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("Il email è errato.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function valid_de(leform)
{
   if (leform.email.value=="")
    {
            alert("'E-mail' ist falsch");
            leform.email.focus();
            return false;
    }
    else
            {
    
            if (leform.email.value.indexOf("@")==-1)        {
                    alert("Das email ist falsch.");
                    leform.email.focus();
                    return false;
            }
            else
            {
                    longueur = leform.email.value.length;
                    position = leform.email.value.indexOf("@");
                    left_str = leform.email.value.substring(0,position);
                    right_str = leform.email.value.substring(position+1,longueur);
                    left_len = left_str.length;
                    right_len = right_str.length;

    
                    if ((left_len==0) || (right_len==0))
                    {
                    alert("Das email ist falsch.");
                    leform.email.focus();
                    return false;
                    }
                    else
                    {
    
                            if (right_str.indexOf(".")==-1)
                            {
                            alert("Das email ist falsch.");
                            leform.email.focus();
                            return false;
                            }
                            else
                            {
                                    right_longueur = right_str.length;
                                    right_position = right_str.lastIndexOf(".");
                                    l_right_str = right_str.substring(0,right_position);
                                    r_right_str = right_str.substring(right_position+1,right_longueur);
                                    l_right_len = l_right_str.length;
                                    r_right_len = r_right_str.length;

    
                                    if ((r_right_len < 2)||(r_right_len > 4))
                                    {
                                    alert("Das email ist falsch.");
                                    leform.email.focus();
                                    return false;
                                    }
                                    else
                                    {
    
                                            if (l_right_len==0)
                                            {
                                            alert("Das email ist falsch.");
                                            leform.email.focus();
                                            return false;
                                            }
                                    }
                            }
                    }
            }
    }
	return true;
}

function popup(mylink, popupNews)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	window.open(href,popupNews,'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,width=170,height=320,left=750,top=180')
	return false;
}


//-----------------
// AUTOMATIC SUBMIT
//-----------------
function formHandler(form)
{
	var URL = form.select.options[form.select.selectedIndex].value;
	window.location.href = URL;
}
function formHandlerCategorie(form)
{
	var URL = form.select_cat.options[form.select_cat.selectedIndex].value;
	window.location.href = URL;
}


//-----------------
// GET TIME
//-----------------
function GetTime() 
{ 
var dt = new Date();
var def = dt.getTimezoneOffset()/60;

var gmt = (dt.getHours() + def);
var ending = ":" + IfZero(dt.getMinutes()) + ":" +  IfZero(dt.getSeconds());

var GMT_ln =check24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));
document.clock.GMT_ln.value = (IfZero(GMT_ln) + ending);

var GMT_fk =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_fk.value = (IfZero(GMT_fk) + ending);

var GMT_ma =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_ma.value = (IfZero(GMT_ma) + ending);

var GMT_mi =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_mi.value = (IfZero(GMT_mi) + ending);

var GMT_pa =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
document.clock.GMT_pa.value = (IfZero(GMT_pa) + ending);

var GMT_ny =check24(((gmt + (24-4)) > 24) ? ((gmt + (24-4)) - 24) : (gmt + (24-4)));
document.clock.GMT_ny.value = (IfZero(GMT_ny) + ending);

var GMT_mr =check24(((gmt + (24-4)) > 24) ? ((gmt + (24-4)) - 24) : (gmt + (24-4)));
document.clock.GMT_mr.value = (IfZero(GMT_mr) + ending);

var GMT_sf =check24(((gmt + (24-7)) > 24) ? ((gmt + (24-8)) - 24) : (gmt + (24-8)));
document.clock.GMT_sf.value = (IfZero(GMT_sf) + ending);

var GMT_sy =check24(((gmt + 10) > 24) ? ((gmt + 9) - 24) : (gmt + 9));
document.clock.GMT_sy.value = (IfZero(GMT_sy) + ending);

setTimeout("GetTime()", 1000);
}

function IfZero(num) 
{
return ((num <= 9) ? ("0" + num) : num);
}

function check24(hour) 
{
return (hour >= 24) ? hour - 24 : hour;
}


