window.onload = BodyOnLoad;

function BodyOnLoad()
{
    if( typeof(LoadMenu) != "undefined" && LoadMenu != null)
		LoadMenu();
	
	MM_preloadImages('images/bvoteron.gif','images/binscrireon.gif');
}

function GetEventObject( evt )
{
	if( !evt && window.event )
	{
		evt = window.event;
	}

    if (evt)
	{
		if( evt.srcElement )
			return evt.srcElement;
		else
			return evt.target;
	}
	else
		return null;
}

function getRealLeft(imgElem)
{
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
  	while (tempEl != null)
	{
  		xPos += tempEl.offsetLeft;
  		
  		//Si le navigateur est IE pour windows, il faut aussi ajouter les bordures des
  		//éléments dans le calcul parce qu'ils ne sont pas inclus dans offsetTop
  		if( navigator.platform.indexOf("Win") != -1 && navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1 )
  		{
  		    var nBorder = parseInt(tempEl.currentStyle.borderLeftWidth);
  		    
  		    if( !isNaN(nBorder) )
  		        xPos += nBorder;
  		}
  		  		
  		tempEl = tempEl.offsetParent;
  	}
  	
    if(navigator.platform == "MacPPC" && navigator.userAgent.indexOf("MSIE") != -1)
    {           
        //Dans IE pour Mac, il faut additionner la marge du body.
        xPos += parseInt(document.body.currentStyle.marginLeft);       
    }
    
	return xPos;
}

function getRealTop(imgElem)
 {
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while ( tempEl != null )
	{
        //Note: On a pas besoin de passer par ici pour calculer la position avec
        //      opera car offsetTop contient déjà la bonne position.  On a pas besoin
        //      de l'additionnner aux positions de ses éléments parent.
  		yPos += tempEl.offsetTop;
  		
  		
  		//Si le navigateur est IE pour windows, il faut aussi ajouter les bordures des
  		//éléments dans le calcul parce qu'ils ne sont pas inclus dans offsetTop
  		if( navigator.platform.indexOf("Win") != -1 && navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1 )
  		{
  		    var nBorder = parseInt(tempEl.currentStyle.borderTopWidth);
  		    
  		    if( !isNaN(nBorder) )
  		        yPos += nBorder;
  		}
		  		
  		/*if(navigator.userAgent.indexOf("Opera") != -1 && yPos != 0)
  		    tempEl = null;
  		else*/
  		    tempEl = tempEl.offsetParent;
  	}
  	
    if(navigator.platform == "MacPPC" && navigator.userAgent.indexOf("MSIE") != -1)
    {           
        //Dans IE pour Mac, il faut additionner la marge du body.
        yPos += parseInt(document.body.currentStyle.marginTop);       
    } 

	return yPos;
}

function PopVideo(nRef)
{
	if(nRef == "56") 
	{
		nH = 200;
		nW = 250;
	}
	else
	{
		nH = 350;
		nW = 400;
	}

	window.open("video.asp?nRef="+nRef+"&nH="+nH+"&nW="+nW,'fWindow',config="height=" + (nH+50) + ",width=" + (nW+50) + ",toolbar=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,status=0");
}

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;
}

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];}}
}

function MM_findObj(n, d) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

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 openWinFriends(strRef)
{
	window.open("friends.asp?"+strRef,'fWindow',config="height=395,width=438,toolbar=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,status=0");	
}

function openScoreKeeper()
{
	window.open("score-keeper.html",'fWindow',config="height=530,width=520,toolbar=0,menubar=0,scrollbars=1,resizable=0,location=0,directories=0,status=0");	
}

function InscNews()
{
	var strEmail = window.document.FNews.iEmail.value;
	if(strEmail.indexOf("@") == -1 || strEmail.indexOf(".") == -1)
	{
		alert("Veuillez inscrire un email valide.");
		window.document.FNews.iEmail.focus();
	}
    else
	   window.open("enr_newsletter.asp?email="+strEmail,'fWindow',config="height=290,width=438,toolbar=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,status=0");	
}

function Friends()
{
	var strEmail = window.document.Ffriends.itoemail.value;
	if(window.document.Ffriends.ifromname.value == "")
	{
		alert("Veuillez inscrire votre nom.");
		window.document.Ffriends.ifromname.focus();
		return false;
	}
	else if(window.document.Ffriends.ifromemail.value == "")
	{
		alert("Veuillez inscrire votre email.");
		window.document.Ffriends.ifromemail.focus();
		return false;
	}
	else if(strEmail.indexOf("@") == -1 || strEmail.indexOf(".") == -1)
	{
		alert("Veuillez inscrire un email valide.");
		window.document.Ffriends.itoemail.focus();
		return false;
	}
    else
	   return true;
}

function Contact()
{
	var strEmail = window.document.Fcontact.iemail.value;
	if(window.document.Fcontact.inom.value == "")
	{
		alert("Veuillez inscrire votre nom.");
		window.document.Fcontact.inom.focus();
		return false;
	}
	else if(window.document.Fcontact.iville.value == "")
	{
		alert("Veuillez inscrire votre ville.");
		window.document.Fcontact.iville.focus();
		return false;
	}
	else if(window.document.Fcontact.imess.value == "")
	{
		alert("Veuillez inscrire votre message.");
		window.document.Fcontact.imess.focus();
		return false;
	}
	else if(strEmail.indexOf("@") == -1 || strEmail.indexOf(".") == -1)
	{
		alert("Veuillez inscrire un email valide.");
		window.document.Fcontact.iemail.focus();
		return false;
	}
    else
	   return true;
}
