<!--
// DESC: Generic Javascripts
// History: MLam 26/06/03 - Added Function SetStatusBarMsg

		function Navigate(form)	{

			var TheHTML = "<SELECT name='ReportID'><OPTION value='-1' selected>--- Select Report Type ---"
			var SelectedCatID = -1

			var j = 0

				//get selected CatID
					SelectedCatID = form.CatID.value;
	
				//run through array and show the report types that belong to the selected category
					for(j=0; j<=i; j++)	{
						if(ArrCatID[j] == SelectedCatID)	{TheHTML += "<OPTION value=" + ArrRptID[j] + ">" + ArrRptName[j]}
					}
			TheHTML += "</select>"
			//alert(TheHTML)
			document.all.ReportSelection.innerHTML=TheHTML
		}
		
//////////////////////////////////////////////////////////////////////////////
function CheckSelection(form)	{	
//////////////////////////////////////////////////////////////////////////////
// this is for normal report upload

	//check that user has selected a value from both category and type
	if(form.CatID.value==-1)	{alert("Please select a category first"); return false;}
	if(form.ReportID.value==-1) {alert("Please select a report type"); return false;}

	//validate date entered
	var DateMsg = "Please enter a correct Date value.\n\nThe date must be of the form YYYY/MM/DD"
	var ReportDate = form.ReportDate.value
	var RptStr = ReportDate.split("/")
	if(ReportDate.length != 10)	{alert(DateMsg); return false;}
	if(ReportDate.charAt(4) != "/" && ReportDate.charAt(7) != "/")	{alert(DateMsg); return false;}
	if(isNaN(parseInt(RptStr[0])) || isNaN(parseInt(RptStr[1])) || isNaN(parseInt(RptStr[2])))	{alert(DateMsg); return false;}
	if(RptStr[0] < 2002 || RptStr[1] < 1 || RptStr[1] > 12 || RptStr[2] < 1 || RptStr[2] > 31)	{alert(DateMsg); return false;}
	
	// need a publication reason if version > 1 OR Category is 'Allocation General' or 'Vessel Reports'
	var ReportCategory = form.CatID;
	var SelectedCategory = ReportCategory.options[ReportCategory.options.selectedIndex].text;
	if(SelectedCategory=="Notices" || SelectedCategory=="Vessel Reports") {
		if(form.RepubReason.value.length==0)         {alert("Please enter a reason for publication or re-publication"); return false;}
		else if(form.RepubReason.value.length > 200) {alert("Reason can only be 200 characters long. You currently have " + form.RepubReason.value.length + " characters entered."); return false;}
	}

	//need to validate that user has selected a file
	form.File1.focus();
	if(form.File1.value == "")	{alert("Please select a file first"); return false;}

	//user has selected all three fields
	form.submit()
		
} // CheckSelection()
		function CheckDeleteSelection(form)	{	//upload for deleted report

			//check that user has entered a reason for delete
				if(form.ReasonDelete.value == "")	{alert("Please Enter a reason for deleting this report"); return false;}

			//find out if user wants to replace the report
				if(form.ReplaceYN[1].checked)	{form.ReplaceReport.value = "0"}
				else	{
					form.ReplaceReport.value = "1"
				//check that user has selected a value from both category and type
					if(form.CatID.value==-1)	{alert("Please select a category first"); return false;}
					if(form.ReportID.value==-1) {alert("Please select a report type"); return false;}

				//validate date entered
				var DateMsg = "Please enter a correct Date value.\n\nThe date must be of the form YYYY/MM/DD"
				var ReportDate = form.ReportDate.value
				var RptStr = ReportDate.split("/")
					if(ReportDate.length != 10)	{alert(DateMsg); return false;}
					if(ReportDate.charAt(4) != "/" && ReportDate.charAt(7) != "/")	{alert(DateMsg); return false;}
					if(isNaN(parseInt(RptStr[0])) || isNaN(parseInt(RptStr[1])) || isNaN(parseInt(RptStr[2])))	{alert(DateMsg); return false;}
					if(RptStr[0] < 2002 || RptStr[1] < 1 || RptStr[1] > 12 || RptStr[2] < 1 || RptStr[2] > 31)	{alert(DateMsg); return false;}
					if(form.File1.value == "")	{alert("Please select a file first"); return false;}

				// need a publication reason if version > 1 OR Category is 'Allocation General' or 'Vessel Reports'
				var ReportCategory = form.CatID;
				var SelectedCategory = ReportCategory.options[ReportCategory.options.selectedIndex].text;
				if(SelectedCategory=="Notices" || SelectedCategory=="Vessel Reports"  ) {
					if(form.RepubReason.value.length==0)         {alert("Please enter a reason for publication or re-publication"); return false;}
					else if(form.RepubReason.value.length > 200) {alert("Reason can only be 200 characters long. You currently have " + form.RepubReason.value.length + " characters entered."); return false;}
				}
					}

		if(!confirm("Are you sure you want to delete this report?")) {
		//Not sure
		 return false;	}
	else	{
		form.submit();
		}
	}
	//original scripts stolen from various parts of the old CIP - they may not be needed any more

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

	//End of original scripts stolen from various parts of the old CIP

	function OpenBig(TheURL)	{
		CourseWin=window.open(TheURL, "", "");
		CourseWin.focus();
	}

	function OpenFullScreen(TheURL)	{
		FullWin=window.open(TheURL, "", "FullScreen=Yes");
		FullWin.focus();
	}

	function SetStatusBarMsg(sMsg)	{
		window.status = sMsg;
	}
	
	function CheckPassWord(form)	{

		if(form.CurrentPass.value == "") {alert("Please enter your Current Password."); form.CurrentPass.focus(); return false;}
		if(form.NewPass1.value == "") {alert("Please enter your New Password."); form.NewPass1.focus(); return false;}
		if(form.NewPass2.value == "") {alert("Please enter your New Password."); form.NewPass2.focus(); return false;}
		if(form.NewPass1.value != form.NewPass2.value) {alert("Both new passwords must match."); form.NewPass1.focus(); form.NewPass1.value=""; form.NewPass2.value=""; return false;}
		form.submit();

		}

	function CheckIfIsEmail(form)	{
		if(form.UserEmail.value == "")	{return false;}
			else	{if(form.UserEmail.value.length < 5)	{return false;}
			else	{if(form.UserEmail.value.indexOf("@", 0) < 1 || form.UserEmail.value.indexOf("@", 0) >(form.UserEmail.value.length - 2))	{return false;}
			else	{if(form.UserEmail.value.indexOf("@", 0) == -1 || form.UserEmail.value.indexOf(".", 0) ==-1)	{return false;}
			else	{if(form.UserEmail.value.indexOf(" ", 0) == -1)	{return false;}
			else	{return true;}
				}}}}
		}

		function img_over(imgName){
			if (document.images){
			imgOn=eval(imgName+"_off.src");
			document[imgName].src=imgOn;
			}
		}

		function img_off(imgName){
			if (document.images){
			imgOff=eval(imgName+"_on.src");
			document[imgName].src=imgOff;
			}
		}

	if (document.images){
		Logout_on=new Image(106,20);
		Logout_on.src="titles/Logout_on.jpg";
		Logout_off=new Image(106,20);
		Logout_off.src="titles/Logout_off.jpg";
		}
// -->
