function showBackground()
{
	setTimeout('showBackgroundImage()', 1000);
}

function showBackgroundImage()
{
	document.getElementById('player').style.backgroundImage = 'url(/images/icon_sound.gif)';
}

function updateDepartmentsList(pValue)
{
	var sDeptList = document.getElementById('DepartmentList').value;

	if (sDeptList.indexOf(pValue) == -1)
		sDeptList += pValue.toString() + ',';
	else
		sDeptList = sDeptList.replace(pValue + ',','');

	document.getElementById('DepartmentList').value = sDeptList;
}

function showUserTypeDescription(pUserTypeID)
{
	var sHTML = '';

	switch (pUserTypeID)
	{
		case '1':
			sHTML = 'Administrators can access and control all elements within the Intranet.  They have full access to the intranet and its admin area.<br/><br/>Select the Administrator User Type for users that you trust, and that you would like to oversee all areas.  They will have unrestricted access to the Intranet.';
			document.getElementById('userdepartments').style.display = 'none';
			break;
		case '2':
			sHTML = 'Editors can access and control all elements within their assigned departments.  They have full access to the intranet, but can only edit content within their own department via the admin area.<br/><br/>Select the Editor User Type for users that you trust, and that you would like to oversee specified areas on the Intranet.  They will only be able to edit content in the areas that you specify below.';
			document.getElementById('userdepartments').style.display = 'block';
			break;
		case '3':
			sHTML = 'Regular Users can view and access all content within the Intranet, but they cannot change anything.  They have no access to the Intranet Admin Area.<br/><br/>Select the Regular User Type for users that you would like to allow access to the intranet content, but not to be able to edit any content.';
			document.getElementById('userdepartments').style.display = 'none';
			break;
		default:
			sHTML = '';
			break;
	}

	if (sHTML != '')
	{
		document.getElementById('usertypedescription').innerHTML = '<img src="/images/related_box_top.gif" alt="test"/><div id="infobox">' + sHTML + '</div>';
		document.getElementById('usertypedescription').style.display = 'block';
	}
	else
	{
		document.getElementById('usertypedescription').innerHTML = '';
		document.getElementById('usertypedescription').style.display = 'none';
	}
}

function validateIDDeleteForm(pForm)
{
	var bValid = true;
	var sAdditionalMessage = (document.getElementById("ItemMessage").value == '') ? '' : '\n\n' + document.getElementById("ItemMessage").value;

	if ((bValid) && (document.getElementById("ID").value==''))
	{
		bValid = false;
		alert('You must select a ' + document.getElementById("ItemName").value + ' to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this ' + document.getElementById("ItemName").value + '?' + sAdditionalMessage);
	}

	return bValid;
}

function validateIDForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.ID.value==''))
	{
		bValid = false;
		alert('You must select a ' + document.getElementById("ItemName").value + ' to continue');
	}

	return bValid;
}

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}

	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

function checkFileType(pValue)
{
	var arrTypes = document.getElementById('AcceptedFileTypes').value.split('|');
	var bSuccess = false;

	for (var ii = 0; ii < arrTypes.length; ii++)
	{
		bSuccess = pValue.endsWith('.' + arrTypes[ii]);
		if (bSuccess) break;
	}

	if (!bSuccess) alert('Your file is not an accepted type - you can only upload the following types:\r\n\r\n' + document.getElementById('AcceptedFileTypes').value.replace(/\|/gi,", "));
}

function formCharCount(pInput,pLimit)
{
	document.getElementById(pInput.id + 'CharsLeft').innerHTML = '(' + (pLimit - pInput.value.length) + ' characters left)';

	if (pInput.value.length > pLimit)
	{
		pInput.value = pInput.value.substring(0,pLimit);
		document.getElementById(pInput.id + 'CharsLeft').innerHTML = '(0 characters left)';
	}
}
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 );
}

/****************************************************************************/
/****************************************************************************/
/****************************************************************************/

function validateSearchForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.keywords.value==''))
	{
		bValid = false;
		alert('You must enter some keywords to perform a search');
	}

	return bValid;
}

function validateCommentsForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.CreatedBy.value==''))
	{
		bValid = false;
		alert('You must enter a Your Name');
	}

	if ((bValid) && (pForm.Comment.value==''))
	{
		bValid = false;
		alert('You must enter a Your Comment');
	}

	return bValid;
}

function validateDepartmentForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.DepartmentNameIsOK.value=='FALSE'))
	{
		bValid = false;
		alert('You must enter a valid Department Name');
	}

	if ((bValid) && (pForm.DepartmentName.value==''))
	{
		bValid = false;
		alert('You must enter a Department Name');
	}

	return bValid;
}

function validateUserForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Email.value==''))
	{
		bValid = false;
		alert('You must enter an Email Address');
	}

	if (bValid)
	{
		bValid = validEmail(pForm.Email.value);
	}

	if ((bValid) && (pForm.EmailIsOK.value=='FALSE'))
	{
		bValid = false;
		alert('You must enter a valid Email Address');
	}

	if ((bValid) && (pForm.FirstName.value==''))
	{
		bValid = false;
		alert('You must enter a First Name');
	}

	if ((bValid) && (pForm.Surname.value==''))
	{
		bValid = false;
		alert('You must enter a Surname');
	}

	if ((bValid) && (pForm.Password.value==''))
	{
		bValid = false;
		alert('You must enter a Password');
	}

	if ((bValid) && (pForm.UserTypeID.value==''))
	{
		bValid = false;
		alert('You must select a User Type');
	}

	if (bValid)
	{
		if (pForm.UserTypeID.value=='2')
		{
			if (pForm.UserDepartments.value=='')
			{
				bValid = false;
				alert('You must select at least one Department for this user to access');
			}
		}
	}

	return bValid;
}


function validatePageForm(pForm)
{
	syncTextarea();
	var bValid = true;

	if ((bValid) && (pForm.TitleIsOK.value=='FALSE'))
	{
		bValid = false;
		alert('You must enter a valid Title');
	}

	if ((bValid) && (pForm.ParentID.value==''))
	{
		bValid = false;
		alert('You must select a navigation section');
	}

	if ((bValid) && (pForm.PageTitle.value==''))
	{
		bValid = false;
		alert('You must enter a Title');
	}

	if ((bValid) && (pForm.PageContent.value==''))
	{
		bValid = false;
		alert('You must enter the Page Content');
	}

	if ((bValid) && (pForm.DepartmentID.value==''))
	{
		bValid = false;
		alert('You must select a Department');
	}

	return bValid;
}

/****************************************************************************/
/****************************************************************************/
/****************************************************************************/



function ChangeProductImage(pImageURL)
{
	var oDiv = $('mainproductimage');
	oDiv.fade({ duration: 0.5 });
	setTimeout('newProductImage(\'' + pImageURL + '\')', 500);
}

function newProductImage(pImageURL)
{
	var oDiv = $('mainproductimage');
	oDiv.src = '/images/products/' + pImageURL;
	oDiv.appear({ duration: 0.5 });
}

function setProductSectionURLPath(pValue)
{
	var arrTemp = pValue.split('|');

	document.getElementById('CategoryID').value = arrTemp[0];

	var sNewValue = arrTemp[1].replace('.aspx','/');
	document.getElementById('SectionURLPath').value = sNewValue;
}


var homeOn = new Image();
var homeOff = new Image();
var aboutOn = new Image();
var aboutOff = new Image();
var servicesOn = new Image();
var servicesOff = new Image();
var productsOn = new Image();
var productsOff = new Image();
var newsOn = new Image();
var newsOff = new Image();
var blogOn = new Image();
var blogOff = new Image();
var contactOn = new Image();
var contactOff = new Image();

function SwapIMG(imageName, image, imagePath)
{
	if (image.src == '')
	{
		image.src = imagePath;
	}
	document.images[imageName].src = image.src;
}

var bMenuAboutUsOn = false;
var bMenuLearningOn = false;
var bMenuTeachingOn = false;
var bMenuParentsOn = false;
var bMenuPartnersOn = false;
var bMenuContactUsOn = false;

function showMenu(pMenu)
{
	setTimeout("doShowMenu('" + pMenu + "')", 500);
}

function doShowMenu(pMenu)
{
	var bMenuOn = null;
	switch(pMenu)
	{
		case 'aboutus':
			bMenuOn = bMenuAboutUsOn;
			break;
		case 'learning':
			bMenuOn = bMenuLearningOn;
			break;
		case 'teaching':
			bMenuOn = bMenuTeachingOn;
			break;
		case 'parents':
			bMenuOn = bMenuParentsOn;
			break;
		case 'partners':
			bMenuOn = bMenuPartnersOn;
			break;
		case 'contactus':
			bMenuOn = bMenuContactUsOn;
			break;
	}

	if (bMenuOn) $('menu'+pMenu).appear({ duration: 0.5 });

}

function hideMenu(pMenu) {
	setTimeout("doHideMenu('" + pMenu + "')", 1000);
}

function doHideMenu(pMenu)
{
	var bMenuOn = null;
	switch(pMenu)
	{
		case 'aboutus':
			bMenuOn = bMenuAboutUsOn;
			break;
		case 'learning':
			bMenuOn = bMenuLearningOn;
			break;
		case 'teaching':
			bMenuOn = bMenuTeachingOn;
			break;
		case 'parents':
			bMenuOn = bMenuParentsOn;
			break;
		case 'partners':
			bMenuOn = bMenuPartnersOn;
			break;
		case 'contactus':
			bMenuOn = bMenuContactUsOn;
			break;
	}

	if (!bMenuOn) $('menu'+pMenu).fade({ duration: 0.5 });
}

var iCurrentGalleryImage = 1;

function nextImage()
{
	iCurrentGalleryImage++;
	if (iCurrentGalleryImage > iImageCount) iCurrentGalleryImage = 1;
	ChangeGalleryImage(iCurrentGalleryImage);
}

function previousImage()
{
	iCurrentGalleryImage--;
	if (iCurrentGalleryImage < 1) iCurrentGalleryImage = iImageCount;
	ChangeGalleryImage(iCurrentGalleryImage);
}

function ChangeGalleryImage(pID)
{
	iCurrentGalleryImage = pID;
	var oImage = arrImages[iCurrentGalleryImage-1];

	$('galleryimage').fade();
	$('galleryimagedescription').fade();
	setTimeout("ShowGalleryImage('" + oImage.src + "','" + oImage.alt + "')", 1000);

	for (var ii = 1; ii <= iImageCount; ii++)
	{
		$('thumbnail' + ii).className = "thumbnail";
	}
	$('thumbnail' + pID).className = "thumbnailon";
}

function ShowGalleryImage(pNewImageSRC, pNewImageAlt)
{
	$('galleryimage').src = pNewImageSRC;
	$('galleryimage').alt = pNewImageAlt;
	$('galleryimagedescription').innerHTML = pNewImageAlt;

	$('galleryimage').appear();
	$('galleryimagedescription').appear();
}

function validateDocumentForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Document.value==''))
	{
		bValid = false;
		alert('You must select a document to upload');
	}

	return bValid;
}

function validateEnquiryForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Name.value==''))
	{
		bValid = false;
		alert('You must enter your name');
	}

	if ((bValid) && (pForm.EmailAddress.value==''))
	{
		bValid = false;
		alert('You must enter an email address');
	}

	if (bValid)
	{
		bValid = validEmail(pForm.EmailAddress.value);
	}

	if ((bValid) && (pForm.ContactNumber.value==''))
	{
		bValid = false;
		alert('You must enter a contact number');
	}

	if ((bValid) && (pForm.NatureOfEnquiry.value==''))
	{
		bValid = false;
		alert('You must enter the nature of your enquiry');
	}

	return bValid;
}

function validateApplicationForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Name.value==''))
	{
		bValid = false;
		alert('You must enter your name');
	}

	if ((bValid) && (pForm.AgencyName.value==''))
	{
		bValid = false;
		alert('You must enter an agency name');
	}

	if ((bValid) && (pForm.AgencyPhone.value==''))
	{
		bValid = false;
		alert('You must enter an agency phone number');
	}

	if ((bValid) && (pForm.AgencyEmail.value==''))
	{
		bValid = false;
		alert('You must enter an agency email contact');
	}

	if ((bValid) && (pForm.Location.value==''))
	{
		bValid = false;
		alert('You must enter your current location');
	}

	if ((bValid) && (pForm.Position.value==''))
	{
		bValid = false;
		alert('You must enter the position you are applying for');
	}

	if ((bValid) && (pForm.Experience.value==''))
	{
		bValid = false;
		alert('You must enter your recent experience');
	}

	if ((bValid) && (pForm.LessonStructure.value==''))
	{
		bValid = false;
		alert('You must enter how you structure your lessions to make them successful');
	}

	if ((bValid) && (pForm.ClassroomManagement.value==''))
	{
		bValid = false;
		alert('You must enter your classroom management strategies');
	}

	if ((bValid) && (pForm.WhySuccessful.value==''))
	{
		bValid = false;
		alert('You must enter why you think you will be successful in this post');
	}

	return bValid;
}

function validateEventIDDeleteForm(pForm)
{
	var bValid = true;

	if ((bValid) && (document.getElementById("EventID").value==''))
	{
		bValid = false;
		alert('You must select an Event to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this Event?');
	}

	return bValid;
}

function validateEventIDForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.EventID.value==''))
	{
		bValid = false;
		alert('You must select an Event to continue');
	}

	return bValid;
}

function validateEventForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Title.value=='FALSE'))
	{
		bValid = false;
		alert('You must enter a valid Title');
	}

	if ((bValid) && (pForm.StartDate.value==''))
	{
		bValid = false;
		alert('You must enter the Start Date');
	}

	if ((bValid) && (pForm.EndDate.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 sEndDay = pForm.EndDate.value.split("/")[0];
		var sEndMonth = pForm.EndDate.value.split("/")[1];
		var sEndYear = pForm.EndDate.value.split("/")[2];
		var dtEndDate = new Date();

		if (sEndDay.substr(0,1) == "0") sEndDay = sEndDay.substr(1);
		if (sEndMonth.substr(0,1) == "0") sEndMonth = sEndMonth.substr(1);

		dtEndDate.setFullYear(parseInt(sEndYear),(parseInt(sEndMonth) - 1),parseInt(sEndDay));

		if (dtEndDate < dtStartDate)
		{
			alert('The End Date must be later than the Start Date.');
			bValid = false;
		}
	}

	return bValid;
}

function validateAlbumIDDeleteForm(pForm)
{
	var bValid = true;

	if ((bValid) && (document.getElementById("AlbumID").value==''))
	{
		bValid = false;
		alert('You must select an Album to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this Album?');
	}

	return bValid;
}

function validateAlbumPictureForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Filename.value==''))
	{
		bValid = false;
		alert('You must select an Image to continue');
	}

	return bValid;
}

function validateArticleIDForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.ArticleID.value==''))
	{
		bValid = false;
		alert('You must select an Article to continue');
	}

	return bValid;
}

function validateProductIDForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.ProductID.value==''))
	{
		bValid = false;
		alert('You must select a Product to continue');
	}

	return bValid;
}

function validateProductIDDeleteForm(pForm)
{
	var bValid = true;

	if ((bValid) && (document.getElementById("ProductID").value==''))
	{
		bValid = false;
		alert('You must select a valid Product to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this Product?');
	}

	return bValid;
}

function validateCategoryIDForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.CategoryID.value==''))
	{
		bValid = false;
		alert('You must select a Category to continue');
	}

	return bValid;
}

function validateCategoryIDDeleteForm(pForm)
{
	var bValid = true;

	if ((bValid) && (document.getElementById("CategoryID").value==''))
	{
		bValid = false;
		alert('You must select a Valid Category to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this Category?');
	}

	return bValid;
}

function validateFooterLinkIDForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.FooterLinkID.value==''))
	{
		bValid = false;
		alert('You must select a Footer Link to continue');
	}

	return bValid;
}

function validateFooterLinkIDDeleteForm(pForm)
{
	var bValid = true;

	if ((bValid) && (document.getElementById("FooterLinkID").value==''))
	{
		bValid = false;
		alert('You must select a valid Footer Link to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this Footer Link?');
	}

	return bValid;
}

function validatePartnerIDForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.PartnerID.value==''))
	{
		bValid = false;
		alert('You must select a Partner to continue');
	}

	return bValid;
}

function validatePartnerIDDeleteForm(pForm)
{
	var bValid = true;

	if ((bValid) && (document.getElementById("PartnerID").value==''))
	{
		bValid = false;
		alert('You must select a valid Partner to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this Partner?');
	}

	return bValid;
}

function validatePageIDForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.PageID.value==''))
	{
		bValid = false;
		alert('You must select a Page to continue');
	}

	return bValid;
}

function validatePageIDDeleteForm(pForm)
{
	var bValid = true;

	if ((bValid) && (document.getElementById("PageID|DELETE").value==''))
	{
		bValid = false;
		alert('You must select a Valid Page to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this page?');
	}

	return bValid;
}

function validateArticleIDDeleteForm(pForm)
{
	var bValid = true;

	if ((bValid) && (document.getElementById("ArticleID").value==''))
	{
		bValid = false;
		alert('You must select a Valid Article to delete');
	}

	if (bValid)
	{
		bValid = confirm('Are you sure you want to delete this article?');
	}

	return bValid;
}

function validateCategoryForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.TitleIsOK.value=='FALSE'))
	{
		bValid = false;
		alert('You must enter a valid Title');
	}

	if ((bValid) && (pForm.CategoryTitle.value==''))
	{
		bValid = false;
		alert('You must enter a Title');
	}

	if ((bValid) && (pForm.CategoryDescription.value==''))
	{
		bValid = false;
		alert('You must enter a Description');
	}

	if ((bValid) && (pForm.CategoryImage.value==''))
	{
		bValid = false;
		alert('You must select an Image to use');
	}

	return bValid;
}

function validateProductForm(pForm)
{
	syncTextarea();
	var bValid = true;

	if ((bValid) && (pForm.TitleIsOK.value=='FALSE'))
	{
		bValid = false;
		alert('You must enter a valid Title');
	}

	if ((bValid) && (pForm.Category.value==''))
	{
		bValid = false;
		alert('You must select a category for this product');
	}

	if ((bValid) && (pForm.ProductTitle.value==''))
	{
		bValid = false;
		alert('You must enter a Title');
	}

	if ((bValid) && (pForm.ProductSummary.value==''))
	{
		bValid = false;
		alert('You must enter the Product Summary');
	}

	if ((bValid) && (pForm.ProductDescription.value==''))
	{
		bValid = false;
		alert('You must enter the Product Description');
	}

	if ((bValid) && (pForm.ProductCode.value==''))
	{
		bValid = false;
		alert('You must enter the Product Code');
	}

	if ((bValid) && (pForm.ProductBarcode.value==''))
	{
		bValid = false;
		alert('You must enter the Product Barcode');
	}

	return bValid;
}

function validateFeaturedProductForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.ProductID.value==''))
	{
		bValid = false;
		alert('You must select a Product');
	}

	return bValid;
}

function validateProductImageForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.PictureURL.value==''))
	{
		bValid = false;
		alert('You must select an image to use');
	}

	return bValid;
}

function validateFooterLinkForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Title.value==''))
	{
		bValid = false;
		alert('You must enter a Title');
	}

	if ((bValid) && (pForm.InternalPageURI.value==''))
	{
		bValid = false;
		alert('You must select a page to link to');
	}

	return bValid;
}

function validatePartnerForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Title.value==''))
	{
		bValid = false;
		alert('You must enter a Title');
	}

	if ((bValid) && (pForm.Logo.value==''))
	{
		bValid = false;
		alert('You must select a logo to use');
	}

	return bValid;
}

function validateArticleForm(pForm)
{
	syncTextarea();
	var bValid = true;

	if ((bValid) && (pForm.PublishDate.value==''))
	{
		bValid = false;
		alert('You must enter the Article Publish Date');
	}

	if ((bValid) && (pForm.TitleIsOK.value=='FALSE'))
	{
		bValid = false;
		alert('You must enter a valid Title');
	}

	if ((bValid) && (pForm.ArticleTitle.value==''))
	{
		bValid = false;
		alert('You must enter a Title');
	}

	if ((bValid) && (pForm.ArticleDescription.value==''))
	{
		bValid = false;
		alert('You must enter a Summary');
	}

	if ((bValid) && (pForm.ArticleContent.value==''))
	{
		bValid = false;
		alert('You must enter the Article Content');
	}

	return bValid;
}

function validateOfficeForm(pForm)
{
	syncTextarea();
	var bValid = true;

	if ((bValid) && (pForm.ParentID.value==''))
	{
		bValid = false;
		alert('You must select a navigation section');
	}

	if ((bValid) && (pForm.PageTitle.value==''))
	{
		bValid = false;
		alert('You must enter a Title');
	}

	if ((bValid) && (pForm.PageContent.value==''))
	{
		bValid = false;
		alert('You must enter the Page Content');
	}

	if ((bValid) && (pForm.OfficePostcode.value==''))
	{
		bValid = false;
		alert('You must enter the Office Postcode');
	}

	if ((bValid) && (pForm.OfficeLatitude.value==''))
	{
		bValid = false;
		alert('You must enter the Office Latitude');
	}

	if ((bValid) && (pForm.OfficeLongitude.value==''))
	{
		bValid = false;
		alert('You must enter the Office Longitude');
	}

	return bValid;
}

function validatePageDownloadForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.DownloadTitle.value==''))
	{
		bValid = false;
		alert('You must enter a Title');
	}

	if ((bValid) && (pForm.Filename.value==''))
	{
		bValid = false;
		alert('You must select a file');
	}

	return bValid;
}

function validatePageDownloadForm(pForm)
{
	var bValid = true;

	if ((bValid) && (pForm.Filename.value==''))
	{
		bValid = false;
		alert('You must select a file');
	}

	return bValid;
}

function getSkillDetail(pSkill)
{
	var sHTML = '';

	switch (pSkill)
	{
		case 'XHTML 1.1':
			sHTML = '<p class="tooltip">XHTML 1.1 is a widely accepted standard of coding your website similar to HTML.  It means that this website was built in a way which adheres to strict standards set out by the W3C Governing body.  Adhering to these standards helps with cross browser compatibility, and also with basic accessibility.  This is currently the highest standard a website can be coded to.</p>';
			break;
		case 'CSS 2':
			sHTML = '<p class="tooltip">CSS standards for Cascading Style Sheets and is a common method used to &quot;style&quot; a website.  CSS Level 2 is another of the W3Cs widely accepted standards when is comes to writing your CSS and is currently the highest available for CSS scripting.</p>';
			break;
		case 'C#':
			sHTML = '<p class="tooltip">C#.NET is a programming language that is part of Microsoft&acute;s .NET environment.  It controls any changing content, or dynamic functionality on a website and is commonly used to communicate with a database.</p>';
			break;
		case 'ASP.NET':
			sHTML = '<p class="tooltip">ASP.NET is a programming language that is part of Microsoft&acute;s .NET environment.  It controls any changing content, or dynamic functionality on a website and is commonly used to communicate with a database.</p>';
			break;
		case 'SQL':
			sHTML = '<p class="tooltip">SQL standards for Structured Query Language and is the programming language used when reading and writing data to and from a database.</p>';
			break;
		case 'MS SQL Server':
			sHTML = '<p class="tooltip">MS SQL Server is Microsoft&acute;s industry standard database.  It can be used to store all information associated with a website, and is fast and reliable.</p>';
			break;
		case 'JavaScript':
			sHTML = '<p class="tooltip">Javascript is a programming language that runs in your web browser.  It is generally used to change images and content on a page without the page having to reload.  Its also common used to check a form for incorrect/empty fields before its submitted.</p>';
			break;
		case 'AJAX':
			sHTML = '<p class="tooltip">AJAX is actually Javascript and allows you to retrieve information from a database, or any external source, without having to reload the page.  Commonly, a loading animation is shown whilst the content is collected by AJAX.</p>';
			break;
		case 'Google Mapping':
			sHTML = '<p class="tooltip">Google allow developers to integrate their mapping application into websites, and to populate the maps as required.  This allows offices, shops and any locations to be highlighted on a live interactive map.</p>';
			break;
		case 'WCAG AA':
			sHTML = '<p class="tooltip">WCAG stands for the Web Content Accessibility Guidelines and are accessibility guidelines provided by the W3C. These guidelines focus on making content accessible, primarily for disabled users, but also for all user agents such as mobile phones as well as normal web browsers.  There are varying levels of these standards - A, AA and AAA.</p>';
			break;
		case 'CMS':
			sHTML = '<p class="tooltip">Content Managed means that this website is powered by a Content Management System (CMS).  This allows users to securly edit the content of their website themselves, without any need to know website programming languages.  This interface is simple and allows a client to manage the content of their own website.</p>';
			break;
		case 'YouTube':
			sHTML = '<p class="tooltip">YouTube is one of the most famous user driven video sites.  Users are able to upload their own videos and watch them for free.  YouTube allow these videos to be embedded within other websites meaning video content can be included on your site if you want it to.</p>';
			break;
		case 'SSL':
			sHTML = '<p class="tooltip">SSL stands for Secure Socket Layer and is a way of securing all connections to your website.  When viewing a website with SSL your connection to that website is encrypted meaning your information cannot be read by anyone else.  It commnly used when entering credit card details, and you look for the padlock icon in your browser.</p>';
			break;
		case 'PHP':
			sHTML = '<p class="tooltip">PHP is an open source programming language used to create dynamic web pages.  It controls any changing content, or dynamic functionality on a website and is commonly used to communicate with a database.</p>';
			break;
		case 'ASP':
			sHTML = '<p class="tooltip">ASP, now known as Classic ASP after the introduction the .NET Framework is a Microsoft programming language used to create dynamic web pages.  It controls any changing content, or dynamic functionality on a website and is commonly used to communicate with a database.</p>';
			break;
		case 'MySQL':
			sHTML = '<p class="tooltip">MySQL is an open source database system.  It can be used to store all information associated with a website, and is fast and reliable.</p>';
			break;
		case 'Flash':
			sHTML = '<p class="tooltip">Flash is a multimedia platform that is popular for adding animation and interactivity to web pages.  A common use is for embedding and streaming video too.</p>';
			break;
		case 'XML':
			sHTML = '<p class="tooltip">XML is a text formatted document commonly used to define data and its structure within a website.  XML can be output from one page, and read on another allowing data to be transferred with ease.</p>';
			break;
		case 'RSS':
			sHTML = '<p class="tooltip">RSS stands for Really Simple Syndication and is actually a form of XML.  Its used to define and transmit news articles and their information and uses a common format allowing it to be read on many different platforms.</p>';
			break;
	}

	return sHTML;
}

function getProjectImage(pProjectCode,pNumber)
{
	document.getElementById("mainprojectimage").src = 'images/projects/' + pProjectCode + '_' + pNumber + '.jpg';
}

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 filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(str)) {
		alert('Please provide a valid email address');
		return false;
	}
	else
		return true;
}

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 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;
}

