var elemento=null;

window.addEvent('domready', function() {
	acordeonMenu = new Accordion($('menu'), 'p.toggler', 'div.menu_int', {
		show:menu_item,
		opacity: false,
		onActive: function(toggler, menu_int){
			//toggler.setStyle('color', '#41464D');
		},
		onBackground: function(toggler, menu_int){
			//toggler.setStyle('color', '#528CE0');
		}
	});

	acordeonDesplegables = new Accordion($('desplegables'), 'h2.toggler', 'div.element', {
		display:item,
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('background-image', 'url(img/menos.gif)');
			toggler.setStyle('background-color', '#F9F7F7');
			toggler.setStyle('margin-bottom', '8px');
			elemento=toggler;
		},
		onBackground: function(toggler, element){
			toggler.setStyle('background-image', 'url(img/mas.gif)');
			toggler.setStyle('background-color', '#FFFFFF');
			toggler.setStyle('margin-bottom', '-8px');
		},
		onComplete: function(){
			ScrollToElement(elemento);
		}
	});	
});

function findPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return posY;
  } else {
    return oElement.y;
  }
}

function ScrollToElement(theElement){
  var selectedPosX = 0;
  var selectedPosY = findPosition(theElement);
          
//  while(theElement != null){
//    selectedPosX += theElement.offsetLeft;
//    selectedPosY += theElement.offsetTop;
//    theElement = theElement.offsetParent;
//  }             		      
 //window.scrollTo(0,selectedPosY);
 window.scrollTo(0, 0);
 if(selectedPosY<window.pageYOffset){
	  //window.scrollTo(0, selectedPosY);
	  
 }

}
