// ===========================================
//  function copyright
//  Displays text content which includes current 
//  year UNLESS start year = current year.
//  
//  Usage:
//  <script type="text/javascript">copyright(site_owner,start_year);</script>
// ===========================================

function copyright(site_owner,start_year){
document.write('<a target="_blank" href="./content/docs/Celerus_602019_Certificate ISO 13485.pdf">ISO 13485:2003 Certified</a><br />');
d=new Date();y=d.getFullYear();
if (start_year==y) {
document.write("Copyright\&nbsp\;\&copy\;\&nbsp\;"+y+"\&nbsp\;"+site_owner+".");
}else{
document.write("Copyright\&nbsp\;\&copy\;\&nbsp\;"+start_year+"-"+y+"\&nbsp\;"+site_owner+".");
}
document.close();
}



function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}


// ===========================================
//   checks if a required form field is empty.
// ===========================================
function checkrequired( thisform ){
var noinfo = false;
var resp = "";
if( thisform.name.value == '' ){noinfo = true;resp += "Name\n";}
if( thisform.email.value == '' ){noinfo = true;resp += "Email\n";}
if( noinfo ) {alert( "Please complete the following field(s) before continuing:\n" + resp );return false;}
return true;
}


// ===========================================
//   checks if a required form field is empty.
// ===========================================
function _checkrequired(which){
	var pass=true

	if (document.images){
		for (i=0;i<which.length;i++){
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required"){
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
					pass=false;
					break;
				}
			}
		}
	}

	if (!pass){
		alert("One or more of the required elements are not completed. Please complete them, then submit again!");
		return false;
	} else {
		return true;
	}
}



// ===========================================
//   Replaces the a character with its html entity.
// ===========================================
function html2entities(){
	var re=/[(<>"'&]/g
	for (i=0; i<arguments.length; i++)
	arguments[i].value=arguments[i].value.replace(re, function(m){return replacechar(m)})
}

function replacechar(match){
	if (match=="<")
	return "&lt;"
	else if (match==">")
	return "&gt;"
	else if (match=="\"")
	return "&quot;"
	else if (match=="'")
	return "&#039;"
	else if (match=="&")
	return "&amp;"
}



