
// *** Library constants (MS-10.03.02) ***

var MSIE = "Microsoft Internet Explorer";
var NETSCAPE = "Netscape";

// *** A function to determine if browser is IE version 4 or above (MS-10.03.02) ***

function isIE4plus()
{
	var rc = false;

	if((navigator.appName == MSIE) && (parseInt(navigator.appVersion) >= 4))
	{
		rc = true;
	}
	return rc;
}

// *** A function to determine if browser is Netscape (MS-10.03.02) ***

function isNetscape()
{
	var rc = false;

	if(navigator.appName == NETSCAPE)
	{
		rc = true;
	}
	return rc;
}

// *** A function to add a favourite to your browser (MS-10.03.02) ***

function addFavourite(siteUrl, siteName)
{
	if(isIE4plus())
	{
		window.external.AddFavorite(siteUrl, siteName);
	}
	else if(isNetscape)
	{
		var msg = "To bookmark this site on Nescape press Ctrl and D";
	}
}


// *** A function to navigate to another URL (MS-11.09.07) ***


function navigateTo(siteUrl)
{
	window.location=siteUrl;
}


// ***  A function to populate a linked combobox (MS-12.12.05) ***

function fillCombo(driverComboName,linkedComboName,contentArray,selectedValue)
{
	var driverComboObj=document.getElementById(driverComboName);
	var linkedComboObj=document.getElementById(linkedComboName);

	linkedComboObj.options.length = 0;

	for(i=0;i<contentArray[driverComboObj.selectedIndex].length;i++)
	{
		var linkedComboKey = contentArray[driverComboObj.selectedIndex][i].key;
		var linkedComboText = contentArray[driverComboObj.selectedIndex][i].desc;

		linkedComboObj.options[i] = new Option(linkedComboText);
		linkedComboObj.options[i].value = linkedComboKey;

		if(	(selectedValue != null) && (linkedComboKey == selectedValue) )
		{
			linkedComboObj.options[i].selected = true;
		}
	}
}


// ***  A present a default image when the candidate image is wrong size (MS-21.10.07) ***

function getCorrectSizedImage(candidateImgName,exactWidth,exactHeight,defaultImgName,altTxt,imgClass)
{
	var imgName = defaultImgName

	var img = new Image(); 

	img.src = candidateImgName;

	if( (img.width == exactWidth) && (img.height == exactHeight) )
	{
		imgName = candidateImgName;
	}

	if( imgName != "" )
	{
		document.write("<img src='"+imgName+"' alt='"+altTxt+"' class='"+imgClass+"'/>");
	}
}


// ***  A present a default image when the candidate image is too big (MS-21.10.07) ***

function getRestrictedSizedImage(candidateImgName,maxWidth,maxHeight,defaultImgName,altTxt,imgClass)
{
	var img = new Image(); 

	img.src = candidateImgName;

	var imgName = null;

	if( (img.width == 0) || (img.height == 0) || (img.width > maxWidth) || (img.height > maxHeight) )
	{
		imgName = defaultImgName;
	}
	else
	{
		imgName = candidateImgName;
	}

	if( imgName != "" )
	{
		document.write("<img src='"+imgName+"' alt='"+altTxt+"' class='"+imgClass+"'/>");
	}
}


// *** A function to load a page on a user confirm (MS-26.01.09) ***

function loadPageOnUserOK(confirmMessage,thePage)
{
	if(confirm(confirmMessage))
	{
		window.location.href = thePage;
	}
}


// *** A function to open a page in a pop-up window (MS-12.07.09) ***

function openPopUp(url)
{
	window.open(url,'thewindow','toolbar=no, width=650, height=500, status=no, scrollbars=yes, resize=no, menubar=no');
}


// *** A function to sybmit a form on the when carriageway return in pressed (MS-02.04.10) ***

function submitFormOnReturn(formId)
{
	if(event.keyCode == 13)
	{
		form = document.getElementById(formId);

		form.submit();
	}
}
