// JavaScript Document

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}
function checkNumber(val) {
	var strPass = val.value;
	var strLength = strPass.length;
	var lchar = val.value.charAt((strLength) - 1);
	var cCode = CalcKeyCode(lchar);
	
	/* Check if the keyed in character is a number
	 do you want alphabetic UPPERCASE only ?
	 or lower case only just check their respective
	 codes and replace the 48 and 57 */
	
	if (cCode < 48 || cCode > 57 ) {
		var myNumber = val.value.substring(0, (strLength) - 1);
		val.value = myNumber;
	}
	return false;
}
function showPopUp(el) {
	var cvr = document.getElementById("cover")
	var dlg = document.getElementById(el)
	cvr.style.display = "block"
	dlg.style.display = "block"
		if (document.body.style.overflow = "hidden") {
		cvr.style.width = "1400"
		cvr.style.height = "200%"
	}
	//setTimeout("window.location='/quote/medsupp/?action=new';",1000);
}
function reSession(){
	setTimeout("showPopUp('session');",1200000);
}
function closePopUp(el) {
	var cvr = document.getElementById("cover")
	var dlg = document.getElementById(el)
	cvr.style.display = "none"
	dlg.style.display = "none"
	document.body.style.overflowY = "scroll"
}
function chkReq(v){
	if(v.value=='') v.className='verdana11Required';
}
function chkRef(v){
	if(v.value=='') v.className='tahomaBRequired';
}
function goMenu(p,a,n){
	document.menu.pageID.value=p;
	document.menu.action.value=a;
	if(n) document.menu.action.value=a;
	document.menu.submit();
}
function changebox(b) {
	if(b.disabled==false) b.checked=!b.checked;
}
function jumpMenu(selObj){
	goMenu(selObj.options[selObj.selectedIndex].value,'jump')
}
function getAge(cal) {
	cal.hide();
	var p = cal.params;
	var dateString = cal.date.print(p.ifFormat);
    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());
    var yearNow = now.getYear();
    var monthNow = now.getMonth()+1;
    var dateNow = now.getDate();
	
	var dob = new Date(dateString.substring(6,10),dateString.substring(0,2),dateString.substring(3,5));
    var yearDob = dob.getYear();
    var monthDob = dob.getMonth();
    var dateDob = dob.getDate();

	if(yearDob<100) yearDob=yearDob+1900;
    yearAge=yearNow-yearDob;

    //if(monthNow = monthDob && dateDob <= dateNow) yearAge++;
	
    if(monthNow < monthDob) yearAge--;
	else if(monthNow==monthDob && dateDob>dateNow) yearAge--;
    document.all.age.value=yearAge;
	document.all.age.className='verdana11';
	if(yearAge=='64') createWindow('<b>Age Quoting Verification</b>', 250, '#F5F5F3', 1, 0, 320, 210);
}
function dispEffDate(cal) {
	cal.hide();
	var p = cal.params;
	var dateString = cal.date.print(p.ifFormat);
    document.all.pbe.value=dateString;
	document.all.pbe.className='verdana11';
}
