var elapsedTime = 0;
var maxTime;
var warningTime;
var oneSecond;


function OnBodyLoad( sessionTimeOut, warningTimeInMinutes )
{
	// set maxTime to the Session.Timeout value to notify users when their Session times out.
	maxTime = ( sessionTimeOut ) * 60;
	
	// set the warning time
	warningTime = ( warningTimeInMinutes ) * 60;

	// call the TimeOut check method every second
	oneSecond = window.setTimeout("TimeoutCheck();",1000);
}


function TimeoutCheck()
{
	// increase the elapsed time by 1 second
    elapsedTime = elapsedTime + 1;

    if (maxTime == 0)
    {
		// time out has been disabled for this page so do nothing
    }
    else if (elapsedTime > maxTime)
    {
		// session has timed out
        window.location.href = 'SessionTimedOut.htm';
    }
    else if (elapsedTime == (maxTime - warningTime) )
    {
		// into warning time before timeout so popup warning window
		ScreenRedirectPopUp("INACTIVEWARNING","SessionInactive","InactiveWarning","","");
		// reset the timeout
		oneSecond = window.setTimeout("TimeoutCheck();",1000);
    }
    else
    {
		// reset the timeout
		oneSecond = window.setTimeout("TimeoutCheck();",1000);
    }
}


function ReInitialiseForTimeOutCheck()
{
	elapsedTime = 0;
}






function ScreenRedirect(strScreenName,strAction,strValue,strValue2) {
	if (verify(strScreenName,strAction)) {

		var formRef=document.forms["frmScreen"];

		if (strScreenName)	formRef.ScreenName.value = strScreenName;
		if (strAction)		formRef.Action.value = strAction;
		if (strValue)		formRef.strValue.value = strValue;
		if (strValue2)		formRef.strValue2.value = strValue2;

		formRef.target = "_self";
		formRef.submit();
	}
}


function ScreenRedirectFromQueryString(strFormAction) {

	var formRef=document.forms["frmScreen"];

	formRef.action = strFormAction;

	formRef.target = "_self";
	formRef.submit();

}



function ScreenRedirectPopUp(strWinName,strScreenName,strAction,strValue,strValue2) {


	if (strWinName != "INACTIVEWARNING")
	{
		if (window.name != strWinName)
		{
			// opening a new popup window so disable timeout on current window 
			maxTime = 0;
		}
	}

	if (verify(strScreenName,strAction)) {

		var formRef=document.forms["frmScreen"];

		formRef.ScreenName.value = strScreenName;
		if (strAction) formRef.Action.value = strAction;
		if (strValue) formRef.strValue.value = strValue;
		if (strValue2) formRef.strValue2.value = strValue2;

		var w = 480, h = 340;

		if (document.all) {
		   w = document.body.clientWidth;
		   h = document.body.clientHeight;
		}
		else if (document.layers) {
		   w = window.innerWidth;
		   h = window.innerHeight;
		}
		
		var sW = (window.screen.availWidth-12);
		var sH = (window.screen.availHeight-50);


		var popW = (w-200), popH = (h-30);
		var leftPos = (w-popW)/2, topPos = 60;

		if (strWinName == "RPT") {
			strWinSettings = 'status=no,menubar=yes,scrollbars=yes,resizable=yes,width='+popW+',height='+popH+',top='+topPos+',left='+leftPos;
		}
		else if (strWinName == "MAIL") {
			strWinSettings = 'menubar=no,scrollbars=no,width=590,height=290,top=110,left=100';
		}
		else if (strWinName == "UPLOAD") {
			strWinSettings = 'status=no,menubar=no,scrollbars=yes,width=590,height=290,top=110,left=100';
		}
		else if (strWinName == "CONFIRM") {
			strWinSettings = 'status=no,menubar=no,scrollbars=no,width=590,height=290,top=110,left=100';
		}
		else if (strWinName == "HTML") {
			strWinSettings = 'status=no,menubar=no,scrollbars=yes,resizable=yes,width='+popW+',height='+popH+',top='+topPos+',left='+leftPos;
		}
		else if (strWinName == "HELP") {
			strWinSettings = 'status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=300,top=110,left=100';
		}
		else if (strWinName == "INACTIVEWARNING") {
			strWinSettings = 'status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=400,top=110,left=100';
		}
		else {
			strWinName = 'POPUP';
//			strWinSettings = 'status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+popW+',height='+popH+',top='+topPos+',left='+leftPos;
			strWinSettings = 'status=yes,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0,width='+sW+',height='+sH;
		}
	

		if (strWinName != "HTML") {
			winPopUp = window.open('',strWinName,strWinSettings);
			winPopUp.focus();

			formRef.target = strWinName;
			formRef.submit();
		}
		else {
			winPopUp = window.open(strScreenName,strWinName,strWinSettings);
			winPopUp.focus();
		}
	}
}




function ScreenRedirectMailPopUp(strScreenName,strAction,strValue,strValue2) {
	var formRef=document.forms["frmScreen"];

	formRef.ScreenName.value = strScreenName;
	if (strAction) formRef.Action.value = strAction;
	if (strValue) formRef.strValue.value = strValue;
	if (strValue2) formRef.strValue2.value = strValue2;
	window.open('','winEmailPopUp','menubar=no,scrollbars=yes,width=590,height=280,screenX=110,screenY=100,top=110,left=100');
	formRef.target = "winEmailPopUp"
	formRef.submit();
}


function WinPopUp(url)
{
	var winpopup=window.open(url,'popup','height=200,width=500');
	if (window.focus) {winpopup.focus()}
}


function ConfirmationPopUp(strText) {
	if (strText == "")
		var agree=confirm("Delete the current record?");
	else
		var agree=confirm(strText);
	if (agree)
		return true;
	else
		return false;
}


function selectAllM(cnt) {
	var formRef=document.forms["frmScreen"];
	if (formRef.elements['AllSelect'].checked) {
		for(i=0; i < cnt; i++) {
			formRef.MessageId[i].checked = true;
		}
	}
	else {
		for(i=0; i < cnt; i++) {
			formRef.MessageId[i].checked = false;
		}
	}
}


function selectAllCbo(strName) {
	var formRef=document.forms["frmScreen"];
	var blnChecked;

	// check if All has been checked
	if (eval("formRef.All" + strName + ".checked") == true)	{
		blnChecked = true;
	}

	var controlIndex;
	var element;
	var numberOfControls = formRef.length;
	var strElementNames;
	// loop through all the form elements to find the relevant checkbox elements, 
	// and check them if necessary
	for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
		element = formRef[controlIndex];
		if (element.type == "checkbox") {
			if (element.name == strName) {
				element.checked = blnChecked;
			}
		}
	}
}


function updateAllCbo(objCBO, strName) {
	var formRef=document.forms["frmScreen"];
	var objAllCBO = eval("formRef.All" + strName);
	if (objCBO.checked == false) {
		objAllCBO.checked = false;
	}
}


function selectAllRad(strName) {
	var formRef=document.forms["frmScreen"];

	var controlIndex;
	var element;
	var numberOfControls = formRef.length;
	var strElementNames;
	// get a string with the names of all all the relevant radio elements
	for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
		element = formRef[controlIndex];

		if (element.type == "radio") {
			var elementName = element.name;
			if (elementName.substring(0,strName.length) == strName) {
				if (strElementNames > "") {
					strElementNames = strElementNames + "," + elementName
				}
				else {
					strElementNames = elementName
				}
			}
		}
	}

	// check which All option was selected : 0=Inc  or 1=Exc
	var elementIndex;
	if (eval("formRef.All" + strName + "[0].checked") == true)	{
		elementIndex = 0;
	}
	else if (eval("formRef.All" + strName + "[1].checked") == true)	{
		elementIndex = 1;
	}

	// now CHECK the relevant radio buttons
	var arrElementNames = strElementNames.split(",");
	for ( i = 0; i < arrElementNames.length; i++) { 
		formRef[arrElementNames[i]][elementIndex].checked = true;
	}

}



//----------------------------------------------------------------------------------------
// checks that newpassword1 equals newpassword2 ...
//----------------------------------------------------------------------------------------
function ValidateNewPassword() {
	var formRef=document.forms["frmScreen"];

	if (formRef.NewPassword1.value.length > 0) {

		if (formRef.NewPassword1.value == formRef.NewPassword2.value) {
			if (formRef.NewPassword1.value.length > 5) {
				return true;
			}
			else {
				alert("New password must be at least 6 characters. Please re-enter!")
				formRef.NewPassword1.value = ""
				formRef.NewPassword2.value = ""
				return false;	
			}
		}
		else {
			alert("New passwords are not equal. Please re-enter!")
			formRef.NewPassword1.value = ""
			formRef.NewPassword2.value = ""
			return false;	
		}
	}
}


//----------------------------------------------------------------------------------------
// 
//----------------------------------------------------------------------------------------
function DoCal(elTarget) {
	if (showModalDialog) {
		var sRtn;
		sRtn = showModalDialog("scripts/calendar.htm","","center=yes;dialogWidth=250pt;dialogHeight=200pt");
		if (sRtn!="")
			var selDate = new Date(sRtn); //selected date
			elTarget.value = getFormattedDateString(selDate);
	} else
		alert("Internet Explorer 4.0 or later is required.")
}


//----------------------------------------------------------------------------------------
// 
//----------------------------------------------------------------------------------------
function DoJobCal(elTarget) {
	if (showModalDialog) {
		var sRtn;
		sRtn = showModalDialog("scripts/calendar.htm","","center=yes;dialogWidth=250pt;dialogHeight=200pt");
		if (sRtn!="") {

			var formRef=document.forms["frmScreen"];
			var curDate = new Date(); //current date
			var selDate = new Date(sRtn); //selected date

			if (elTarget=="DateJobStarted") {
				if (daysBetween(selDate,curDate) > 180) {
					alert("Start date must be within 6 months of current date!");
				} else {
					formRef.DateJobStarted.value = getFormattedDateString(selDate);
				}
			}
			
			if (elTarget=="DateJobFinished") {
				var ds = formRef.DateJobStarted.value.substr(0,2);
				var ms = formRef.DateJobStarted.value.substr(3,2);
				var ys = formRef.DateJobStarted.value.substr(6,4);
				startDate = new Date(ms + "/" + ds + "/" + ys);

				if (selDate > curDate) {
					alert("Finish date cannot be in the future.")
				} else {
					var iDaysBetween = daysBetween(selDate,startDate);
					if (iDaysBetween > 180) {
						alert("Finish date must be within 6 months of start date!");
					} else {
						if (iDaysBetween < 0) {
							alert("Finish date cannot be before start date!");
						} else {
							formRef.DateJobFinished.value = getFormattedDateString(selDate);
						}
					}
				}
			}
		}
	} else
		alert("Internet Explorer 4.0 or later is required.")
}


//----------------------------------------------------------------------------------------
// 
//----------------------------------------------------------------------------------------
function getFormattedDateString(objDate) {

	var d  = objDate.getDate();
	var day = (d < 10) ? '0' + d : d;

	var m = objDate.getMonth() + 1;
	var month = (m < 10) ? '0' + m : m;

	var yy = objDate.getYear();
	var year = (yy < 1000) ? yy + 1900 : yy;

	return day+"/"+month+"/"+year;

}


//----------------------------------------------------------------------------------------
// 
//----------------------------------------------------------------------------------------
function daysBetween(date1, date2) {

    // the number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime();
    var date2_ms = date2.getTime();

    // Calculate the difference in milliseconds
    var difference_ms = date1_ms - date2_ms;
    
    // Convert back to days and return
    return Math.round(difference_ms/ONE_DAY);

}


//----------------------------------------------------------------------------------------
// verify screen form fields
//----------------------------------------------------------------------------------------
function verify(strScreenName,strAction) {
	var frm=document.forms["frmScreen"];
	var doVerify = false;
	var msg;
	var empty_fields = "";
	var errors = "";

	//initialise form fields on required screens

	if ((strScreenName == "HelpAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.ScrAction.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "CollegeAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.Address1.optional = true;
		frm.Address2.optional = true;
		frm.TownCity.optional = true;
		frm.County.optional = true;
		frm.PostCode.optional = true;
		frm.Tel.optional = true;
		frm.Fax.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "CollegeAdmin") && (strAction == "addusersave")) {
		doVerify = true;
	}
	else if ((strScreenName == "CollegeAdmin") && (strAction == "editusersave")) {
		frm.NewPassword1.optional = true;
		frm.NewPassword2.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "IVAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.Email.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "IVAdmin") && (strAction == "savelogin")) {
		frm.NewPassword1.optional = true;
		frm.NewPassword2.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "AssessorAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.Email.optional = true;
		frm.Email2.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "AssessorAdmin") && (strAction == "savelogin")) {
		frm.NewPassword1.optional = true;
		frm.NewPassword2.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "CandidateAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.Address1.optional = true;
		frm.Address2.optional = true;
		frm.TownCity.optional = true;
		frm.County.optional = true;
		frm.PostCode.optional = true;
		frm.Tel.optional = true;
		frm.Fax.optional = true;
		frm.Mobile.optional = true;
		frm.Email.optional = true;
		frm.DOB.optional = true;
		frm.CollegeRef.optional = true;
		frm.CGCandRef.optional = true;
		frm.Disability.optional = true;
		frm.LearnerGroup.optional = true;
		frm.QualificationBackground.optional = true;
		frm.Source.optional = true;
		frm.LeavingCodeId.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "CandidateAdmin") && (strAction == "loginsave")) {
		frm.NewPassword1.optional = true;
		frm.NewPassword2.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "EmployerAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.Address1.optional = true;
		frm.Address2.optional = true;
		frm.TownCity.optional = true;
		frm.County.optional = true;
		frm.PostCode.optional = true;
		frm.Tel.optional = true;
		frm.Fax.optional = true;
		frm.Email.optional = true;
		frm.Type.optional = true;
		frm.IIPStatus.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "EmployerAdmin") && (strAction == "addusersave")) {
		doVerify = true;
	}
	else if ((strScreenName == "EmployerAdmin") && (strAction == "editusersave")) {
		frm.NewPassword1.optional = true;
		frm.NewPassword2.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "EmployerAdmin") && (strAction == "addusercandsave")) {
		doVerify = true;
	}
	else if ((strScreenName == "ManagingAgentAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.Address1.optional = true;
		frm.Address2.optional = true;
		frm.TownCity.optional = true;
		frm.County.optional = true;
		frm.PostCode.optional = true;
		frm.Tel.optional = true;
		frm.Fax.optional = true;
		frm.Email.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "ManagingAgentAdmin") && (strAction == "addusersave")) {
		doVerify = true;
	}
	else if ((strScreenName == "ManagingAgentAdmin") && (strAction == "editusersave")) {
		frm.NewPassword1.optional = true;
		frm.NewPassword2.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "ManagingAgentAdmin") && (strAction == "addusercandsave")) {
		doVerify = true;
	}
	else if ((strScreenName == "NvqAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.NvqNo.numeric = true;
		frm.NvqLevel.numeric = true;
		frm.QNo.optional = true;
		frm.DateExpiry.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "UnitEdit") && ((strAction == "addsave") || (strAction == "editsave") || (strAction == "addloadas"))) {
		frm.Overview.optional = true;
		frm.Overview.maxlength = 2000;
		doVerify = true;
	}
	else if ((strScreenName == "KeywordGroupEdit") && ((strAction == "addsave") || (strAction == "editsave"))) {
		doVerify = true;
	}
	else if ((strScreenName == "POEdit") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.ObjectiveNo.numeric = true;
		frm.ObjectiveText.maxlength = 500;
		frm.HelpText.maxlength = 1000;
		frm.HelpText.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "KEEdit") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.RequirementNo.numeric = true;
		frm.RequirementText.maxlength = 500;
		frm.HelpText.maxlength = 1000;
		frm.HelpText.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "OQEdit") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.QuestionNo.numeric = true;
		frm.QuestionText.maxlength = 500;
		frm.ExpectedResponse.maxlength = 1000;
		frm.HelpText.maxlength = 1000;
		frm.HelpText.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "SQEdit") && ((strAction == "addsave") || (strAction == "editsave"))) {
		frm.QuestionNo.numeric = true;
		frm.QuestionText.maxlength = 500;
		frm.HelpText.maxlength = 1000;
		frm.HelpText.optional = true;
		doVerify = true;
	}
	else if ((strScreenName == "ABodyAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		doVerify = true;
	}
	else if ((strScreenName == "QualificationAdmin") && ((strAction == "addsave") || (strAction == "editsave"))) {
		doVerify = true;
	}
	else if ((strScreenName == "Access") && (strAction == "savepassword")) {
		doVerify = true;
	}
	else if ((strScreenName == "DemoAdmin") && (strAction == "addsave")) {
		doVerify = true;
	}
	else if ((strScreenName == "CandGroupEdit") && (strAction == "SaveGroup")) {
		frm.DateExpectedFinish.optional = false;
		doVerify = true;
	}
	else if ((strScreenName == "CandGroupEdit") && (strAction == "CreateGroups")) {
		frm.DateExpectedFinish.optional = false;
		doVerify = true;
	}
	else if ((strScreenName == "CandidateInterview") && (strAction == "RejectSave")) {
		frm.RejectionReason.optional = false;
		doVerify = true;
	}
	else if ((strScreenName == "Verification") && (strAction == "plansel1")) {
		frm.Comments.optional = true;
		frm.SampleSize.optional = false;
		frm.SampleSize.numeric = true;
		doVerify = true;
	}
	else if ((strScreenName == "AssessmentPlan") && (strAction == "Save")) {
		frm.ProposedAssessment.maxlength = 1000;
		if (frm.ActualAssessment != null) frm.ActualAssessment.maxlength = 1000;
		if (frm.CandidateComments != null) frm.CandidateComments.maxlength = 1000;
		if (frm.DateActual != null) frm.DateActual.isDate = true;
		doVerify = true;
	}
	else if ((strScreenName == "Verification") && (strAction == "candnvqunitsave")) {
		frm.Status.optional = true;
		frm.Comments.optional = true;
		frm.Comments.maxlength = 500;
		doVerify = true;
	}
	else if ((strScreenName == "TrainingReview") && (strAction == "Save")) {
		if (frm.DateOfReview != null) frm.DateOfReview.isDate = true;
		if (frm.DateNextReview != null) frm.DateNextReview.isDate = true;
		frm.NvqProgressComments.optional = true;
		frm.TCProgressComments.optional = true;
		frm.KSProgressComments.optional = true;
		frm.ActionsRequiredByReviewer.optional = true;
		frm.LearnersComments.optional = true;
		doVerify = true;
	}


	//only check initialised screens - see above
	if (doVerify) {
		for(var i = 0; i < frm.length; i++) {
			var e = frm.elements[i];

			if (e.type == "textarea") {
				//check the maxlength
				if (e.value.length > e.maxlength) {
//					e.value = e.value.substring(0,(e.maxlength))
					errors += "- " + e.name + " cannot be longer than " + e.maxlength + " characters.\n";
				}
			}

			if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {
				// first check if the field is empty
				if ((e.value == null) || (e.value == "")) {
					empty_fields += "\n      " + e.name;
				}
				else if (e.isDate == true) {
					if (isDate(e.value) == false){
						errors += "- The date format for " + e.name + " should be dd/mm/yyyy.\n";
					}
				}
			}
			
			if ((e.type == "password") && !e.optional) {
				// first check if the field is empty
				if ((e.value == null) || (e.value == "")) {
					empty_fields += "\n      " + e.name;
				}
				//then check for minimum length
				if ((e.value.length < 6) && !(e.name == "CurrentPassword")) {
					errors += "- " + e.name + " must be at least 6 characters.\n";
				}
				continue;
			}

			if ((e.type == "password") && e.optional) {
				// for check if the field is not empty
				if ((e.value != null) && (e.value != "")) {
					//then check for minimum length
					if (e.value.length < 6) {
						errors += "- " + e.name + " must be at least 6 characters.\n";
					}
				}
				continue;
			}

			if (e.numeric) {
				if (isNaN(e.value)) 
					errors += "- " + e.name + " must be a number.\n";
			}

		}
	}


	/* SPEACIAL ERROR HANDLING FOR LOGSHEET */
	if ((strScreenName == "LogSheet") && (strAction == "SaveLogSheetMain")) {
		var e;
		
		e = frm.DateJobStarted
		if ( ! ((e.value == null) || (e.value == "")) ) {
			if (isDate(e.value)==false){
				errors += "- The date format for DateJobStarted should be dd/mm/yyyy.\n";
			}
		}
	
		e = frm.DateJobFinished
		if ( ! ((e.value == null) || (e.value == "")) ) {
			if (isDate(e.value)==false){
				errors += "- The date format for DateJobFinished should be dd/mm/yyyy.\n";
			}
		}
		
		e = frm.JobDescription
		if (e.value.length > 2000) {
				errors += "- The maximum length for Job Description has been exceeded.\n";
		}
		
		e = frm.AssessorNotes
		if (e.value.length > 1000) {
				errors += "- The maximum length for Assessor Notes has been exceeded.\n";
		}
		
	
	}



	// now, if there were any errors, display error messages and return false
	//otherwise return true
	if (!empty_fields && !errors) {
		return true;
	}
	else {
		msg  = "________________________________________________\n\n";
		msg += "The form was not submitted because of the following error(s).\n";
		msg += "Please correct these error(s) and re-submit.\n";
		msg += "________________________________________________\n\n";
			
		if (empty_fields) {
			msg += "- The following required field(s) are empty:"
						+ empty_fields + "\n"
			if (errors) msg += "\n";
		}
		msg += errors;
		alert(msg);
		return false;
	}
}




function MM_swapImgRestore() {
	if (document.MM_swapImgData != null)
	for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
	document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() {
	var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
	for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
		objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
		if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
			(objStr.indexOf('document.all[')   ==0 && document.all   ==null)) {
			objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
		}
		obj = eval(objStr);
		if (obj != null) {
			swapArray[j++] = obj;
			swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
			obj.src = MM_swapImage.arguments[i+2];
		}
	}
	document.MM_swapImgData = swapArray; //used for restore
}




function SetLogoText(strText) {
	document.frmScreen.LogoText.value = strText;
}


function TR_OnMouseOver(obj) {
  obj.bgColor="#ababab";
}
function TR_OnMouseOver_WH(obj) {
  obj.bgColor="#ababab";
  obj.style.cursor="hand";
}
function TR_OnMouseOut(obj) {
  obj.bgColor=document.bgColor;
}


function checkMaxLength(taText, len)
{
if (taText.value.length > len)
 taText.blur();
}









/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
return true
}

