/* 
  ------------------------------------------------
  TabBar Magic menu scripts
  Copyright (c) 2005-2006 Project Seven Development
  www.projectseven.com
  Version: 1.0.5 
  ------------------------------------------------
*/

var hmenuona=new Array();
var hmenuont=new Array();

function horizontal_drop(){ //v1.0.2 by PVII-www.projectseven.com
 //define over and down image suffix
 var Iv = "_f2";
 var Id = "_f3";
 var i,j,x,k,d,nV,tB,tbs,iM,im,ts,tA,sA,nA=new Array();
 document.hmenuonsw=new Array();hmenuona=arguments;
 if(!document.getElementById||document.hmenuonf){return;}
 tb=document.getElementById('hmenuon');if(!tb){return;}tb.onmouseout=hmenuonclose;
 tB=document.getElementById('hmenuon');nV=document.getElementById('hmenuonroot');
 if(!nV||!tB){return;}tA=nV.getElementsByTagName('A');j=0;for(i=0;i<tA.length;i++){
 hmenuont[j]=tA[i].id;j++;d='hmenuonsub'+tA[i].id.replace('hmenuont','');
 tbs=document.getElementById(d);if(tbs){tbs.onmouseover=function(){hmenuonsub(this);};}
 hmenuont[j]=(tbs)?tbs.id:false;tA[i].hasSub=hmenuont[j];j++;tA[i].isRoot=true;
 tA[i].onclick=function(){return hmenuontrig(this);};
 tA[i].onmouseover=function(){hmenuonovr(this);};tA[i].hmenuonstate=0;tA[i].hasIm=false;
 iM=tA[i].getElementsByTagName('IMG');if(iM&&iM[0]){im=iM[0];ts=im.getAttribute("src");
 x=ts.lastIndexOf(".");nA[0]=ts.substring(0,x);nA[1]='.'+ts.substring(x+1);
 im.hmenuonmimg=new Array();im.hmenuonmimg[0]=ts;if(hmenuona[1]>1){ts=nA[0]+Iv+nA[1];
 hmenuonpl(ts);}im.hmenuonmimg[1]=ts;if(hmenuona[1]==3){im.hmenuonmimg[2]=ts;}
 if(hmenuona[1]==1||hmenuona[1]==2){ts=nA[0]+Id+nA[1];hmenuonpl(ts);if(hmenuona[1]==1){
 im.hmenuonmimg[1]=ts;}}im.hmenuonmimg[2]=ts;im.hmenuonstate=0;tA[i].hasIm=true;}}
 document.hmenuonf=true;hmenuonopen();
}

function hmenuonpl(ims){ //v1.0.2 by PVII-www.projectseven.com
 var x=document.hmenuonsw.length;document.hmenuonsw[x]=new Image();document.hmenuonsw[x].src=ims;
}

function hmenuonovr(a){ //v1.0.2 by PVII-www.projectseven.com
 if(!document.hmenuonf){return;}if(document.hmenuontm){clearTimeout(document.hmenuontm);}hmenuonswp(a);
 if(hmenuona[0]==1){document.hmenuontm=setTimeout("hmenuonshow('"+a.id+"')",hmenuona[4]);
 }else{hmenuonshow(a.id);}
}

function hmenuonswp(d){ //v1.0.2 by PVII-www.projectseven.com
 var i,cl,a;for(i=0;i<hmenuont.length;i+=2){a=document.getElementById(hmenuont[i]);
 cl=a.className;if(hmenuont[i]!=d.id){if(a.hmenuonstate<2){if(cl.indexOf("hmenuonon")>-1){
 a.className=cl.replace("hmenuonon",'');}if(a.hasIm){im=a.getElementsByTagName('IMG')[0];
 if(im.hmenuonstate<2){im.src=im.hmenuonmimg[0];}}}}else{if(a.hmenuonstate!=2){if(cl.indexOf("hmenuonon")==-1){
 a.className=(cl&&cl.length>0)?cl+" hmenuonon":"hmenuonon";}if(a.hasIm){
 im=a.getElementsByTagName('IMG')[0];if(im.hmenuonstate<2){im.src=im.hmenuonmimg[1];}}}}}
}

function hmenuonshow(d){ //v1.0.5 by PVII-www.projectseven.com
 var a,i,im,cl;a=document.getElementById(d);if(a.hasIm){im=a.getElementsByTagName('IMG')[0];
 if(im.hmenuonstate==0){im.src=im.hmenuonmimg[1];im.hmenuonstate=1;}}if(a.hasSub){if(a.hmenuonstate!=2){
 a.hmenuonstate=1;cl=a.className;if(cl.indexOf("hmenuonon")==-1){
 a.className=(cl&&cl.length>0)?cl+" hmenuonon":"hmenuonon";}}
 document.getElementById(a.hasSub).style.visibility="visible";}hmenuontg(a);
}

function hmenuontg(d){ //v1.0.2 by PVII-www.projectseven.com
 var i,im,s,cl;for(i=0;i<hmenuont.length;i+=2){if(!d||hmenuont[i]!=d.id){
 a=document.getElementById(hmenuont[i]);if(a.hasIm){im=a.getElementsByTagName('IMG')[0];
 if(im.hmenuonstate<2){im.src=im.hmenuonmimg[0];im.hmenuonstate=0;}}if(a.hmenuonstate!=2){a.hmenuonstate=0;
 cl=a.className;if(cl.indexOf("hmenuonon")>-1){a.className=cl.replace("hmenuonon",'');}}
 s=document.getElementById(hmenuont[i+1]);if(s){s.style.visibility="hidden";}}}
}

function hmenuontrig(a){ //v1.0.2 by PVII-www.projectseven.com
 var h,hh,ret=false;hmenuondown(a);h=a.href;hh='javascript:; javascript:void(0)';
 if(hmenuona[3]==1){if(h.charAt(h.length-1)=='#'||document.location.href==h){
 ret=false;}else{ret=(hh.indexOf(h)>-1)?false:true;}}else{ret=false;}return ret;
}

function hmenuondown(a){ //v1.0.2 by PVII-www.projectseven.com
 var i,aa,im,cl;for(i=0;i<hmenuont.length;i+=2){aa=document.getElementById(hmenuont[i]);
 aa.hmenuonstate=0;aa.className=hmenuon_trim(aa.className.replace("hmenuondown",''));if(aa.hasIm){
 im=aa.getElementsByTagName('IMG')[0];im.hmenuonstate=0;}}a.hmenuonstate=2;if(a.hasIm){
 im=a.getElementsByTagName('IMG')[0];im.hmenuonstate=2;im.src=im.hmenuonmimg[2];}else{cl=a.className;
 a.className=(cl&&cl.length>0)?cl+" hmenuondown":"hmenuondown";}hmenuonshow(a.id);
}
function hmenuon_trim(t){ //v1.0.2 by PVII-www.projectseven.com
 t=t.replace(/^\s/,'');t=t.replace(/\s$/,'');return t;
}

function hmenuonclose(evt){ //v1.0.2 by PVII-www.projectseven.com
 var i,pp,tS,d,p,f,m=true;evt=(evt)?evt:((event)?event:null);if(evt){
 tS=(evt.relatedTarget)?evt.relatedTarget:evt.toElement;if(tS){pp=tS;
 while(pp){if(pp.id){d=pp.id;if(pp.id.indexOf("hmenuon")>-1){m=false;break;}}
 pp=pp.parentNode;}if(m){f='hmenuontg()';if(hmenuona[2]==1){for(i=0;i<hmenuont.length;i+=2){
 p=document.getElementById(hmenuont[i]);if(p.hmenuonstate==2){f="hmenuonshow('"+p.id+"')";}}}
 if(hmenuona[0]==1){eval('document.hmenuontm=setTimeout("'+f+'",'+parseInt(hmenuona[4]+50)+')');
 }else{eval(f);}}}}
}

function hmenuonsub(s){ //v1.0.2 by PVII-www.projectseven.com
 if(document.hmenuontm){clearTimeout(document.hmenuontm);}
 var d=s.id.replace("hmenuonsub","hmenuont"),a=document.getElementById(d);
 hmenuonswp(a);
}

function hmenuonark(){document.hmenuonop=arguments;}

function hmenuonopen(){ //v1.0.2 by PVII-www.projectseven.com
 var x,i,j,k,kk,wH,tM,tA,pp,cl,a,nd,op,r1,aU;wH=window.location.href;
 var mt = new Array(1,'','');if(document.hmenuonop){mt=document.hmenuonop;}op=mt[0];
 if(op<1){return;}r1=/index\.[\S]*/i;k=-1,kk=-1;tM=document.getElementById('hmenuon');
 tA=tM.getElementsByTagName("A");for(j=0;j<tA.length;j++){aU=tA[j].href.replace(r1,'');
 if(op>0){if(tA[j].href==wH||aU==wH){k=j;kk=-1;
 // tweak to allow last link found
 //break;
 //end tweak
 }}if(op==2){if(tA[j].firstChild){
 if(tA[j].firstChild.nodeValue==mt[1]){kk=j;}}}if(op==3 && tA[j].href.indexOf(mt[1])>-1){
 kk=j;}if(op==4){for(x=1;x<mt.length;x+=2){if(wH.indexOf(mt[x])>-1){
 if(tA[j].firstChild&&tA[j].firstChild.nodeValue){if(tA[j].firstChild.nodeValue==mt[x+1]){
 kk=j;}}}}}}k=(kk>k)?kk:k;if(k>-1){a=false;if(!tA[k].hasIm&&!tA[k].isRoot){cl=tA[k].className;
 tA[k].className=(cl&&cl.length>0)?cl+" hmenuonmark":"hmenuonmark";}pp=tA[k].parentNode;
 while(pp){if(pp.id&&pp.id=='hmenuonroot'){a=tA[k];break;}if(pp.id&&pp.id.indexOf('hmenuonsub')>-1){
 nd='hmenuont'+pp.id.replace('hmenuonsub','');a=document.getElementById(nd);break;}
 pp=pp.parentNode;}if(a){hmenuondown(a);}}
}

function initARC(formId,onClassRadio,offClassRadio,onClassCheckbox,offClassCheckbox) {
    var agt=navigator.userAgent.toLowerCase();

    // Browser Detection stuff
    this.major = parseInt(navigator.appVersion);
    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
	this.iemac  = (this.ie && (agt.indexOf("mac")!=-1));

	if( !(this.iemac || ie3 || ie4) ){
		customiseInputs(formId,onClassRadio,offClassRadio,onClassCheckbox,offClassCheckbox);
	}
}


//Add a .label reference to all input elements. Handy! Borrowed from...
//http://www.codingforums.com/archive/index.php/t-14672
function addLabelProperties(f){
	if(typeof f.getElementsByTagName == 'undefined') return;
	var labels = f.getElementsByTagName("label"), label, elem, i = j = 0;
	
	while (label = labels[i++]){
		if(typeof label.htmlFor == 'undefined') return;
		elem = document.getElementById(label.htmlFor);
		//elem = f.elements[label.htmlFor]; /* old method */
		
		if(typeof elem == 'undefined'){
			//no label defined, find first sub-input
			var inputs = label.getElementsByTagName("input");
			if(inputs.length==0){
				continue;
			} else {
				elem=inputs[0];
			}
		} else if(typeof elem.label != 'undefined') { // label property already added
			continue;
		} else if(typeof elem.length != 'undefined' && elem.length > 1 && elem.nodeName != 'SELECT'){
			for(j=0; j<elem.length; j++){
				elem.item(j).label = label;
			}
		}
		elem.label = label;
	}
} 



/**
NAME: toggleLabelStyle()

ABOUT:
 This function is attached to our label's onClick event. So when the label is
 clicked this function alters the radio group's members to an unchecked state
 and style, and alters the currently selected label to the on style and checked
 state.

USAGE:
 ARC currently assumes that the label contains a FOR='id' in it's HTML. The other
 valid form of a label is <label>text <input /></label> - while it is possible
 to modify this code to allow for this form I have left this as an exercise for
 the reader.
 
PARAMS:
 formId   - Parent form of this label
 label    - The label for a radio button we wish to toggle
 onClass  - The CSS class name for the radio button's on style
 offClass - The CSS class name for the radio button's off style
*/
function toggleLabelStyle(formId, label, onClass, offClass){
	if(!document.getElementById || !label) return;
		
	var form = document.getElementById(formId); //label.form;
	if(!form) return;
	
	//find radio associated with label (if in htmlFor form)
	if(label.htmlFor) {
		var e = document.getElementById(label.htmlFor);
		
		if(e.type=="checkbox"){
			e.label.className = (e.label.className==onClass) ? offClass : onClass;
			e.checked = (e.label.className==onClass);
		}
	}
}


// ADAMS's RADIO CUSTOMISATION
// adam.burmister@gmail.com, Copyright 2005.


/**
NAME: initARC()

ABOUT:
 Detects the current user browser and customises the form's radio buttons if
 the browser is not IE mac, <= IE 4 or NS4.

USAGE:
 In your main HTML body use onLoad() to call initARC(), passing in the form id
 and on/off class names you wish to use to customise your radio buttons.
 e.g. <body onLoad="initARC('myform','radioOn', 'radioOff');">
 
PARAMS:
 formId   - The ID of the form you wish to customise
 onClass  - The CSS class name for the radio button's on style
 offClass - The CSS class name for the radio button's off style
*/
function initARC(formId,onClassRadio,offClassRadio,onClassCheckbox,offClassCheckbox) {
    var agt=navigator.userAgent.toLowerCase();

    // Browser Detection stuff
    this.major = parseInt(navigator.appVersion);
    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
	this.iemac  = (this.ie && (agt.indexOf("mac")!=-1));

	if( !(this.iemac || ie3 || ie4) ){
		customiseInputs(formId,onClassRadio,offClassRadio,onClassCheckbox,offClassCheckbox);
	}
}



//Add a .label reference to all input elements. Handy! Borrowed from...
//http://www.codingforums.com/archive/index.php/t-14672
function addLabelProperties(f){
	if(typeof f.getElementsByTagName == 'undefined') return;
	var labels = f.getElementsByTagName("label"), label, elem, i = j = 0;
	
	while (label = labels[i++]){
		if(typeof label.htmlFor == 'undefined') return;
		elem = document.getElementById(label.htmlFor);
		//elem = f.elements[label.htmlFor]; /* old method */
		
		if(typeof elem == 'undefined'){
			//no label defined, find first sub-input
			var inputs = label.getElementsByTagName("input");
			if(inputs.length==0){
				continue;
			} else {
				elem=inputs[0];
			}
		} else if(typeof elem.label != 'undefined') { // label property already added
			continue;
		} else if(typeof elem.length != 'undefined' && elem.length > 1 && elem.nodeName != 'SELECT'){
			for(j=0; j<elem.length; j++){
				elem.item(j).label = label;
			}
		}
		elem.label = label;
	}
} 



/**
NAME: toggleLabelStyle()

ABOUT:
 This function is attached to our label's onClick event. So when the label is
 clicked this function alters the radio group's members to an unchecked state
 and style, and alters the currently selected label to the on style and checked
 state.

USAGE:
 ARC currently assumes that the label contains a FOR='id' in it's HTML. The other
 valid form of a label is <label>text <input /></label> - while it is possible
 to modify this code to allow for this form I have left this as an exercise for
 the reader.
 
PARAMS:
 formId   - Parent form of this label
 label    - The label for a radio button we wish to toggle
 onClass  - The CSS class name for the radio button's on style
 offClass - The CSS class name for the radio button's off style
*/
function toggleLabelStyle(formId, label, onClass, offClass){
	if(!document.getElementById || !label) return;
		
	var form = document.getElementById(formId); //label.form;
	if(!form) return;
	
	//find radio associated with label (if in htmlFor form)
	if(label.htmlFor) {
		var e = document.getElementById(label.htmlFor);
		
		if(e.type=="checkbox"){
			e.label.className = (e.label.className==onClass) ? offClass : onClass;
			e.checked = (e.label.className==onClass);
		} else if(e.type=="radio"){
			var radioGroup = form.elements[e.name];
			if(!radioGroup) return;
			
			for(var i=0; i<radioGroup.length; i++){
				if(radioGroup[i].label){
					radioGroup[i].label.className = ((radioGroup[i].checked=(radioGroup[i].id == e.id))
													 && radioGroup[i].label) ? onClass : offClass;
				}
			}
		}
	}
}



/**
NAME: customiseInputs()

ABOUT:
 This function does all the magic. It finds the <input>'s within the passed form
 and attaches a .label reference to the element, and also adds an onClick
 function to that label to the toggleLabelStyle() function.
 It hides all radio elements from the form and mirrors the startup checked values
 in the label's customised radio button styles.

USAGE:
 Called from initARC()
 
PARAMS:
 formId   - The form we're customising
 onClass  - The CSS class name for the radio button's on style
 offClass - The CSS class name for the radio button's off style
*/
function customiseInputs(formId, onClassRadio, offClassRadio, onClassCheckbox, offClassCheckbox) {
	if(!document.getElementById) return;

	var prettyForm = document.getElementById(formId);
	if(!prettyForm) return;
		
	//onReset, reset radios to initial values
	prettyForm.onreset = function() { customiseInputs(formId, onClassRadio, offClassRadio, onClassCheckbox, offClassCheckbox); }
	
	//attach an easy to access .label reference to form elements
	addLabelProperties(prettyForm);

	var inputs = prettyForm.getElementsByTagName('input');
	for (var i=0; i < inputs.length; i++) {
		/* NB: Yeah, i know this code is duplicated - I can't figure out how to create a local, persistent
			variable within the anonymous function calls. Fix it if you can, and let me know. */
			
		//RADIO ONLY
		if( (inputs[i].type=="radio") && inputs[i].label && onClassRadio && offClassRadio){
			//hide element
			inputs[i].style.position="absolute"; inputs[i].style.left = "-1000px";
			//initialise element
			inputs[i].label.className=offClassRadio;
			//when the label is clicked, call toggleLabelStyle and toggle the label
			inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassRadio, offClassRadio); return false; };
			//enable keyboard navigation
			inputs[i].onclick = function (){ toggleLabelStyle(formId, this.label, onClassRadio, offClassRadio); };
			//if the radio was checked by default, change this label's style to checked
			if(inputs[i].defaultChecked || inputs[i].checked){ toggleLabelStyle(formId, inputs[i].label, onClassRadio, offClassRadio); }
		}
		
		//CHECKBOX ONLY
		if( (inputs[i].type=="checkbox") && inputs[i].label && onClassCheckbox && offClassCheckbox){
			//hide element
			inputs[i].style.position="absolute"; inputs[i].style.left = "-1000px";
			//initialise element
			inputs[i].label.className=offClassCheckbox;
			inputs[i].checked = false;
			//when the label is clicked, call toggleLabelStyle and toggle the label
			inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassCheckbox, offClassCheckbox); return false; };
			//enable keyboard navigation
			inputs[i].onclick = function (){ toggleLabelStyle(formId, this.label, onClassCheckbox, offClassCheckbox); };
			//if the radio was checked by default, change this label's style to checked
			if(inputs[i].defaultChecked || inputs[i].checked){ toggleLabelStyle(formId, inputs[i].label, onClassCheckbox, offClassCheckbox); }
		}

		if( (inputs[i].type=="checkbox") || (inputs[i].type=="radio") && inputs[i].label ){
			//Attach keyboard navigation
			if(!this.ie){ //IE has problems with this method
				//You could set these to grab a passed in class name if you wanted to
				//do something a bit more interesting for keyboard states. But for now the
				//generic dotted outline will do for most elements.
				inputs[i].label.style.margin = "1px";
				inputs[i].onfocus = function (){ this.label.style.border = "1px dotted #333"; this.label.style.margin="0px"; return false; };
				inputs[i].onblur  = function (){ this.label.style.border = "none"; this.label.style.margin="1px"; return false; };
			}
		}
}
}
		if (document.all)
		document.styleSheets["buttonstyle"].addRule(".dhtmlbutton","background-color:#F8F7F7;border: 1px solid black;background-color:#F8F7F7;padding:1px;cursor:hand;")
		
		function upeffect(cur){
		if (document.all)
		cur.className='logbtn'
		}
		
		function downeffect(cur){
		if (document.all)
		cur.className='logbtn_down'
		}
		
		
		function normaleffect(cur){
		if (document.all)
		cur.className='logbtn'
}
function openMe(url) {
window.open(url,"","height=475,width=490, left=100,top=100, scrollbars=no,resizable=no,statusbar=yes,menubar=no,toolbar=no,dependent=yes")

}

function openYou(url) {
window.open(url,"","height=430,width=490, left=100,top=100, scrollbars=no,resizable=no,statusbar=yes,menubar=no,toolbar=no,dependent=yes")

}
function printMe(url) {
window.open(url,"","height=800,width=831, left=100,top=100, scrollbars=yes,resizable=yes,statusbar=yes,menubar=no,toolbar=no,dependent=yes")

}
function added(){
document.write("<a href=\"#\" onClick=\"window.opener.location = \'records.asp\'; window.close();\">")
}
function openPopUp(url, newwindow, w_width, w_height){
	xpos	= (screen.width - w_width)/2;
	ypos	= (screen.height - w_height)/2;
	window.open(url, newwindow, "width="+w_width+", height="+w_height+", left="+xpos+", top="+ypos);
}


var nbsp = 160;    // non-breaking space char
var node_text = 3; // DOM text node-type
var emptyString = /^\s*$/
var glb_vfld;      // retain vfld for timer thread

// -----------------------------------------
//                  trim
// Trim leading/trailing whitespace off string
// -----------------------------------------

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '')
};


// -----------------------------------------
//                  setfocus
// Delayed focus setting to get around IE bug
// -----------------------------------------

function setFocusDelayed(vfld)
{
  glb_vfld.focus()
}

function setfocus(vfld)
{
  glb_vfld = vfld;
  setTimeout( 'setFocusDelayed()', 100 );
}


// -----------------------------------------
//                  msg
// Display warn/error message in HTML element
// commonCheck routine must have previously been called
// -----------------------------------------

function msg(fld,     // id of element to display message in
             msgtype, // class to give element ("warn" or "error")
             message) // string to display
{
  // setting an empty string can give problems if later set to a 
  // non-empty string, so ensure a space present. (For Mozilla and Opera one could 
  // simply use a space, but IE demands something more, like a non-breaking space.)
  var dispmessage;
  if (emptyString.test(message)) 
    dispmessage = String.fromCharCode(nbsp);    
  else  
    dispmessage = message;

  var elem = document.getElementById(fld);
  elem.firstChild.nodeValue = dispmessage;  
  
  elem.className = msgtype;   // set the CSS class to adjust appearance of message
};

// -----------------------------------------
//            commonCheck
// Common code for all validation routines to:
// (a) check for older / less-equipped browsers
// (b) check if empty fields are required
// Returns true (validation passed), 
//         false (validation failed) or 
//         proceed (don't know yet)
// -----------------------------------------

var proceed = 2;  

function commonCheck    (vfld,   // element to be validated
                         ifld,   // id of element to receive info/error msg
                         reqd)   // true if required
{
  if (!document.getElementById) 
    return true;  // not available on this browser - leave validation to the server
  var elem = document.getElementById(ifld);
  if (!elem.firstChild)
    return true;  // not available on this browser 
  if (elem.firstChild.nodeType != node_text)
    return true;  // ifld is wrong type of node  

  if (emptyString.test(vfld.value)) {
    if (reqd) {
      msg (ifld, "error", "*");  
      setfocus(vfld);
	  return false;
    }
    else {
      msg (ifld, "off", "*");   // OK
	 return true;  
    }
  }
  
  return proceed;
}

// -----------------------------------------
//            validatePresent
// Validate if something has been entered
// Returns true if so 
// -----------------------------------------

function validatePresent(vfld,   // element to be validated
                         ifld )  // id of element to receive info/error msg
{
  var stat = commonCheck (vfld, ifld, true);
  if (stat != proceed) return stat;

  msg (ifld, "off", "*");  
  return true;
};

function validateEmail  (vfld,   // element to be validated
                         ifld,   // id of element to receive info/error msg
                         reqd)   // true if required
{
  var stat = commonCheck (vfld, ifld, reqd);
  if (stat != proceed) return stat;
  document.forms.bp_form.email.style.background = "#E3E3E3";
  var tfld = trim(vfld.value);  // value of field with whitespace trimmed off
  var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/
  if (!email.test(tfld)) {
    msg (ifld, "error", "*");
    setfocus(vfld);
    return false;
  }

  else {
  msg (ifld, "error", "");
  document.forms.bp_form.email.style.background = "#FFFFFF";
  return true;
  }
};
function validateTelnr  (vfld,   // element to be validated
                         ifld,   // id of element to receive info/error msg
                         reqd)   // true if required
{
  var stat = commonCheck (vfld, ifld, reqd);
  if (stat != proceed) return stat;

  var tfld = trim(vfld.value);  // value of field with whitespace trimmed off
  var telnr = /^\+?[0-9 ()-]+[0-9]$/
  if (!telnr.test(tfld)) {
    msg (ifld, "error", "*");
    setfocus(vfld);
	document.forms.bp_form.phone.style.background = "#E3E3E3";
    return false;
  }

  var numdigits = 0;
  for (var j=0; j<tfld.length; j++)
    if (tfld.charAt(j)>='0' && tfld.charAt(j)<='9') numdigits++;

  if (numdigits<6) {
   // msg (ifld, "error", "ERROR: " + numdigits + " digits - too short");
	msg (ifld, "error", "*");
    setfocus(vfld);
	document.forms.bp_form.phone.style.background = "#E3E3E3";
    return false;
  //}
   // if (numdigits>14) {
   // msg (ifld, "error", "ERROR: " + numdigits + " digits - too short");
	//msg (ifld, "warn", "*");
    //setfocus(vfld);
	//document.forms.bp_form.phone.style.background = "#F0F7FB";
   // return false;
  } 
  else { 
 	//if (numdigits<10)
      //msg (ifld, "warn", "Only " + numdigits + " digits - check if correct");
	//  msg (ifld, "warn", "*");
	  
	//else
	  msg (ifld, "off", "*");
	}
	document.forms.bp_form.phone.style.background = "#FFFFFF";
	return true;
};


// -----------------------------------------
//             validateAge
// Validate person's age
// Returns true if OK 
// -----------------------------------------

function validateAge    (vfld,   // element to be validated
                         ifld,   // id of element to receive info/error msg
                         reqd)   // true if required
{
  var stat = commonCheck (vfld, ifld, reqd);
  if (stat != proceed) return stat;

  var tfld = trim(vfld.value);
  var ageRE = /^[0-9]{1,3}$/
  if (!ageRE.test(tfld)) {
    msg (ifld, "error", "ERROR: not a valid age");
    setfocus(vfld);
    return false;
  }

  if (tfld>=200) {
    msg (ifld, "error", "ERROR: not a valid age");
    setfocus(vfld);
    return false;
  }

  if (tfld>110) msg (ifld, "warn", "Older than 110: check correct");
  else {
    if (tfld<7) msg (ifld, "warn", "Bit young for this, aren't you?");
    else        msg (ifld, "warn", "");
  }
  return true;
};
function refresh()
{
    window.location.reload( false );
}

  
// EOF
