var search = { forma: null, waitMsg: null, errMsg: null, d: null, m: null, y: null, d2: null, m2: null, y2: null, submitForm: function(obj) { this.forma = obj; while (this.forma && this.forma.nodeName.toLowerCase()!='form') this.forma = this.forma.parentNode; if (this.validateDate()) { obj.value = this.waitMsg; this.forma.submit(); } else { if (this.d2==null || this.m2==null || this.y2==null) alert (this.d.value+'.'+this.m.value+'.'+this.y.value+' '+this.errMsg); else alert (this.d.value+'.'+this.m.value+'.'+this.y.value+' - '+this.d2.value+'.'+this.m2.value+'.'+this.y2.value+' '+this.errMsg); } }, validateDate: function() { // nema datuma polaska if (this.d==null || this.m==null || this.y==null) return false; var d = this.d.value; var m = this.m.value; var y = this.y.value; // samo datum polaska if (this.d2!=null && this.m2!=null && this.y2!=null) { var d2 = this.d2.value; var m2 = this.m2.value; var y2 = this.y2.value; // provjeri pocetni if (YMDdate2int(y,m,d)>=YMDdate2int(y2,m2,d2) || YMDdate2int(y,m,d)<(date2int(currentDate())+1) || (d==31 && (m==2 || m==4 || m==6 || m==9 || m==11)) || (d==30 && m==2) || (m==2 && d==29 && !isYearOver(y))) { return false; } // provjeri zavrsni if ( (d2==31 && (m2==2 || m2==4 || m2==6 || m2==9 || m2==11)) || (d2==30 && m2==2) || (m2==2 && d2==29 && !isYearOver(y2)) ) { return false; } } // oba datuma else { if (YMDdate2int(y,m,d)<(date2int(currentDate())+1) || (d==31 && (m==2 || m==4 || m==6 || m==9 || m==11)) || (d==30 && m==2) || (m==2 && d==29 && !isYearOver(y))) { return false; } } return true; } }