function SwapIMG(imageName, image, imagePath)
{
	if (image.src == '')
	{
		image.src = imagePath;
	}
	document.images[imageName].src = image.src;
}

function winPop(pageToLoad, winName, width, height, center, scroll, control)
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=" + control + ","
    + "scrollbars="+scroll+", "
    + "status=1,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open(pageToLoad,winName,args );
}

function winPopFull(pageToLoad, winName, width, height, center, scroll, control)
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=1,"
    + "menubar=1,"
    + "resizable=" + control + ","
    + "scrollbars="+scroll+", "
    + "status=1,"
    + "titlebar=1,"
    + "toolbar=1,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open(pageToLoad,winName,args );
}

var arrNews	= new Array();
var iCurrentNewsStory = 0;
var iCurrentChar = 0;
var iDelay = 0;
var oDiv = null;

function OutputNews()
{
	oDiv = document.getElementById("news");
	revealNews();
}

function revealNews(pDiv)
{
	iDelay = 50;
	var sText = arrNews[iCurrentNewsStory][0];
	var sLinkID = arrNews[iCurrentNewsStory][1];
	var sPage = arrNews[iCurrentNewsStory][2];
	var sHTML = '<a href="' + sPage + '?id=' + sLinkID + '" title="' + sText + '"><span class="title">NEWS &gt;</span> ' + sText.substr(0, iCurrentChar) + "</a>";
	oDiv.innerHTML = sHTML;
	
	iCurrentChar++;
	
	if (iCurrentChar > (sText.length + 3))
	{
		iCurrentNewsStory++;
		iDelay = 2000;
		iCurrentChar = 0;
	}
	
	if (iCurrentNewsStory >= arrNews.length)
	{
		iCurrentNewsStory = 0;	
	}
	
	setTimeout('revealNews()', iDelay);
}

function switchPattern(pPattern)
{
	
	switch (pPattern)
	{
		case "weave":
			document.getElementsByTagName("body")[0].style.background = 'url(images/background.gif)';
			break;
		case "circles":
			document.getElementsByTagName("body")[0].style.background = 'url(images/background_circle.gif)';
			break;
		case "bricks":
			document.getElementsByTagName("body")[0].style.background = 'url(images/background_bricks.gif)';
			break;			
	}
}

function switchColour(pColour)
{
	switch (pColour)
	{
		case "grey":
			document.getElementById("mainblock").style.background = 'url(images/background_main_block.png)';
			break;
		case "red":
			document.getElementById("mainblock").style.background = 'url(images/background_main_block_red.png)';
			break;
		case "blue":
			document.getElementById("mainblock").style.background = 'url(images/background_main_block_blue.png)';
			break;
		case "green":
			document.getElementById("mainblock").style.background = 'url(images/background_main_block_green.png)';
			break;
	}
}

function NumberOfChar(str,char)
{
	var ii, charCount;
	charCount = 0;
	for (ii=0; ii < str.length;ii++)
	{
		var cc = str.charAt(ii);
		if (cc == char)
		{
			charCount = charCount + 1;
		}
	}
	return charCount;
}

function validEmail(str)
{
	var bool;
	bool = true;
	if (str.length < 6)
	{
		bool = false;
		alert("The email address has too few characters.");
	}
	if ((bool) && ((NumberOfChar(str,'@')==0)||(NumberOfChar(str,'@')>1)))
	{
		bool = false;
		alert("The email address contains the wrong number of @'s.");
	}
	if ((bool) && (NumberOfChar(str,'.')==0))
	{
		bool = false;
		alert("The email address must contain at least one '.'.");
	}
	if ((bool) && (NumberOfChar(str,' ')!=0))
	{
		bool = false;
		alert("The email address must not contain any spaces.");
	}
	return bool;
}

function validateContactForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Name.value == ''))
	{
		alert('You must enter your Name');
		bValid = false;	
	}

	if ((bValid) && (pForm.Email.value == ''))
	{
		alert('You must enter your Email Address');
		bValid = false;	
	}

	if (bValid)
	{
		bValid = validEmail(pForm.Email.value);	
	}	

	if ((bValid) && (pForm.Enquiry.value == ''))
	{
		alert('You must enter your Enquiry Address');
		bValid = false;	
	}
	
	return bValid;	
}

function validateCommentForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.ArticleID.value == ''))
	{
		alert('You must select an article to comment on');
		pForm.ArticleID.focus();
		pForm.ArticleID.className = 'errortext';
		bValid = false;
	}

	if ((bValid) && (pForm.CreatedByName.value == ''))
	{
		alert('You must enter Your Name when commenting on an article');
		pForm.CreatedByName.focus();
		pForm.CreatedByName.className = 'errortext';
		bValid = false;
	}

	if ((bValid) && (pForm.Content.value == ''))
	{
		alert('You must enter Your Comment when commenting on an article');
		pForm.Content.focus();
		pForm.Content.className = 'errortext';
		bValid = false;
	}
	
	return bValid;		
}

function validateArticleForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.ArticleTitle.value == ''))
	{
		alert('You must enter an Article Title');
		pForm.ArticleTitle.focus();
		pForm.ArticleTitle.className = 'errortext';
		bValid = false;
	}

	if ((bValid) && (pForm.Content.value == ''))
	{
		alert('You must enter the Article Content');
		pForm.Content.focus();
		pForm.Content.className = 'errortext';
		bValid = false;
	}

	if ((bValid) && (pForm.ArticleDate.value == ''))
	{
		alert('You must enter the Article Date');
		pForm.Content.focus();
		pForm.Content.className = 'errortext';
		bValid = false;
	}	
	
	return bValid;		
}

function Left(pString, pLength)
{
	if (pLength <= 0)
	{
	    return "";
	}
	else if (pLength > String(pString).length)
	{
	    return pString;
	}
	else
	{
	    return String(pString).substring(0,pLength);
	}
}

function Right(pString, pLength)
{
    if (pLength <= 0)
    {
		return "";
	}
    else if (pLength > String(pString).length)
    {
    	return pString;
    }
    else 
    {
       var iStringLength = String(pString).length;
       return String(pString).substring(iStringLength, iStringLength - pLength);
    }
}

function resetSearchFields()
{
	var oForm = document.getElementById('searchform');
	for (var ii=0; ii < oForm.elements.length; ii++)
	{
		if ((oForm.elements[ii].name != 'OrganisationIDHIDE') &&
			(oForm.elements[ii].name != 'SearchSubmitted') &&
			(oForm.elements[ii].name != 'Search') &&
			(oForm.elements[ii].name != 'Reset'))
		{
			document.getElementById('searchform').elements[ii].value = '';
		}
	}
}

var bPassphraseIsStrong = false;

function checkPassphraseStrength(pPhrase)
{
	if ((checkLength(pPhrase)) &&
		(checkForCapitals(pPhrase)) &&
		(checkForLowerCase(pPhrase)) &&
		(checkForSpace(pPhrase)) &&
		(checkForSpecialCharacters(pPhrase)))
	{
		document.getElementById('passphrasefeedback').innerHTML = '<img src="images/icon_success.gif" alt="Passphrase is STRONG"><p class="greentxt">Passphrase is STRONG</p>';		
		bPassphraseIsStrong = true;
	}
	else
	{
		document.getElementById('passphrasefeedback').innerHTML = '<img src="images/icon_failed.gif" alt="Passphrase NOT STRONG"><p class="redtxt">Passphrase NOT STRONG</p>';
		bPassphraseIsStrong = false;
	}
}

function checkLength(pPhrase)
{
	if ((pPhrase.length >= 7) &&
		(pPhrase.length <= 50))
		return true;
	else
		return false;
}

function checkForCapitals(pPhrase)
{
	var myRegExp = '[A-Z]';
	var matchPos1 = pPhrase.search(myRegExp);
		
	if (matchPos1 != -1)
		return true;
	else
		return false;
}

function checkForLowerCase(pPhrase)
{
	var myRegExp = '[a-z]';
	var matchPos1 = pPhrase.search(myRegExp);
		
	if (matchPos1 != -1)
		return true;
	else
		return false;
}

function checkForSpace(pPhrase)
{
	var myRegExp = ' .';
	var matchPos1 = pPhrase.search(myRegExp);
		
	if (matchPos1 != -1)
		return true;
	else
		return false;
}

function checkForSpecialCharacters(pPhrase)
{
	var myRegExp = '[0123456789!\£$%^\&*()@~\{\}_+-=#<>\;]';
	var matchPos1 = pPhrase.search(myRegExp);
		
	if (matchPos1 != -1)
		return true;
	else
		return false;
}

function alertNoProducts()
{

}

function validateCodeBatchEntry(pForm)
{
	var bValid = true;
	
	if ((bValid) && (pForm['TotalProductCount'].value == '0'))
	{
		if ((pForm['ProductCode|1'].value == '') &&
			(pForm['Strength|1'].value == '') &&
			(pForm['Packsize|1'].value == '') &&
			(pForm['Formulation|1'].value == ''))
		{ 
			alert('You must enter at least one Product Code');
			return false;			
		}
		else if ((pForm['ProductCode|1'].value != '') &&
			(pForm['Strength|1'].value != '') &&
			(pForm['Packsize|1'].value != '') &&
			(pForm['Formulation|1'].value != ''))
		{}
		else
		{
			alert('You must complete a full row in order to submit a new code.');
			bValid = false;		
		}
	}
	else
	{
		if ((pForm['ProductCode|1'].value == '') &&
			(pForm['Strength|1'].value == '') &&
			(pForm['Packsize|1'].value == '') &&
			(pForm['Formulation|1'].value == ''))
		{ }
		else if ((pForm['ProductCode|1'].value != '') &&
			(pForm['Strength|1'].value != '') &&
			(pForm['Packsize|1'].value != '') &&
			(pForm['Formulation|1'].value != ''))
		{}
		else
		{
			alert('You must complete a full row in order to submit a new code.');
			bValid = false;			
		}	
	}
	
	return bValid;
}

function validateProductName(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.ProductName.value == ''))
	{
		alert('You must enter a Product Name to continue');
		bValid = false;
	}	
	
	return bValid;
}

function validateUser(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Organisation.value == ''))
	{
		alert('You must select an Organisation to continue');
		bValid = false;
	}	

	if ((bValid) && (pForm.UserType.value == ''))
	{
		alert('You must select an User Type to continue');
		bValid = false;
	}		

	if ((bValid) && (pForm.Username.value == ''))
	{
		alert('You must enter a Username to continue');
		bValid = false;
	}		

	if ((bValid) && (pForm.FirstName.value == ''))
	{
		alert('You must enter a First Name to continue');
		bValid = false;
	}			

	if ((bValid) && (pForm.Surname.value == ''))
	{
		alert('You must enter a Surname to continue');
		bValid = false;
	}		

	if ((bValid) && (pForm.Email.value == ''))
	{
		alert('You must enter a First Name to continue');
		bValid = false;
	}		
	else if (bValid)
	{
		bValid = validEmail(pForm.Email.value);
	}
	
	return bValid;
}

function validateOrganisation(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.OrganisationTitle.value == ''))
	{
		alert('You must enter an Organisation Title to continue');
		bValid = false;
	}	

	if ((bValid) && (pForm.Country.value == ''))
	{
		alert('You must select a Country to continue');
		bValid = false;
	}		
	
	var iRowCount = document.getElementById('ContactCount').value;

	for (var ii = 1; ii <= iRowCount; ii++)
	{
		if ((pForm['FirstName|' + ii.toString()].value == '') &&
			(pForm['Surname|' + ii.toString()].value == '') &&
			(pForm['Email|' + ii.toString()].value == ''))
		{ }
		else if ((pForm['FirstName|' + ii.toString()].value != '') &&
			(pForm['Surname|' + ii.toString()].value != '') &&
			(pForm['Email|' + ii.toString()].value != ''))
		{ 
			bValid = validEmail(pForm['Email|' + ii.toString()].value);
		}
		else
		{
			alert('You must complete a full row in order to add a new contact.');
			bValid = false;			
		}
	}
	
	return bValid;
}

function validateCountry(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.CountryName.value == ''))
	{
		alert('You must enter a Country Name to continue');
		bValid = false;
	}	

	if ((bValid) && (pForm.CountryCode.value == ''))
	{
		alert('You must enter a Country Code to continue');
		bValid = false;
	}	
	
	var iRowCount = document.getElementById('LanguageCount').value;

	for (var ii = 1; ii <= iRowCount; ii++)
	{
		if ((pForm['LanguageTitle|' + ii.toString()].value == '') &&
			(pForm['LanguageCode|' + ii.toString()].value == ''))
		{ }
		else if ((pForm['LanguageTitle|' + ii.toString()].value != '') &&
			(pForm['LanguageCode|' + ii.toString()].value != ''))
		{ }
		else
		{
			alert('You must complete a full row in order to add a new language.');
			bValid = false;			
		}
	}
	
	return bValid;
}

function validateProductEntry(pForm)
{
	var bValid = true;

	if (pForm.Validate.value == 'TRUE')
	{
		if ((bValid) && (pForm.ProductName.value == ''))
		{
			alert('You must enter a Product Name to continue');
			bValid = false;
		}	

		var iRowCount = document.getElementById('ProductCount').value;

		for (var ii = 1; ii <= iRowCount; ii++)
		{
			if ((pForm['ProductCode|' + ii.toString()].value == '') &&
				(pForm['Strength|' + ii.toString()].value == '') &&
				(pForm['Packsize|' + ii.toString()].value == '') &&
				(pForm['Formulation|' + ii.toString()].value == ''))
			{ }
			else if ((pForm['ProductCode|' + ii.toString()].value != '') &&
				(pForm['Strength|' + ii.toString()].value != '') &&
				(pForm['Packsize|' + ii.toString()].value != '') &&
				(pForm['Formulation|' + ii.toString()].value != ''))
			{}
			else
			{
				alert('You must complete a full row in order to submit a new code.');
				bValid = false;			
			}
		}
	}
	
	return bValid;
}

function validateReason(pForm)
{
	var bValid = true;
	
	if ((bValid) && (pForm.RecallReason.value == ''))
	{
		alert('You must enter a Reason');
		bValid = false;
	}	
	
	if ((bValid) && (pForm.RecallAction.value == ''))
	{
		alert('You must enter an Action');
		bValid = false;
	}	
	
	if ((bValid) && (pForm.ReturnDate.value != ''))
	{
		var myRegExp = '(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/(19|20)[0-9]{2}';
		var matchPos1 = pForm.ReturnDate.value.search(myRegExp);

		if (matchPos1 == -1)
		{
			alert('Your Return Date is not in the correct format.\n\nDates must be in dd/mm/yyyy format.');
			bValid = false;			
		}
	}
	
	if ((bValid) && (pForm.ReturnDate.value != ''))
	{
		var dtNow = new Date();

		var sDay = pForm.ReturnDate.value.split("/")[0];
		var sMonth = pForm.ReturnDate.value.split("/")[1];
		var sYear = pForm.ReturnDate.value.split("/")[2];	
		var dtReturnDate = new Date();

		if (sDay.substr(0,1) == "0") sDay = sDay.substr(1);
		if (sMonth.substr(0,1) == "0") sMonth = sMonth.substr(1);

		dtReturnDate.setFullYear(parseInt(sYear),(parseInt(sMonth) - 1),parseInt(sDay));				

		if (dtReturnDate < dtNow)
		{
			alert('The Return Date cannot be in the past.');
			bValid = false;
		}
	}	
	
	
	if ((bValid) && (pForm.IssuedBy.value == ''))
	{
		alert('You must enter who the recall has been Issued By');
		bValid = false;
	}		
	
	return bValid
}

function validateRecallType(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.RecallLevelID.value == ''))
	{
		alert('You must select a Recall Level');
		bValid = false;
	}	

	return bValid;
}

function validateRecallContent(pForm)
{
	var bValid = true;

	if ((bValid) && ((pForm.ContentEN.value == '') || (pForm.ContentEN.value == '<br>')))
	{
		alert('You must enter at least an English Translation of the message');
		bValid = false;
	}		

	if ((bValid) && (removeHTMLTags(pForm.ContentEN.value).length > 500))
	{
		alert('There is a 500 character limit on the message');
		bValid = false;
	}		

	var iCount = document.getElementById('TranslationCount').value;

	for (var ii = 1; ii <= iCount; ii++)
	{
		if ((bValid) && (pForm['Translation|' + ii.toString()].value != ''))
		{
			if (removeHTMLTags(pForm['Translation|' + ii.toString()].value).length > 500)
			{
				alert('There is a 500 character limit on each translation');
				bValid = false;
			}		
		}
	}	
	
	return bValid;
}

function validateMessageContent(pForm)
{
	syncTextarea();
	var bValid = true;
	
	if ((bValid) && (pForm.MessageTitle.value == ''))
	{
		alert('You must enter a Message Title');
		bValid = false;
	}	

	if ((bValid) && ((pForm.ContentEN.value == '') || (pForm.ContentEN.value == '<br>')))
	{
		alert('You must enter at least an English Translation of the message');
		bValid = false;
	}		

	if ((bValid) && (removeHTMLTags(pForm.ContentEN.value).length > 500))
	{
		alert('There is a 500 character limit on the message');
		bValid = false;
	}			

	var iCount = document.getElementById('TranslationCount').value;

	for (var ii = 1; ii <= iCount; ii++)
	{
		if ((bValid) && (pForm['Translation|' + ii.toString()].value != ''))
		{
			if (removeHTMLTags(pForm['Translation|' + ii.toString()].value).length > 500)
			{
				alert('There is a 500 character limit on each translation');
				bValid = false;
			}		
		}
	}	
	
	return bValid;
}

function validateMessageDates(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.StartDate.value == ''))
	{
		alert('You must select a Start Date');
		bValid = false;
	}

	if (bValid)
	{
		var myRegExp = '(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/(19|20)[0-9]{2}';
		var matchPos1 = pForm.StartDate.value.search(myRegExp);

		if (matchPos1 == -1)
		{
			alert('Your Start Date is not in the correct format.\n\nDates must be in dd/mm/yyyy format.');
			bValid = false;			
		}
	}
	
	if (bValid)
	{
		var dtNow = new Date();

		var sDay = pForm.StartDate.value.split("/")[0];
		var sMonth = pForm.StartDate.value.split("/")[1];
		var sYear = pForm.StartDate.value.split("/")[2];	
		var dtStartDate = new Date();

		if (sDay.substr(0,1) == "0") sDay = sDay.substr(1);
		if (sMonth.substr(0,1) == "0") sMonth = sMonth.substr(1);

		dtStartDate.setFullYear(parseInt(sYear),(parseInt(sMonth) - 1),parseInt(sDay));				

		if (dtStartDate < dtNow)
		{
			alert('The Start Date cannot be in the past.');
			bValid = false;
		}
	}

	if ((bValid) && (pForm.ExpiryDate.value == ''))
	{
		alert('You must select an Expiry Date');
		bValid = false;
	}			

	if (bValid)
	{
		var myRegExp = '(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/(19|20)[0-9]{2}';
		var matchPos1 = pForm.ExpiryDate.value.search(myRegExp);

		if (matchPos1 == -1)
		{
			alert('Your Expiry Date is not in the correct format.\n\nDates must be in dd/mm/yyyy format.');
			bValid = false;			
		}
	}
	
	if (bValid)
	{
		var dtStartDate = new Date(pForm.StartDate.value); 
		var dtExpiryDate = new Date(pForm.ExpiryDate.value); 
		
		var sStartDay = pForm.StartDate.value.split("/")[0];
		var sStartMonth = pForm.StartDate.value.split("/")[1];
		var sStartYear = pForm.StartDate.value.split("/")[2];	
		var dtStartDate = new Date();

		if (sStartDay.substr(0,1) == "0") sStartDay = sStartDay.substr(1);
		if (sStartMonth.substr(0,1) == "0") sStartMonth = sStartMonth.substr(1);

		dtStartDate.setFullYear(parseInt(sStartYear),(parseInt(sStartMonth) - 1),parseInt(sStartDay));				
		
		var sExpiryDay = pForm.ExpiryDate.value.split("/")[0];
		var sExpiryMonth = pForm.ExpiryDate.value.split("/")[1];
		var sExpiryYear = pForm.ExpiryDate.value.split("/")[2];	
		var dtExpiryDate = new Date();

		if (sExpiryDay.substr(0,1) == "0") sExpiryDay = sExpiryDay.substr(1);
		if (sExpiryMonth.substr(0,1) == "0") sExpiryMonth = sExpiryMonth.substr(1);

		dtExpiryDate.setFullYear(parseInt(sExpiryYear),(parseInt(sExpiryMonth) - 1),parseInt(sExpiryDay));			
		
		if (dtExpiryDate <= dtStartDate)
		{
			alert('The Expiry Date must be later than the Start Date.');
			bValid = false;
		}
	}
	return bValid;
}

function validateAuthoriser(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Authoriser.value == ''))
	{
		alert('You must select an Authoriser');
		bValid = false;
	}	

	return bValid;
}

function validateMessageType(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.MessageTypeID.value == ''))
	{
		alert('You must select a Message Type');
		bValid = false;
	}	

	return bValid;
}

function SetDefaultPageOptions(pUserType)
{
	SetDefaultPageOptions(pUserType,'')
}

function SetDefaultPageOptions(pUserType,pCurrentDefaultPage)
{
	var oSelect = document.getElementById("DefaultPage");

	oSelect.options.length = 0;
	var oOption = null;	
	var oOptionOld = null;  
	
	if (pUserType == "3") //Administrator
	{
		oOption = document.createElement('option');
		oOption.text = 'Countries';
		oOption.value = 'admin_countries.aspx';
		if (pCurrentDefaultPage == oOption.value) oOption.selected = true;
		try {
		  oSelect.add(oOption, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
		  oSelect.add(oOption); // IE only
		}
		
		oOption = document.createElement('option');	
		oOption.text = 'Organisations';
		oOption.value = 'admin_organisations.aspx';
		if (pCurrentDefaultPage == oOption.value) oOption.selected = true;
		try {
		  oSelect.add(oOption, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
		  oSelect.add(oOption); // IE only
		}
		
		oOption = document.createElement('option');	
		oOption.text = 'Users';
		oOption.value = 'admin_users.aspx';
		if (pCurrentDefaultPage == oOption.value) oOption.selected = true;
		try {
		  oSelect.add(oOption, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
		  oSelect.add(oOption); // IE only
		}		
	}
	else
	{
		oOption = document.createElement('option');	
		oOption.text = 'Message Centre';
		oOption.value = 'message_centre.aspx';
		if (pCurrentDefaultPage == oOption.value) oOption.selected = true;
		try {
		  oSelect.add(oOption, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
		  oSelect.add(oOption); // IE only
		}	
		
		oOption = document.createElement('option');	
		oOption.text = 'Recall Centre';
		oOption.value = 'recall_centre.aspx';
		if (pCurrentDefaultPage == oOption.value) oOption.selected = true;
		try {
		  oSelect.add(oOption, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
		  oSelect.add(oOption); // IE only
		}			
	}
}

function AddContactRow()
{
	var iRowCount = document.getElementById('ContactCount').value;
	iRowCount++;	
	
	var tblBody = document.getElementById('productinfo').tBodies[0];
	var newRow = tblBody.insertRow(-1);
	var newCell0 = newRow.insertCell(0);
	newCell0.innerHTML = '<input type="text" name="FirstName|' + iRowCount.toString() + '" value=""/></td>';
	var newCell1 = newRow.insertCell(1);
	newCell1.innerHTML = '<input type="text" name="Surname|' + iRowCount.toString() + '" value=""/></td>';
	var newCell2 = newRow.insertCell(2);
	newCell2.innerHTML = '<input type="text" name="Email|' + iRowCount.toString() + '" value=""/></td>';	
	
	document.getElementById('ContactCount').value = iRowCount;
}

function AddLanguageRow()
{
	var iRowCount = document.getElementById('LanguageCount').value;
	iRowCount++;	
	
	var tblBody = document.getElementById('productinfo').tBodies[0];
	var newRow = tblBody.insertRow(-1);
	var newCell0 = newRow.insertCell(0);
	newCell0.innerHTML = '<input type="text" name="LanguageTitle|' + iRowCount.toString() + '" value=""/></td>';
	var newCell1 = newRow.insertCell(1);
	newCell1.innerHTML = '<input type="text" name="LanguageCode|' + iRowCount.toString() + '" value=""/></td>';
	
	document.getElementById('LanguageCount').value = iRowCount;
}

function AddProductRow()
{
	var iRowCount = document.getElementById('ProductCount').value;
	iRowCount++;	
	
	var tblBody = document.getElementById('productinfo').tBodies[0];
	var newRow = tblBody.insertRow(-1);
	var newCell0 = newRow.insertCell(0);
	newCell0.innerHTML = '<input type="text" name="ProductCode|' + iRowCount.toString() + '" value=""/></td>';
	var newCell1 = newRow.insertCell(1);
	newCell1.innerHTML = '<input type="text" name="Strength|' + iRowCount.toString() + '" value=""/></td>';
	var newCell2 = newRow.insertCell(2);
	newCell2.innerHTML = '<input type="text" name="Packsize|' + iRowCount.toString() + '" value=""/></td>';
	var newCell3 = newRow.insertCell(3);
	newCell3.innerHTML = '<input type="text" name="Formulation|' + iRowCount.toString() + '" value=""/></td>';
	
	document.getElementById('ProductCount').value = iRowCount;
}

function AddBatchRow()
{
	var iRowCount = document.getElementById('BatchCount').value;
	iRowCount++;	
	
	var tblBody = document.getElementById('batchinfo').tBodies[0];
	var newRow = tblBody.insertRow(-1);
	var newCell0 = newRow.insertCell(0);
	newCell0.innerHTML = '<input type="text" name="BatchCode|' + iRowCount.toString() + '" value=""/></td>';
	
	document.getElementById('BatchCount').value = iRowCount;
}

function removeHTMLTags(pInputString)
{
	var strInputCode = pInputString;
	/* 
		This line is optional, it replaces escaped brackets with real ones, 
		i.e. < is replaced with < and > is replaced with >
	*/	
	strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
		return (p1 == "lt")? "<" : ">";
	});
	var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
	//alert("Output text:\n" + strTagStrippedText);	
// Use the alert below if you want to show the input and the output text
	//alert("Input code:\n" + strInputCode + "\n\nOutput text:\n" + strTagStrippedText);	
	return strTagStrippedText;
}
