//FUNZIONE PER SOSTITUIRE NEI CAMPI DI INPUT L'APPICE " CON L'APPICE ' --- INIZIO function controlla_appice(nome_campo,nome_form){ var campo, nome_form, valore; campo = eval("document."+nome_form+"."+nome_campo+".name"); valore = eval("document."+nome_form+"."+nome_campo+".value"); // Sostituisco l'appice doppio con l'appice singolo for (i=0; i nome campo data // form --> nome form // lingua --> alert in lingua // campo_focus --> nome del campo su cui fare il focus function Check_dmg(campo,form,lingua,campo_focus) { var valore,giorno,barra1,mese,barra2,anno,str_mesi,str_giorni,pos_mese,max_giorno_mese; str_mesi = '01*02*03*04*05*06*07*08*09*10*11*12*'; str_giorni = '31*29*31*30*31*30*31*31*30*31*30*31*'; valore = eval(form+"."+campo+".value"); // gg/mm/aaaa // 0123456789 // il secondo parametro di substring indica la posizione +1 dell'ultimo carattere da selezionare giorno = valore.substring(0,2); barra1 = valore.substring(2,3); mese = valore.substring(3,5); barra2 = valore.substring(5,6); anno = valore.substring(6,10); switch(lingua){ case'it': data_arrivo_valori_alert = 'Data '+valore+' non valida. Formato gg/mm/aaaa'; break; case'en': data_arrivo_valori_alert = 'Date '+valore+' is wrong. Format gg/mm/aaaa'; break; case'fr': data_arrivo_valori_alert = 'Date '+valore+' est mal. Format gg/mm/aaaa'; break; case'de': data_arrivo_valori_alert = 'Datum '+valore+' ist unrecht. Format gg/mm/aaaa'; break; } if (isNaN(giorno)){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } else if(giorno <1 || giorno >31){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } if (barra1 != '/'){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } if (isNaN(mese)){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } else if(mese <1 || mese >12){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } else { pos_mese = str_mesi.indexOf(mese+'*'); max_giorno_mese = str_giorni.substring(pos_mese,pos_mese + 2); if (giorno > max_giorno_mese){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } } if (barra2 != '/'){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } if (isNaN(anno)){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } else if(anno < 1900){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } else if(valore.length != 10){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } // Gestione bisestile if (mese === '02'){ if (eBisestile(anno)){ if (giorno > 29){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } } else if (giorno > 28){ alert (data_arrivo_valori_alert); eval("document."+form+"."+campo_focus+".focus()"); return false; } } return true; } /* L'anno bisestile cade normalmente ogni quattro anni, Il problema di questo 'strano' 29 febbraio nasce dal calendario gregoriano, introdotto nel 1582, che fissa un anno bisestile ogni quattro, ma prevede anche che la regola non si applichi agli anni divisibili per 100, esclusi quelli divisibili per 400. Non sono quindi stati bisestili il 1700, il 1800 e il 1900, mentre lo è stato il 1600 e lo è il 2000. La fonte di potenziali problemi sta nel fatto che non tutti i programmatori possono aver conosciuto nel dettaglio la clausola del 'bisesto se divisibile per 400' e che quindi abbiano considerato il 2000 'divisibile per 100' e quindi con un febbraio da 28 giorni. */ function eBisestile(anno){ if(anno%4 == 0 && (anno%100!=0 || anno%400==0)){ // alert (anno + ' bisestile'); return true; } else { // alert (anno + ' NON bisestile'); return false; } } function durata(arrivo, partenza) { var gionims, giorni; giornims=arrivo.getTime() - partenza.getTime(); giorni=Math.floor(giornims / (1000 * 60 * 60 * 24)); return giorni; } // FUNZIONE PER DATE - Fine /*********************************************** * Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts * This notice must stay intact for legal use ***********************************************/ //Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row: var highlightbehavior="TR" var ns6=document.getElementById&&!document.all var ie=document.all function changeto(e,highlightcolor){ source=ie? event.srcElement : e.target if (source.tagName=="TABLE") return while(source.tagName!=highlightbehavior && source.tagName!="HTML") source=ns6? source.parentNode : source.parentElement if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore") source.style.backgroundColor=highlightcolor } function contains_ns6(master, slave) { //check if slave is contained by master while (slave.parentNode) if ((slave = slave.parentNode) == master) return true; return false; } function changeback(e,originalcolor){ if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE") return else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore")) return if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source) source.style.backgroundColor=originalcolor } //FUNZIONE PER SOSTITUIRE NEI CAMPI DI INPUT L'APPICE " CON L'APPICE ' --- INIZIO function controlla_appice(nome_campo,nome_form){ var campo, nome_form, valore; campo = eval("document."+nome_form+"."+nome_campo+".name"); valore = eval("document."+nome_form+"."+nome_campo+".value"); // Sostituisco l'appice doppio con l'appice singolo for (i=0; i 0){ valore = valore.substr(0, poscar) + valore.substr(poscar + 1) ; lunghezza = valore.length; } } for (x=0; x 0){ valore = valore.substr(0, poscar) + valore.substr(poscar + 1) ; lunghezza = valore.length; } } for (x=0; x 0){ valore = valore.substr(0, poscar) + valore.substr(poscar + 1) ; lunghezza = valore.length; } } for (x=0; x 0){ valore = valore.substr(0, poscar) + valore.substr(poscar + 1) ; lunghezza = valore.length; } } for (x=0; x 0){ valore = valore.substr(0, poscar) + valore.substr(poscar + 1) ; lunghezza = valore.length; } } if (isNaN(valore)){ esito = false; }else{ esito = true; } return esito; } // FUNZIONE PER CONTROLLARE I VALORI AMMESSI NELL'INPUT --- Fine // FUNZIONE PER ATTIVARE E DISATTIVARE IL BOTTONE INVIA --- INIZIO var checkobj; function accetta(el){ checkobj=el; if (document.all||document.getElementById){ for (i=0;i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i0){ document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : "" curobj.src=(document.getElementById(cid).style.display=="none")? expandsymbol : contractsymbol } } function revivecontent(){ selectedItem=getselectedItem() selectedComponents=selectedItem.split("|") for (i=0; i 0) { offset = document.cookie.indexOf(search) if (offset != -1) { offset += search.length end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } function getselectedItem(){ if (get_cookie(window.location.pathname) != ""){ selectedItem=get_cookie(window.location.pathname) return selectedItem } else return "" } function saveswitchstate(){ var inc=0, selectedItem="" while (ccollect[inc]){ if (ccollect[inc].style.display=="none") selectedItem+=ccollect[inc].id+"|" inc++ } if (get_cookie(window.location.pathname)!=selectedItem){ //only update cookie if current states differ from cookie's var expireDate = new Date() expireDate.setDate(expireDate.getDate()+parseInt(memoryduration)) document.cookie = window.location.pathname+"="+selectedItem+";path=/;expires=" + expireDate.toGMTString() } } function do_onload(){ uniqueidn=window.location.pathname+"firsttimeload" var alltags=document.all? document.all : document.getElementsByTagName("*") ccollect=getElementbyClass(alltags, "switchcontent") statecollect=getElementbyClass(alltags, "showstate") if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0) revivecontent() if (ccollect.length>0 && statecollect.length>0) revivestatus() } if (window.addEventListener) window.addEventListener("load", do_onload, false) else if (window.attachEvent) window.attachEvent("onload", do_onload) else if (document.getElementById) window.onload=do_onload if (enablepersist=="on" && document.getElementById) window.onunload=saveswitchstate function Log(id, tiporichiesta, marca, codice){ parent.ghost.location.href='code/log.cod.php?ope_id='+id+'&log_tiporichiesta='+tiporichiesta+'&mar_codice='+marca+'&art_codice='+codice; } function Log_lp(v_sercode, v_zetcode, tiporichiesta, v_marca, v_codice, v_codvar){ parent.ghost.location.href='code/log_lp.cod.php?sercode='+v_sercode+'&zetcode='+v_zetcode+'&log_tiporichiesta='+tiporichiesta+'&marca='+v_marca+'&articolo='+v_codice+'&articolo_dist='+v_codvar; } function Log_sigle_marca(id, tiporichiesta, formato){ parent.ghost.location.href='code/log_sigle_marca.cod.php?ope_id='+id+'&log_tiporichiesta='+tiporichiesta+'&log_estrazioneformato='+formato; }