/*
 * Proyecto 83 - http://proyecto83.com - "Simplify, simplify, simplify"
 * Copyright (C) 2008 Emilio Mariscal
 * 
 * == BEGIN LICENSE ==
 * 
 * Licensed under the terms of any of the following licenses at your
 * choice:
 * 
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 * 
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 * 
 * == END LICENSE ==
 * 
 * 	File Name  :
 *
 * 	visualfx.js
 *
 * File Authors :
 * 		Emilio Mariscal ( emi420@gmail.com )
 */
 
var visualFX = {

	/*** DropDown menu ***/
	
	cDDMenu: 0,			// Control DropDown menu
	aDDMenu: null, 		// Array DropDown menu
	eMenu : null,		// Elemento menu
	aMenuList : null,	// Array menu (listado)
	cMenu : 0,			// Control menu 

	
	loadDDMenu: function( eId ) {
	
		visualFX.aDDMenu = new Array() ;
		var eMenu = document.getElementById(eId) ;		
		var eMenuContent = document.getElementById( eMenu.id + '_c' ) ;
		var leftPos = visualFX.getLeftPos(eMenu) - 195 ;

		eMenuContent.style.left = leftPos + 'px';
		
		eMenu.onclick = function () { 

			eMenuContent = document.getElementById( this.id + '_c' ) ;
			eMenu = document.getElementById( this.id ) ;
			visualFX.aDDMenu[visualFX.aDDMenu.length] = eMenuContent ;
			visualFX.hideDDMenus() ;
			
			visualFX.cDDMenu = 1 ;
			
			if(eMenuContent.style.display == 'none') {
				eMenuContent.style.display = 'block' ;
			} else {
				eMenuContent.style.display = 'none' ;
			}
		} ;
		
		var aMenuElements = eMenuContent.getElementsByTagName('li') ;
		
		for(i = 0 ; i < aMenuElements.length ; i++ ) {
			aMenuElements[i].onmouseout = function() {
				visualFX.cDDMenu = 0 ;
				setTimeout( "if(visualFX.cDDMenu==0) visualFX.hideDDMenus() ;" , visualFX.ConfigMenuTimeOut ); 
			} ;
		}
		
		for(i = 0 ; i < aMenuElements.length ; i++ ) {
			aMenuElements[i].onmouseover = function() {
				visualFX.cDDMenu = 1 ;
			} ;
		}
		
	},
	
	hideDDMenus: function() {
		for(i = 0; i < visualFX.aDDMenu.length; i++ )
			visualFX.aDDMenu[i].style.display = 'none' ;
	},
	
	getTopPos: function ( inputObj ) {
	
	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null){
	  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
	  }
	  return returnValue;
	},

	getLeftPos: function ( inputObj ) {
	
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null){
	  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
	  }
	  return returnValue;
	}
}