    function isPasswordOk(formName, fieldName1, fieldName2) {
        eval("str = document."+formName+ "." +fieldName1+".value");
        eval("str1 = document."+formName+ "." +fieldName2+".value");

    	str = trim(str);
    	str1 = trim(str1);
    	if (str == "") {
    	  alert("Enter Your Password.");
            eval("document."+formName+"."+fieldName1+".value=str");
            eval("document."+formName+"."+fieldName1+".select()");
            eval("document."+formName+"."+fieldName1+".focus()");
    	  return false;
    	}
    	if(str.length <6) 	{
    	  alert("Your Password Should be at least 6 Characters.");
            eval("document."+formName+"."+fieldName1+".select()");
            eval("document."+formName+"."+fieldName1+".focus()");
    	  return false;		
    	}
    	if (str1 == "") {
    	  alert("Please Confirm Your Password.");
            eval("document."+formName+"."+fieldName1+".value=str");
            eval("document."+formName+"."+fieldName2+".select()");
            eval("document."+formName+"."+fieldName2+".focus()");
    	  return false;
    	}
    	if (str == str1) { 
    	} else {
    	  alert("Confirm Your Password Again.");    	 
            eval("document."+formName+"."+fieldName2+".value=\"\"");
            eval("document."+formName+"."+fieldName2+".select()");
            eval("document."+formName+"."+fieldName2+".focus()");
    	  return false;
    	}
    	return true;
    }
    
    function isRadioOk(formName, fieldName) {
        var len = eval("document."+formName+"."+fieldName+".length");
        for(var i=0; i < len; i++){
            var check = eval("document."+formName+"."+fieldName+"[i].checked");
            if(check) {
                return true;
            }
        }
        alert("select "+fieldName);
        return false;
    }
    
    function isCheckBoxOk(formName, fieldName) {
//    alert('ok');
       try {
        var len = eval("document."+formName+"."+fieldName+".checked");
        alert(len);
       } catch(e) {alert(e);}
        for(var i=0; i < len; i++){
            var check = eval("document."+formName+"."+fieldName+"[i].checked");
            if(check) {
                return true;
            }
        }
        alert("select "+fieldName);
        return false;
    }    

    
    function isFieldOk(formName, fieldName, fldLength) {
        var fld  = "";
        eval("fld = document."+formName+ "." +fieldName+".value");
        fld = trim(fld);
        if (fld == "") {
            var alrt = "Please Enter "+fieldName;
	    alert(alrt);
	    eval("document."+formName+"."+fieldName+".focus()");
	    return false;
	} else {
	    if (fld.length > fldLength) {
	        alert('Restrict ' + fieldName + ' to ' + fldLength + ' chars.');
	        return false;
	    } else {
	        return true;
	    }
	}
    }
    
    function CheckNum(formName, fieldName) {
        var t1 = "";
        eval("t1 = document."+formName+ "." +fieldName+".value");
        if (parseInt(t1) >= 0) {
	    return true;
	} else {
	    alert("Please enter " + fieldName + " as integer number.");
	    eval("document."+formName+"."+fieldName+".focus()");
	    return false;
	}
    }

    function isEmailOk(formName, fldName) {
	var email = eval("document." + formName + "." + fldName + ".value");
	if (email == "") {
		alert ('Please enter your E-mail address.');
		eval("document." + formName + "." + fldName + ".focus()");
		eval("document." + formName + "." + fldName + ".select()");
		return false;
	}
	if((email.indexOf("@")==-1) ||(email.indexOf(".")==-1)) {
		alert ('Enter a vaild E-mail address!');
		eval("document." + formName + "." + fldName + ".focus()");
		eval("document." + formName + "." + fldName + ".select()");
		return false;
	}
	if (email.length < 8) {
		alert("Check your E-mail Id!");
		eval("document." + formName + "." + fldName + ".focus()");
		eval("document." + formName + "." + fldName + ".select()");
		return false;
      }
	return true;
    }
 
     function isBlank(formName, fieldName) {
         var fld  = "";
         eval("fld = document."+formName+ "." +fieldName+".value");
         if (trim(fld) == "") {
             var alrt = "Please Enter "+fieldName;
 	    alert(alrt);
 	    return false;
 	} else {
 	    return true;
 	}
    }
    
    function trim(strInput) {
       return strInput.replace(/^\s+/g, '').replace(/\s+$/g, ''); 
    }
    
function isDateOk(formName,myDate,myMonth,myYear) {
    var dd=0;
    var mm=0;
    var yy=0;
    var lp=0;
    dd = eval("document." + formName + "." + myDate  + ".value");
    mm = eval("document." + formName + "." + myMonth + ".value");
    yy = eval("document." + formName + "." + myYear  + ".value");
    if (dd==0 || mm==0 || yy==0) {
        return false;
    }
    if (yy.length != 4) {
	    alert("Year should be in YYYY format.");
	    eval("document."+ formName +"."+myYear+".focus()");
	    eval("document."+ formName +"."+myYear+".select()");
	    return false;
    }
    lp = yy % 4;
    if ( lp==0 && mm==2) {
	if (dd > 29) {
	    alert("Invalid Date. Please check.");
            eval("document." + formName + "." + myDate + ".options[0].selected = true");
  	    return false;
	}
    } else {
        if (mm==2) {
  	    if (dd>28) {
	 	alert("Invalid Date!!");
		eval("document." + formName + "." + myDate + ".options[0].selected = true");
		return false;
	    }
	} else if ((mm==4) || (mm==6) || (mm==9) || (mm==11)) {
	    if (dd>30) {
		alert("Invalid Date!!");
		eval("document." + formName + "." + myDate + ".options[0].selected = true");
		return false;
	    }
	}
    }
    return true;
}


function isArrivalDateOk(formName,myDate,myMonth,myYear) {
    isDateOk(formName,myDate,myMonth,myYear);

    var dd=0;
    var mm=0;
    var yy=0;
    var lp=0;
    
    dd = eval("document." + formName + "." + myDate  + ".value");
    mm = eval("document." + formName + "." + myMonth + ".value");
    yy = eval("document." + formName + "." + myYear  + ".value");

    aDate = new Date();    
    aDate.setYear(yy);
    aDate.setMonth(mm-1);
    aDate.setDate(dd);
    
    cDate = new Date();  
    getDay = cDate.getDate();    
    getMon = cDate.getMonth();
    getMon +=1;
    getYr = cDate.getYear();
    cDate.setDate(getDay);

    if (cDate <= aDate ) {
        return true;
    } else {
	eval("document." + formName + "." + myMonth + ".value ="+ getMon);
	eval("document." + formName + "." + myDate + ".value ="+ getDay);
	eval("document." + formName + "." + myYear + ".value ="+ getYr);
        alert('Check Date');
        return false;
    }  
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);

	// otherwise, update 'characters left' counter
	else
		countfield.value = maxlimit - field.value.length;
}

/*

function textCounter(formName, fieldName, countfield, maxlimit) {
        eval("fldVal = document."+formName+ "." +fieldName+".value");
	if (fldVal.length > maxlimit)  {
	    finalVal = fldVal.substring(0, maxlimit);
	    eval("document." + formName + "." + fieldName + ".value ="+ fldVal.substring(0, maxlimit));
        } else {
	    countVal = maxlimit - fldVal.length; 
	    eval("document." + formName + "." + countfield + ".value ="+ countVal);
	}
}
                onKeyDown="textCounter('outrageousForm', 'complaintDesc', 'complaintDescription',2);"
                 onKeyUp="textCounter('outrageousForm','complaintDesc', 'complaintDescription',2);"></textarea>

*/


    function isPhoneNumber(formName,phoneNumber,ph1,ph2,ph3) {
	str1 = eval("document."+ formName +"."+ph1+".value");
	str2 = eval("document."+ formName +"."+ph2+".value");
	str3 = eval("document."+ formName +"."+ph3+".value");
	
	if (str1 == "") {
	    alert("Please enter area code in phone number.");
	    eval("document."+ formName +"."+ph1+".focus()");
	    eval("document."+ formName +"."+ph1+".select()");
	    return false;
	}
	if (str2 == "") {
	    alert("Please check the phone number.");
	    eval("document."+ formName +"."+ph2+".focus()");
	    eval("document."+ formName +"."+ph2+".select()");
	    return false;
	}
	if (str3 == "") {
	    alert("Please check the phone number.");
	    eval("document."+ formName +"."+ph3+".focus()");
	    eval("document."+ formName +"."+ph3+".select()");
	    return false;
	}
	
	var str = str1 + str2 + str3;
	for (var i = 0; i < str.length; i++) {
	    var ch = str.substring(i, i + 1);
	    if (ch < "0" || "9" < ch) {
		alert('Phone number should be numeric.');
		eval("document."+ formName +"."+ph3+".focus()");
	    	eval("document."+ formName +"."+ph3+".select()");
		return false;
	    }
	}
	if (str.length != 10) {
	    alert("The phone number should have 10 digits.");
	    eval("document."+ formName +"."+ph3+".focus()");
	    eval("document."+ formName +"."+ph3+".select()");
	    return false;
	}
	eval("document."+ formName +"."+phoneNumber+".value="+str);
	return true;
    }

