﻿var dropdownVisible = 2;

function addProductDropdownEvents()
{
	if (product_div != null)
	{
		if (window.addEventListener)
		{
			product_div.addEventListener('mouseover', handleMouseOver, true);
			product_div.addEventListener('mouseout', handleMouseOut, true);
		}	   
		if (window.attachEvent)
		{
			product_div.attachEvent('onmouseover', handleMouseOver);
			product_div.attachEvent('onmouseout', handleMouseOut);
		}
	}

	var product_dropdown = document.getElementById("productDropdown");
	if (product_dropdown != null)
	{
		if (window.addEventListener)
		{
			product_dropdown.addEventListener('mouseover', handleMouseOver, true);
			product_dropdown.addEventListener('mouseout', handleMouseOut, true);
		}	   
		if (window.attachEvent)
		{
			product_dropdown.attachEvent('onmouseover', handleMouseOver);
			product_dropdown.attachEvent('onmouseout', handleMouseOut);
		}
	}
}

function handleMouseOver(e)
{
    dropdownVisible = 2;
    var product_dropdown = document.getElementById("productDropdown");
    product_dropdown.style.display = "block";
    product_div.className = "products_on";
    hideIE6DropDowns(true);
}

function handleMouseOut(e)
{
	dropdownVisible = 1;
    var product_dropdown = document.getElementById("productDropdown");
    product_dropdown.style.display = "none";
    product_div.className = "products_off";
    changeContent('mouseout');
    hideIE6DropDowns(false);
    setTimeout( setDefaultView, 1000 );
}

function changeContent(whichcontent){
	if(whichcontent=='mouseout')
	{
//################ need to set a delay to reset to default after a period of time #####################
//		if (document.all||document.getElementById){
//			cross_el = document.getElementById ? document.getElementById("screenshots") : document.all.screenshots;
//			cross_el.innerHTML='';
//			cross_el = document.getElementById ? document.getElementById("descriptions") : document.all.descriptions;
//			cross_el.innerHTML='';
//		}			
//		if(document.getElementById("productDropdownDefault"))
//			document.getElementById("productDropdownDefault").style.display="block";		
	}
	else
	{
		if(document.getElementById("productDropdownDefault"))
			document.getElementById("productDropdownDefault").style.display="none";

		if(document.getElementById("productDropdownProductView"))
			if(document.getElementById("productDropdownProductView").style.display="none")
				document.getElementById("productDropdownProductView").style.display="inline";
		
		if(document.getElementById("productDropdownScreenshot"))
			if(document.getElementById("productDropdownScreenshot").style.display="none")
				document.getElementById("productDropdownScreenshot").style.display="inline";
		
			
		if (document.all||document.getElementById){
			cross_el = document.getElementById ? document.getElementById("screenshots") : document.all.screenshots;
			cross_el.innerHTML=whichcontent;
		}
	}
}

function changeDesc(whichdesc){
	if (document.all||document.getElementById){
	    cross_el = document.getElementById ? document.getElementById("descriptions") : document.all.descriptions;
	    cross_el.innerHTML=whichdesc;
	}
	else if (document.layers){
	    document.d3.document.d4.document.write(whichdesc);
	    document.d3.document.d4.document.close();
	}
}

function changeLogo(whichdesc){
	if (document.all||document.getElementById){
	    cross_el = document.getElementById ? document.getElementById("logos") : document.all.descriptions;
	    cross_el.innerHTML=whichdesc;
	}
}

//IE6 hack : <select/> elements always stay on top regardless of styling
function hideIE6DropDowns( hide ) {
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6") >= 0 ) {
		var spanElements = document.getElementsByTagName( "span" );
		for (var i in spanElements) {
			if ( spanElements[i].className == "productsDDHide" ) spanElements[i].style.visibility = ( hide ) ? "hidden" : "inherit";
		}
	}
}

function setDefaultView(){
	if (dropdownVisible == 1)
	{
		if(document.getElementById("productDropdownDefault"))
			document.getElementById("productDropdownDefault").style.display="inline";
		if(document.getElementById("productDropdownProductView"))
			document.getElementById("productDropdownProductView").style.display="none";
		if(document.getElementById("productDropdownScreenshot"))
			document.getElementById("productDropdownScreenshot").style.display="none";				
	}
} 
