
function disclaimer(lang) {
          if (lang == "English") {
             alert("This page contains notices which have been released by the Canadian Coast Guard prior to the year 2000.  They are not necessarily active and are not to be relied upon.  DFO accepts no liability whatsoever for consequences resulting from any reliance upon them.");
        } else {
             alert("Cette page contient des avis qui ont été émis par la Garde côtière canadienne entre janvier 1997 et décembre 1999. Il ne sont pas nécessairement actifs et on ne doit pas s’y fier. Le MPO décline toute responsabilité pour les conséquences résultant de l’utilisation de ces données.");
        }
}

function setfocus() { 
	document.profile.userid.focus(); 
}



function checkemail(form1) {

    Ctrl = document.forms['form1'].userid;

    if(Ctrl.value == "" || Ctrl.value.indexOf("@") < 0 || Ctrl.value.indexOf(".") < 0) {

        validatePrompt (Ctrl, "Please enter a valid e-mail address.\nThis will be your Notmar profile identifier")

        return(false);

    }

            if (document.forms['form1'].pass1.value == ""){

             alert(" Please enter a password ");

             return false;

        }

        if (document.forms['form1'].pass1.value != document.forms['form1'].pass2.value){

             alert(" Passwords do not match ");

             return false;

        }   else {

        return(true);

    }

}



function validAnswers(form1) {

 if (document.forms['form1'].pass.value == ""){

      alert(" Please enter a password ");

      return false;

 }

 if (document.forms['form1'].pass.value != document.forms['form1'].pass2.value){

      alert(" Passwords do not match ");

      return false;

 }

 else{

      return true;

 }

}



function helpWindow(file) {

        window.open(file,'email','toolbar=no,width=400,height=300,directories=no,scrollbars=no,resizable=no,menubar=no,status=no')

}



function gotocharts(form) {	

	var product = document.forms['f'].product.options[document.forms['f'].product.selectedIndex].value;

	

}



function testEmail(form1) {

    Ctrl = document.forms['form1'].userid;

    if(Ctrl.value == "" || Ctrl.value.indexOf("@") < 0 || Ctrl.value.indexOf(".") < 0) {

        validatePrompt (Ctrl, "Please enter a valid e-mail address.\nThis will be your Notmar profile identifier")

        return(false);

    } else {

        return(true);

    }

}


function validPassword(form1) {

 if (document.forms['form1'].pass1.value == ""){

      alert(" Please enter a password ");

      return false;

 }

 if (document.forms['form1'].pass1.value != document.forms['form1'].pass2.value){

      alert(" Passwords do not match ");

      return false;

 }

 else{

      return true;

 }

}



function validPasswoprdLogin(form1) {

 if (document.forms['form1'].pass.value == ""){

      alert(" Please enter a password ");

      return false;

 }

 else{

      return true;

 }

}

function runSubmitLogin (form1) {

        if(!testEmail(document.forms['form1'])){

         return(false);

        }
		
        if(! validPasswoprdLogin(document.forms['form1'])){

         return(false);

        }


        else {

            return(true);

        }

}

function runSubmit (form1) {

        if(!testEmail(document.forms['form1'])){

         return(false);

        }
		
        if(! validPassword(document.forms['form1'])){

         return(false);

        }


        else {

            return(true);

        }

}

function runSubmitDelete (form1) {

		Ctrl = document.forms['form1'].user;
		
		if(Ctrl.value == "" || Ctrl.value.indexOf("@") < 0 || Ctrl.value.indexOf(".") < 0) {
		
			validatePrompt (Ctrl, "Please enter a valid e-mail address.\n")
		
			return(false);
		
		}
		
		if (document.forms['form1'].pass1.value == ""){
		
			alert(" Please enter a password ");
				
			return false;
		
		}


        else {

			var agree=confirm("Are you sure you want to delete your Notmar Profile?");
			if (agree)
				return true ;
			else
				return false ;

        }

}

function validatePrompt (Ctrl, PromptStr) {

        alert (PromptStr)

        Ctrl.focus();

        return(true);

}



function MM_openBrWindow(theURL,winName,features) { //v2.0

     window.open(theURL,winName,features);

}


function SelectAll(fieldName){

var checker = true;

var len = document.forms['f'].elements.length;

    for (var i=0; i<len; i++){

         var e = document.forms['f'].elements[i];

         e.checked = checker;

    }

}


function deSelectAll(fieldName){

var checker = false;

var len = document.forms['f'].elements.length;

    for (var i=0; i<len; i++){

         var e = document.forms['f'].elements[i];

         e.checked = checker;

    }

}

function atleastone_chart(form1) { 

	atleastonechart = 0;
	
	for (var i=0; i < document.forms['form1'].product.length; i++) {
						
		thisbox = "c"+document.forms['form1'].product.options[i].value;	

		if(document.getElementById(i)) {
			atleastonechart = 1;
			i = document.forms['form1'].product.length;
		}   
		
	}
	
	if(atleastonechart == 0) {
		alert("You must add at least one chart to create a profile");
	 	return(false);

	} else {
		
		return(true);

	}
}


	function showNotice(form1) {
		NoticeChoice = document.forms['form1'].noticesSelect.selectedIndex; 
		if (document.forms['form1'].noticesSelect[NoticeChoice].value != ""){
			noticeChange = document.forms['form1'].noticesSelect[NoticeChoice].value;
			window.location.href = noticeChange;
		}
	}
	
	 var printthelist=new Array();

	
	
	
// function to check the checkboxes and make them appear based on the selectbox   
 	function showCheckbox() {	
	
	theselectedoptions = document.forms['form1'].product.selectedIndex;
	printthis="<table border='0' width='400'><tr>";

			printthelist[0] = "";
			cellcounter = 0;
			for (var i=0; i < document.forms['form1'].product.length; i++) {
			
				if(document.forms['form1'].product.options[i].selected == true) {
							
					thisboxlabel = document.forms['form1'].product.options[i].text;
					thisbox = "c"+document.forms['form1'].product.options[i].value;	
					
					if(document.getElementById(thisbox)) {

					} else {
						printthelist[i] = "<td align='center'>"+thisboxlabel+"<br><input id=\""+i+"\" type=\"checkbox\" name=\""+thisbox+"\" value=\""+thisbox+"\" checked></td>";
						
					}					
				
				}
				if( printthelist[i]) {
					printthis += printthelist[i];
						cellcounter++;
						if(cellcounter > 6){
							printthis += "</tr><tr>";
							cellcounter = 0;
						}				
						
				}
			//}
			
						 
		} 
		printthis+="</tr></table>";
		
		  if (document.all){
               document.all.chartListing.innerHTML = printthis;
          }
          if(!document.all && document.getElementById){
               document.getElementById("chartListing").innerHTML = printthis;
          }
		  /*
          if(document.layers){
                    chartListing = document.layers["chartListing"];
                    chartListing.document.open();
                    chartListing.document.write(printthis);
                    chartListing.document.close();
          }
		 */
	}  		
	
// function to check the checkboxes and make them appear based on the selectbox   
 	function showCheckbox2(form1) {	
	
	//theselectedoptions = document.form1.product.options[document.form1.product.selectedIndex].value;
	//alert("Selected Charts: "+theselectedoptions);
	theselectedoptions = document.forms['form1'].product.selectedIndex;
		printthis="";
		
		if(document.forms['form1'].product.options[0].selected == true) {			
			thisboxlabel = document.forms['form1'].product.options[0].text;
			thisbox = "c"+document.forms['form1'].product.options[0].value;	
			startloop = "0";
				
			//printthelist[0] = thisboxlabel+"<input id=\"0\" type=\"checkbox\" name=\""+thisbox+"\" value=\"all\" onClick=\"uncheckCharts(form1,'"+thisbox+"',"+startloop+")\" checked>";
			printthelist[0] = thisboxlabel+"<input id=\"0\" type=\"checkbox\" name=\""+thisbox+"\" value=\"all\" checked>";	
	
			printthis += printthelist[0]; 
			for (var i=1; i< document.forms['form1'].product.length; i++) {											
					if(printthelist[i]){
						printthelist[i] = ""; 
					}
			}	
					
		} else {
			printthelist[0] = "";
			for (var i=1; i < document.forms['form1'].product.length; i++) {
			
				if(document.forms['form1'].product.options[i].selected == true) {
							
					thisboxlabel = document.forms['form1'].product.options[i].text;
					thisbox = "c"+document.forms['form1'].product.options[i].value;	
					
					if(document.getElementById(thisbox)) {

					} else {
						//printthelist[i] = thisboxlabel+"<input id=\""+i+"\" type=\"checkbox\" name=\""+thisbox+"\" value=\""+thisbox+"\" onClick=\"uncheckCharts(form1,'"+thisboxlabel+"',"+i+")\" checked>";
						printthelist[i] = thisboxlabel+"<input id=\""+i+"\" type=\"checkbox\" name=\""+thisbox+"\" value=\""+thisbox+"\" checked>";
						//alert(printthelist[i]);
					}

				
				}
				if( printthelist[i]) {
					printthis += printthelist[i]; 
				}
			}

						 
		} 
		
		
		  if (document.all){
               document.all.chartListing.innerHTML = printthis;
          }
          if(!document.all && document.getElementById){
               document.getElementById("chartListing").innerHTML = printthis;
          }
		  /*
          if(document.layers){
                    chartListing = document.layers["chartListing"];
                    chartListing.document.open();
                    chartListing.document.write(printthis);
                    chartListing.document.close();
          }
		 */
	}  		
		
// function to uncheck the chart checkboxes and make them disappear
	function uncheckCharts2(form1,deleteChartLabel,labelNum) {
	
	
	//alert(deleteChartLabel);
		deleteChart = "c" + deleteChartLabel;
		
		if(labelNum == "0"){
			deleteChart = "call";		
			printthelistDel = "Select All Charts<input id=\"0\" type=\"checkbox\" name=\"call\" value=\"all\" checked>";		
		
		} else {										
			printthelistDel = deleteChartLabel+"<input id=\""+labelNum+"\" type=\"checkbox\" name=\""+deleteChart+"\" value=\""+deleteChart+"\" checked>";										
			
			//alert(printthelistDel);
		}
		printthis = (printthis.replace(printthelistDel, ""));
		printthelist[labelNum] = "";
		
		document.forms['form1'].product.options[labelNum].selected = false;
		
		  if (document.all){
               document.all.chartListing.innerHTML = printthis;
          }
          if(!document.all && document.getElementById){
               document.getElementById("chartListing").innerHTML = printthis;
          }

	}				
	

	
// function to uncheck the chart checkboxes and make them disappear
	function uncheckCharts(form1,deleteChartLabel,labelNum) {
	
		deleteChart = "c" + deleteChartLabel;
		printthelist[labelNum] = "";
		
		document.getElementById(labelNum).checked = false;		
		document.forms['form1'].product.options[labelNum].selected = false;
		
		thisboxlabel = document.forms['form1'].product.options[labelNum].text;
		thisbox = "c"+document.forms['form1'].product.options[labelNum].value;
					
		printthelistcheck = "<td align='center'>"+thisboxlabel+"<br><input id=\""+labelNum+"\" type=\"checkbox\" name=\""+thisbox+"\" value=\""+thisbox+"\" onClick=\"uncheckCharts(form1,'"+thisboxlabel+"',"+labelNum+")\" checked></td>";

		var printthis2 = printthis.split(printthelistcheck);
		checkCount = printthis2[0].split("br");
	    printthis=printthis2[0];
		
			cellcountrows = (checkCount.length % 7); 
			
			if(cellcountrows > 0) {
				cellcounter = cellcountrows;
			} else {
			
				cellcounter = 7;
			}
			//alert(labelNum+"  "+document.form1.product.length);
			for (var i=labelNum; i < document.forms['form1'].product.length; i++) {
					thisboxlabel = document.forms['form1'].product.options[i].text;
					thisbox = "c"+document.forms['form1'].product.options[i].value;
										
					if(document.getElementById(i)) {
						if(document.getElementById(i).checked == true) {
							//printthelist[i] = "<td align='center'>"+thisboxlabel+"<br><input id=\""+i+"\" type=\"checkbox\" name=\""+thisbox+"\" value=\""+thisbox+"\" onClick=\"uncheckCharts(form1,'"+thisboxlabel+"',"+i+")\" checked></td>";
							//alert(printthelist[i]);
						}
					} 	
				
				
				if( printthelist[i]) {
					printthis += printthelist[i];
						
					if(cellcounter > 6){
						printthis += "</tr><tr>";
						cellcounter = 0;
					}				
					cellcounter++;
				}
			}
					
		   //alert(printthis);
		
		  printthis+="</tr></table>";

		
		  if (document.all){
               document.all.chartListing.innerHTML = printthis;
          }
          if(!document.all && document.getElementById){
               document.getElementById("chartListing").innerHTML = printthis;
          }
		
	}
		
// function to setup the checkboxes when the page first loads
	function setupCheckboxes() {
			
		for (var i=0; i<document.forms['form1'].product.length; i++) {	
				printthelist[i] = "";		
		}		
		
	}   
	
	
// function to setup the checkboxes when the page first loads
	function PresetupCheckboxes() {
	//showalljsstuff="";
		
		for (var i=0; i<document.forms['form1'].product.length; i++) {		
		
		
			printthelist[i] = "";		
			//showalljsstuff += "printthelist["+i+"] = '';<br>";
		}		
		
		
		  if (document.all){
               document.all.chartListing.innerHTML = printthis;
          }
          if(!document.all && document.getElementById){
               document.getElementById("chartListing").innerHTML = printthis;
          }
		  
	}  	


// function to uncheck the chart checkboxes and make them disappear
	function uncheckChartstest(form1) {

			printthis="<table border='0' width='400'><tr>";
			cellcountrows =1;
			
			if(cellcountrows > 0) {
				cellcounter = cellcountrows;
			} else {
			
				cellcounter = 7;
			}
			//alert(labelNum+"  "+document.form1.product.length);
			for (var i=1; i < document.forms['form1'].product.length; i++) {
					thisboxlabel = document.forms['form1'].product.options[i].text;
					thisbox = "c"+document.forms['form1'].product.options[i].value;
										
					if(document.getElementById(i)) {
						if(document.getElementById(i).checked == true) {
							printthelist[i] = "<td align='center'>"+thisboxlabel+"<br><input id=\""+i+"\" type=\"checkbox\" name=\""+thisbox+"\" value=\""+thisbox+"\" checked></td>";
							//alert(printthelist[i]);
						} else {
							//alert(thisbox);
							printthelist[i] = "";
						}
					} 	
				
				
				if( printthelist[i]) {
					printthis += printthelist[i];
						
					if(cellcounter > 6){
						printthis += "</tr><tr>";
						cellcounter = 0;
					}				
					cellcounter++;
				}
			}
					
		   //alert(printthis);
		
		  printthis+="</tr></table>";

		
		  if (document.all){
               document.all.chartListing.innerHTML = printthis;
          }
          if(!document.all && document.getElementById){
               document.getElementById("chartListing").innerHTML = printthis;
          }
		
	}