/* Author : Tosom S.r.l. Version : 1.4 requires : the ajaxcore This file provides functions to handle form elements, divs and ajax */ function trace() { if(window.console){ window.console.log(m) } } /* DATE MUST BE UNIX FORMAT YYYY-MM-DD*/ function checkDate(date) { var pattern = /^[0-9]{4}\-([0-9]{2}|[0-9]{1})\-([0-9]{2}|[0-9]{1})$/ ; if( !pattern.test(date) ) { return false ; } var dt = date.split("-") ; var ctrlDate = new Date() ; var ctrlDateString = "" ; ctrlDate.setFullYear( dt[0] ) ; ctrlDate.setMonth( parseInt(dt[1],10)-1 ) ; ctrlDate.setDate( dt[2] ) ; var md = new Array( 31,28,31,30,31,30,31,31,30,31,30,31); // var ctrlYear = ctrlDate.getFullYear(); var ctrlMonth = ctrlDate.getMonth() ; var ctrlDay = ctrlDate.getDate() ; if ( ctrlMonth==2 ) { if( ( ctrlYear%100 == 0 && ctrlYear%400 == 0 ) || ( ctrlYear%4==0 ) ) { md[1] = 29 ; } } if( parseInt(dt[2]) > parseInt(md[ ctrlMonth ]) ) { return false ; } ctrlMonth = ctrlMonth+1 ; ctrlDateString = ctrlYear+"-"+ctrlMonth+"-"+ctrlDay; date = dt[0]+"-"+parseInt(dt[1],10)+"-"+parseInt(dt[2],10) ; return ctrlDateString==date ; } function trim(str) { if(str && str!="") { return str.replace(/^\s+|\s+$/g, ''); } } function openTooltip( e , id ) { var box = null ; if( typeof id == "string" ) box = getId( id ); else box = id ; if(box) { var mpos = lovely_getMouseXY(e); box.style.top = (mpos[1]+25)+"px" ; box.style.left = (mpos[0]-5)+"px"; if(box.style.display!="block") showPanel(box); } } function closeTooltip( id ) { hidePanel(id); } // type= 0 idx is the index, type=1 idx is the value function changeSelectIndex( sel , idx , type ) { if(type==0) { sel.selectedIndex = idx ; } else { for(var i=0 ; i0) sel.remove(0); } /* Options must be an array containig { "value" :"val" , "label":"label" } */ function popolaSelect( select , opts ) { var tmp = null; if(select && opts) { for( var i=0; i=99 ) { elem.value = str.substr( 0 , 99 ) ; } } /* Cambia la selezione di una serie di radio buttons "radio" nome dei radio buttons "type_check" indica il tipo di controllo da effetture : 0 - indice di posizione dell'array degli elementi 1 - valore assunto dal radio button ( seleziona il primo valore trovato ) "check" valore da controllare in base al tipo specificato */ function changeRadioCheck( radio , type_check , check ) { try { elems = document.getElementsByName( radio ); for( var crc_cnt=0 ; crc_cnt