<!-- CJE Javascript
var mm; 
var dd; 
var yyyy; 
var daysInMonth; 
var minYear = 2009; //inclusive, 1930 is the lowest valid year 
var maxYear = 2099; //inclusive, 2003 is the highest valid year 

function formatPhone(fieldname,id){ 
    area_code = document.vendor_Form["area_code_"+id].value; 
    prefix = document.vendor_Form["prefix_"+id].value; 
    suffix = document.vendor_Form["suffix_"+id].value; 

//set value of the hidden field with the whole string 
 	document.vendor_Form[fieldname].value="(" + area_code + ")" +prefix+"-"+suffix; 
// 	alert (document.vendor_Form[fieldname].value);
   return true; 
}

function checkDate(fieldname,id){ 
    mm = document.vendor_Form["month_"+id].value; 
    dd = document.vendor_Form["day_"+id].value; 
    yyyy = document.vendor_Form["year_"+id].value; 
    setDaysInMonth(mm);
//check month
    if(mm!="" && mm >=1 && mm <=12){ 
//        return true; 
    } else { 
	    alert('valid months are 1 to 12'); 
    	document.vendor_Form["month_"+id].value=""; 
    	document.vendor_Form["month_"+id].focus(); 
		return false;
	} 
//check day
    if(dd!="" && dd >=1 && dd <= daysInMonth){ 
//        return true; 
    } else {
    	alert('valid days are 1 to ' + daysInMonth); 
    	document.vendor_Form["day_"+id].value=""; 
    	document.vendor_Form["day_"+id].focus();
		return false;
	} 
//check year
    if(yyyy.length==4 && yyyy >= minYear && yyyy <= maxYear){ 
//        return true; 
    } else {
	    alert('Please enter a 4-digit year between '+minYear+' and '+maxYear); 
    	document.vendor_Form["year_"+id].value=""; 
    	document.vendor_Form["year_"+id].focus(); 
		return false;
	} 

//set value of the hidden field with the whole date string 
 	document.vendor_Form[fieldname].value=yyyy+"-"+mm+"-"+dd; 
// 	alert (document.vendor_Form[fieldname].value);
   return true; 
}

function setDaysInMonth(month){ 
    leap = (yyyy%400==0) || ((yyyy%4==0) && (yyyy%100 !=0)); 
    if(month==4 || month==6 || month==9 || month==11){ 
        daysInMonth = 30; 
    } 
    else if(month==2 && leap){ 
        daysInMonth = 29; 
    } 
    else if(month==2 && !leap){ 
        daysInMonth = 28; 
    } 
    else{ 
        daysInMonth = 31; 
    } 
} 

//-->


