
var ret=true;
var pos="";

function checkfield(field)
{
    var fieldret=true;
    if ( field.value=='' || field.value=="00" )
    {
		field.style.backgroundColor ="#ffdddd";
        if(ret) field.focus();

		//alert(field.name);

        ret=false;
    }else{
    	pos="";
        field.style.backgroundColor ="#ffffff";
    }
}

function checkmm()
{
    var o =document.getElementById('mm');
    if ( o.selectedIndex == 0 )
    {
		o.style.backgroundColor ="#ffdddd";
        if(ret) o.focus();
        ret=false;
    }else{
    	pos="";
        o.style.backgroundColor ="#ffffff";
    }
}

function checkrange(field,minnum,maxnum){
    if(field.value=='' || field.value<minnum || field.value>maxnum){
        field.style.backgroundColor ="#ffdddd";
        if(ret) field.focus();
        ret= false;
    }else{
        field.style.backgroundColor ="#ffffff";
    }
}

function checkform(theform)
{
	ret=true;
    with (theform)
    {
    checkfield(formname);
    checkfield(formphone);
    checkrange(dd,1,31)
    checkmm();
    }

    if(!ret) alert('Please make sure the highlighted fields are filled in, thanks.');

    return ret;
}

