function Document_Click(e)
{
	if (!e) var obj = window.event.srcElement;
	else var obj = e.target;
	while (obj.nodeType != 1)
	{
		obj = obj.parentNode;
	}
	if (obj.tagName == 'DIV') return;
	
	if(typeof g_oMenu != 'undefined' && g_oMenu)
	{
		g_oMenu.style.display = "none"
		g_oMenu = null;
		document.onclick = null;
	}
	else return;
}

function HideMenu(div)
{
	if(typeof g_oMenu != 'undefined' && g_oMenu && (div.id != g_oMenu.id))
	{
		g_oMenu.style.display = "none"
		g_oMenu = null;
		document.onclick = null;
	}
	else return;
}

function switchdiv(div_1, div_2)
{
	if (document.getElementById)	{
	    if(!document.getElementById(div_1)) return ;
	    if(!(document.getElementById(div_1).style)) return ;
	    if(!(document.getElementById(div_1).style.display)) return ;

		var state_1 = document.getElementById(div_1).style.display;
		if(state_1=="none") {
        		document.getElementById(div_1).style.display="block";
        		document.getElementById(div_2).style.display="none";
	     }
	    if(state_1=="block") {
        		document.getElementById(div_2).style.display="block";
        		document.getElementById(div_1).style.display="none";
	     }
	}
	else if (document.all)	{
	    if(!document.all[div_1]) return ;
	    if(!(document.all[div_1].style)) return ;
	    if(!(document.all[div_1].style.display)) return ;

		var state_1 = document.all[div_1].style.display;
		if(state_1=="none") {
		        document.all[div_1].style.display = "block";
		        document.all[div_2].style.display = "none";
		}
		if(state_1=="block") {
        		document.getElementById(div_1).style.display="none";
        		document.getElementById(div_2).style.display="block";
	     }
    }
}

function showhide()
{
	var nArguments = arguments.length;
	
	function __showhide_one_argument(div)
	{
		HideMenu(document.getElementById(div));
		state = document.getElementById(div).style.display;
		g_oMenu = document.getElementById(div);
		
		if(state == "none")
		{
			g_oMenu.style.display="block";
			g_oMenu.style.visibility = 'visible';
			g_oMenu = document.getElementById(div);
			setTimeout("document.onclick = Document_Click",100);
		}
		else
		{
			g_oMenu.style.display="none";
			g_oMenu.style.visibility = 'visible';
			g_oMenu = null;
		}
		g_oMenu = document.getElementById(div);
		
	}
	
	function __showhide_two_arguments(div,ensurevis)
	{
//		HideMenu(document.getElementById(div));
		state = document.getElementById(div).style.display;
		g_oMenu = document.getElementById(div);
		
		if(state == "none") { g_oMenu.style.display="block";}
		else { g_oMenu.style.display = "none";}
		g_oMenu.style.visibility = 'visible';
	}
		
	if(nArguments == 1) return __showhide_one_argument(arguments[0]);
	else if(nArguments == 2) return __showhide_two_arguments(arguments[0],arguments[1]);
	else return false;
}

// Multiple combo functions =============================

function moveUpList(listField)
{
	if ( listField.length == -1) {  // If the list is empty
	  alert("There are no values which can be moved!");
	} else {
	  var selected = listField.selectedIndex;
	  if (selected == -1) {
	     alert("You must select an entry to be moved!");
	  } else {  // Something is selected
	     if ( listField.length == 0 ) {  // If there's only one in the list
	        alert("There is only one entry!\nThe one entry will remain in place.");
	     } else {  // There's more than one in the list, rearrange the list order
	        if ( selected == 0 ) {
	           alert("The first entry in the list cannot be moved up.");
	        } else {
	           // Get the text/value of the one directly above the hightlighted entry as
	           // well as the highlighted entry; then flip them
	           var moveText1 = listField[selected-1].text;
	           var moveText2 = listField[selected].text;
	           var moveValue1 = listField[selected-1].value;
	           var moveValue2 = listField[selected].value;
	           listField[selected].text = moveText1;
	           listField[selected].value = moveValue1;
	           listField[selected-1].text = moveText2;
	           listField[selected-1].value = moveValue2;
	           listField.selectedIndex = selected-1; // Select the one that was selected before
	        }  // Ends the check for selecting one which can be moved
	     }  // Ends the check for there only being one in the list to begin with
	  }  // Ends the check for there being something selected
	}  // Ends the check for there being none in the list
}

//Hopefully the code makes sense. It is commented pretty well, so that should help. For moving down in the list, the code is quite similar:

function moveDownList(listField)
{
	if ( listField.length == -1) {  // If the list is empty
	  alert("There are no values which can be moved!");
	} else {
	  var selected = listField.selectedIndex;
	  if (selected == -1) {
	     alert("You must select an entry to be moved!");
	  } else {  // Something is selected
	     if ( listField.length == 0 ) {  // If there's only one in the list
	        alert("There is only one entry!\nThe one entry will remain in place.");
	     } else {  // There's more than one in the list, rearrange the list order
	        if ( selected == listField.length-1 ) {
	           alert("The last entry in the list cannot be moved down.");
	        } else {
	           // Get the text/value of the one directly below the hightlighted entry as
	           // well as the highlighted entry; then flip them
	           var moveText1 = listField[selected+1].text;
	           var moveText2 = listField[selected].text;
	           var moveValue1 = listField[selected+1].value;
	           var moveValue2 = listField[selected].value;
	           listField[selected].text = moveText1;
	           listField[selected].value = moveValue1;
	           listField[selected+1].text = moveText2;
	           listField[selected+1].value = moveValue2;
	           listField.selectedIndex = selected+1; // Select the one that was selected before
	        }  // Ends the check for selecting one which can be moved
	     }  // Ends the check for there only being one in the list to begin with
	  }  // Ends the check for there being something selected
	}  // Ends the check for there being none in the list
}

function allSelect(el)
{
	for (i=0;i<el.length;i++) el.options[i].selected = true;
}

// End Multiple combo fncs

function SwichImgs(img,src)
{
	document.getElementById(img).src = src;
}
