// Author:		Thomas Powell
// Date:		19 Dec 2007
// Purpose:		JavaScript for the My Computer page
//
// Change History:
// Date			Author			Comments
// 21-01-2008	Thomas Powell	Added more search box functions.

function SearchBoxInstructions()
{
	// Add instructions if empty
	if (document.serialsearch.serialno.value == "")
	{
		document.serialsearch.serialno.className = "mycomputer_searchinput searchbox_background_on"
	}
}

function ClearSearchBox()
{
	// Remove instructions
	document.serialsearch.serialno.className = "mycomputer_searchinput searchbox_background_off"
}

window.onload = function ClearSearchBoxOnBack()
{
	// Remove instructions if not empty
	if (document.serialsearch.serialno.value != "")
	{
		document.serialsearch.serialno.className = "mycomputer_searchinput searchbox_background_off"
	}
}

function SubmitOnEnterKey(oEvent) 
{ 	
	// Get the keypress
	numCode = oEvent.which||oEvent.keyCode;

	// If it's 'Enter' then submit the search
	if (numCode == 13)
	{
		SubmitSearch();
		return false;
	}
	
	return true;
}

function SubmitSearch()
{
	// Submit serial number after testing one has been entered
	if (document.serialsearch.serialno.value == "" || document.serialsearch.serialno.value == "Enter serial number")
	{
		alert('Please enter a serial number to search for');
	}
	else
	{
		document.serialsearch.submit();
	} 
}

function ToggleExpansion( pstrSectionID )
{
	// Switch view of sections from expanded to collapsed and vice versa
	var strElement = pstrSectionID + "_collapsed";
	var strOtherElement = pstrSectionID + "_expanded";
	var oElement = document.getElementById(strElement);
	var oOtherElement = document.getElementById(strOtherElement);
	
	if (oElement.style.display == "none")
	{
		oElement.style.display = "block";
		oOtherElement.style.display = "none";
	}
	else
	{
		oElement.style.display = "none";
		oOtherElement.style.display = "block";
	} 
}
