﻿
    	var _timeoutFunctionID;
    	var _mouseEntered;
    	var _inInitialized;
    	var _outTimeoutID;
    	var _cacheDomain;

    	function setCacheDomain(cacheDomain)
    	{
    		_cacheDomain = cacheDomain;    		
    	}
        
        function hideDetailsDivs() 
        {
            var divInitialText = document.getElementById('divInitialText');
            var divBroadcast = document.getElementById('divBroadcast');
            var divInventory = document.getElementById('divInventory');
            var divShowroom = document.getElementById('divShowroom');
            var divClassifieds = document.getElementById('divClassifieds');

            divInitialText.style.display = "none";
            divBroadcast.style.display = "none";
            divInventory.style.display = "none";
            divShowroom.style.display = "none";
            divClassifieds.style.display = "none";
        }
        
        function setDefaultMenuPictures()
        {
            var imgBroadcast = document.getElementById('imgBroadcast');
            var imgInventory = document.getElementById('imgInventory');
            var imgShowroom = document.getElementById('imgShowroom');
            var imgClassifields = document.getElementById('imgClassifieds');

            if (_cacheDomain)
            {            	
            	if (_cacheDomain.length > 0 && _cacheDomain[_cacheDomain.length - 1] != "/")
            	{
            		_cacheDomain = _cacheDomain + "/";
            	}
            }
            else
            {
            	_cacheDomain = "http://www.ittradeonline.com";
            }            

            imgBroadcast.src = _cacheDomain + "Themes/ITTO/Images/broadcast.png";
            imgInventory.src = _cacheDomain + "Themes/ITTO/Images/inventory.png";
            imgShowroom.src = _cacheDomain + "Themes/ITTO/Images/showroom.png";
            imgClassifields.src = _cacheDomain + "Themes/ITTO/Images/classifields.png";
        }

        function setSelectedMenuItem(option)
        {        	
        	_inInitialized = false;
        	
        	setDefaultMenuPictures();
        	hideDetailsDivs();

        	switch (option)
        	{
        		case "Broadcast":
        			{

        				document.getElementById('imgBroadcast').src = _cacheDomain + "Themes/ITTO/Images/broadcast-selected.png";
        				document.getElementById('divBroadcast').style.display = "";
        			} 
        			break;

        		case "Inventory":
        			{

        				document.getElementById('imgInventory').src = _cacheDomain + "Themes/ITTO/Images/inventory-selected.png";
        				document.getElementById('divInventory').style.display = "";
        			} 
        			break;

        		case "Showroom":
        			{

        				document.getElementById('imgShowroom').src = _cacheDomain + "Themes/ITTO/Images/showroom-selected.png";
        				document.getElementById('divShowroom').style.display = "";
        			} 
        			break;

        		case "Classifieds":
        			{

        				document.getElementById('imgClassifieds').src = _cacheDomain + "Themes/ITTO/Images/classifields-selected.png";
        				document.getElementById('divClassifieds').style.display = "";
        			} 
        			break;

        		default:
        			{
        				document.getElementById('imgBroadcast').src = _cacheDomain + "Themes/ITTO/Images/broadcast-selected.png";
        				document.getElementById('divBroadcast').style.display = "";
        			} 
        			break;
        	}
        }

        function initiateOption(option)
        {
        	_inInitialized = true;
        	if (_timeoutFunctionID)
        	{
        		window.clearTimeout(_timeoutFunctionID);
        	}

        	if (_outTimeoutID)
        	{
        		window.clearTimeout(_outTimeoutID);
        	}
        	
			_timeoutFunctionID = window.setTimeout("setSelectedMenuItem('" + option + "')", 0);
		}

		function initiateOut(reset)
		{
			if (_mouseEntered)
			{
				_mouseEntered = false;
				
				return;
			}

			if (_inInitialized)
			{
				return;
			}

			if (reset)
			{
				setDefaultMenuPictures();

				hideDetailsDivs();

				document.getElementById('divInitialText').style.display = "";
				
				window.clearTimeout(_timeoutFunctionID);
			}
			else
			{
				_outTimeoutID = setTimeout('initiateOut(true)', 300);
			}
		}

		function setTextContainerEvents(containerID)
		{
			var container = document.getElementById(containerID);

			container.onmouseover = function(ev)
			{
				_mouseEntered = true;
			};

			container.onmouseout = function(ev)
			{
				initiateOut();
			};
		}            
