// JavaScript Document
	menuTop=[0,14,14,14];
	indx=[1,1,1,1];
  	tId = new Array(4);
	tOpenId = new Array(4);
	menu = [false, false, false, false];
	processing = [false, false, false, false];
	var startTime = new Array(4);
	var endTime	= new Array(4);
  
  function load()
    {
    	for(var i=1;i<4;i++)
	    {
	    	document.getElementById('menu'+i+'body').style.top = menuTop[i]+'px';	    	   	
		}
		
	}
		function unload(arrowID , rowID)
	{
			document.getElementById(arrowID).style.backgroundImage='url(../images/offerings/menu_selected.JPG)';
			document.getElementById(rowID).className = 'menu_items_selected';
	}
    
    // Following mouse_over and mouse_out used for left menu to create mouse over effect
    // Create effect that the item is selected i.e. mouse is over the item
    function mouse_over(arrowID , rowID)
	{
		if(document.layers)	   //NN4+
	    {
    		document.layers[arrowID].style.backgroundImage='url(../images/offerings/menu_selected.JPG)';
			document.layers[rowID].className = 'menu_items_selected'; 
	    }
		else if(document.getElementById)	  //gecko(NN6) + IE 5+
    	{
			
			document.getElementById(arrowID).style.backgroundImage='url(../images/offerings/menu_selected.JPG)';
			document.getElementById(rowID).className = 'menu_items_selected';
	     }
	    else if(document.all)	// IE 4
    	{
        	document.all[arrowID].style.backgroundImage='url(../images/offerings/menu_selected.JPG)';
			document.all[rowID].className = 'menu_items_selected';
	    }
	}
	
	// Create effect that the item is unselected i.e. mouse is out 
	function mouse_out(arrowID , rowID)
	{
		if(document.layers)	   //NN4+
	    {
    		document.layers[arrowID].style.backgroundImage='url(../images/offerings/menu_arrow.jpeg)';
			document.layers[rowID].className = 'menu_items_unselected'; 
	    }
		else if(document.getElementById)	  //gecko(NN6) + IE 5+
    	{
			document.getElementById(arrowID).style.backgroundImage='url(../images/offerings/menu_arrow.jpeg)';
			document.getElementById(rowID).className = 'menu_items_unselected';
	     }
	    else if(document.all)	// IE 4
    	{
        	document.all[arrowID].style.backgroundImage='url(../images/offerings/menu_arrow.jpeg)';
			document.all[rowID].className = 'menu_items_unselected';
	    }
	
	}
    
    
    function MouseOut(num)
    {
    	document.getElementById('menu'+num+'body').style.visibility = 'hidden';
		menu[num-1] = false;
    }


    //*******************************************************
    // Following functions are used to create menu animation



    // Set timer when mouse is inside the specific top main menu
	function setTimer(num)
	{
		startTime[num-1] = new Date().getTime();
	}
	
	
	// To avoid following problem:
    // When user moves mouse over the mian top menus for fraction of second (i.e. he/she don't want to open the menu), 
    // then also the sub menu gets open
	function stopTimer(num)
	{
		endTime[num-1] = new Date().getTime();
		
		if((endTime[num-1]-startTime[num-1])<100)
		{	
    		// Reset the processing flag to allow menu to be close, instead of the menu is not totally opened
			processing[num-1] = false;
		}
	}
	
	// To open the menu set the specific flag
	function setMenu(num)
	{
		menu[num-1]= true;	
	}
		
	
	// To close the menu reset the specific flag
	function resetMenu(num)
	{
		menu[num-1]= false;
	}
	
	// To open the mrnu
	function openMenu(num)
	{
	   // Set the processing flag to indicate that the menu is opening
		processing[num-1] = true;
		clearTimeout(tId[num-1]);
		
		openSubMenu(num);
	}
	function openSubMenu(num)
	{
		document.getElementById('menu'+num+'body').style.visibility = 'visible';
		
		 // Insert some delay while opening the menu, to create animation
		tOpenId[num-1] = setTimeout('down('+num+')',20);
	}
	
	function down(num)
	{
        // Check full sub menu is opened or not
		if(indx[num-1] >= 180)
		{
		    // Full sub menu is opened
			indx[num-1]=180;
			
			// Reset the processing flag to indicate that the full menu is opened
			processing[num-1] = false;
			return;
		}
		else
		{	
            // Increase the div top to close the menu
			indx[num-1]=indx[num-1]+1;
			document.getElementById('menu'+num+'body').style.top=(indx[num-1]+41)+'px';
			openSubMenu(num);
		}
		
	}
	
	// To close the menu
	function closeMenu(num)
	{	
		clearTimeout( tOpenId[num-1]);

		// Close the opend sub menu
		closeSubMenu(num);	
		
	}
	
	
	function closeSubMenu(num)
	{	
        // Insert some delay while closing the menu, to create animation
		tId[num-1] = setTimeout('shrink('+num+')',20);
	}
	
	
	function shrink(num)
	{
	   
		if(indx[num-1]<=1)
		{
            // Stop shrinking since the menu is not visible now
			indx[num-1]=1;
			return;
		}
		else
		{
            // Decrease the div top to close the menu
			indx[num-1]=indx[num-1]-1;
			document.getElementById('menu'+num+'body').style.top=(41+indx[num-1])+'px';
			
			closeSubMenu(num);
		}
	}
	function menuAnimation()
	{
			
			for(i=0;i<4;i++)
			{
                // If menu is set
				if(menu[i]==true)
				{
				    // Open the specific menu
					openMenu(i+1);
				}
				else
				{   
				    // If open menu is called then do not call close menu until whole sub menu is dispalyed
                    // To create syncronization processing[i] flag is used				    
					if( processing[i] == false)
					{
                        // Close the specific menu
						closeMenu(i+1);
					}
				}
			}		
	}
	
	setInterval('menuAnimation()',1);
