var RestoreScrollPosition = null;
var PageLoadSpecific = null;

window.onload = BodyOnLoad;

function BodyOnLoad()
{
    if( LoadMenu != null )
		LoadMenu();

	/*if( PageLoadSpecific != null )
        PageLoadSpecific(); */
	
	oZebra = document.getElementById('zebra')
	if(oZebra)
        stripe('zebra', '#fff', '#f7f6f4');
	
    // Textbox txtZipCode dans le dealer locator
    var txtZipCode = document.getElementById("UserControl1_txtZipCode");
    if(txtZipCode)
    {
        txtZipCode.onkeydown = KeyDownHandler;
    }
    
    //Gestion du positionnement de la page après postback
    if( RestoreScrollPosition != null )
        RestoreScrollPosition();
}

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 KeyDownHandler()
{
    // Process only the Enter key
    if(event.keyCode == 13)
    {
        // Cancel the default submit
        event.returnValue = false;
        event.cancel = true;

        // Submit the form by programmatically clicking the specified button
        document.getElementById("UserControl1_btnSearch").click();
    }
}

function getRealLeft(imgElem)
{
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
  	while (tempEl != null)
	{
  		xPos += tempEl.offsetLeft;
  		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;
  		
  		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;
}

