diff --git a/htdocs/lib/lib.js b/htdocs/lib/lib.js
new file mode 100644
index 00000000000..e1d5a71b1b0
--- /dev/null
+++ b/htdocs/lib/lib.js
@@ -0,0 +1,222 @@
+
+// Pour la fonction de saisi auto des villes
+// *****************************************
+
+function PopupPostalCode(postalcode,objectville)
+{
+ var url = 'searchpostalcode.php?cp=' + postalcode + '&targetobject=window.opener.document.formsoc.' + objectville.name;
+ // alert(url);
+ var hWnd = window.open(url, "SearchPostalCodeWindow", "width=" + 300 + ",height=" + 150 + ",resizable=yes,scrollbars=yes");
+ if((document.window != null) && (!hWnd.opener)) hWnd.opener = document.window;
+}
+
+function save_refresh()
+{
+ document.formsoc.action.value="edit";
+ document.formsoc.submit();
+}
+
+
+// Pour la saisie des dates par calendrier
+// ***************************************
+
+function showDP(base,dateFieldID,format)
+{
+ var dateField= getObjectFromID(dateFieldID);
+
+ //check to see if another box is already showing
+ var alreadybox=getObjectFromID("DPCancel");
+ if(alreadybox) closeDPBox();
+
+ //get positioning
+ var thetop=getTop(dateField)+dateField.offsetHeight;
+ var theleft=getLeft(dateField);
+ if (theleft+140 > window.innerWidth)
+ theleft= theleft-140+dateField.offsetWidth-15;
+
+ showDP.box=document.createElement("div");
+ showDP.box.className="bodyline";
+ showDP.box.style.siplay="block";
+ showDP.box.style.position="absolute";
+ showDP.box.style.top=thetop + "px";
+ showDP.box.style.left=theleft + "px";
+
+ showDP.datefieldID=dateFieldID;
+
+ if(dateField.value)
+ {
+ selDate=stringToDate(dateField.value,format);
+ year=selDate.getFullYear();
+ month=selDate.getMonth()
+ day=selDate.getDay();
+ }
+ else
+ {
+ tdate=new Date();
+ year=tdate.getFullYear();
+ month=tdate.getUTCMonth()+1;
+ day=tdate.getDay();
+ }
+ loadMonth(base,month,year,year+'-'+month+'-'+day);
+ hideSelectBoxes();
+ document.body.appendChild(showDP.box);
+}
+
+// selectedDate must be in format YYYY-MM-DD
+function loadMonth(base,month,year,selectedDate)
+{
+ showDP.box.innerHTML="Loading...";
+ var theURL=base+"datepicker.php?cm=shw";
+ theURL+="&m="+encodeURIComponent(month);
+ theURL+="&y="+encodeURIComponent(year);
+ if (selectedDate){
+ tempdate=mysqlstringToDate(selectedDate);
+ theURL+="&sd="+encodeURIComponent(tempdate.getFullYear()+"-"+tempdate.getMonth()+"-"+tempdate.getDate());
+ }
+
+ loadXMLDoc(theURL,null,false);
+ showDP.box.innerHTML=req.responseText;
+}
+
+
+function closeDPBox(){
+ document.body.removeChild(showDP.box);
+ displaySelectBoxes();
+ showDP.box=null;
+ showDP.datefieldID=null;
+}
+
+function dpClickDay(year,month,day){
+ var thefield=getObjectFromID(showDP.datefieldID);
+ thefield.value=day+"/"+month+"/"+year;
+ if(thefield.onchange) thefield.onchange.call(thefield);
+ closeDPBox();
+}
+
+function dpHighlightDay(year,month,day){
+ var displayinfo=getObjectFromID("dpExp");
+ var months=Array("January","February","March","April","May","June","July","August","September","October","November","December");
+ displayinfo.innerHTML=months[month-1]+" "+day+", "+year;
+}
+
+function stringToDate(sDate,format){
+// \todo fonction a ecrire pour tenir compte de format
+ var sep="/";
+ var month=sDate.substring(0,sDate.indexOf(sep))
+ var day=sDate.substring(sDate.indexOf(sep)+1,sDate.indexOf(sep,sDate.indexOf(sep)+1))
+ var year=sDate.substring(sDate.lastIndexOf(sep)+1);
+ return new Date(year,month,day);
+}
+
+function mysqlstringToDate(sDate){
+ var sep="-";
+ var year=sDate.substring(0,sDate.indexOf(sep))
+ var month=sDate.substring(sDate.indexOf(sep)+1,sDate.indexOf(sep,sDate.indexOf(sep)+1))
+ var day=sDate.substring(sDate.lastIndexOf(sep)+1);
+// alert(year+','+month+','+day);
+ return new Date(year,month,day);
+}
+
+
+
+//Returns an object given an id
+function getObjectFromID(id){
+ var theObject;
+ if(document.getElementById)
+ theObject=document.getElementById(id);
+ else
+ theObject=document.all[id];
+ return theObject;
+}
+
+
+// This Function returns the Top position of an object
+function getTop(theitem){
+ var offsetTrail = theitem;
+ var offsetTop = 0;
+ while (offsetTrail) {
+ offsetTop += offsetTrail.offsetTop;
+ offsetTrail = offsetTrail.offsetParent;
+ }
+ if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined")
+ offsetLeft += document.body.TopMargin;
+ return offsetTop;
+}
+
+// This Function returns the Left position of an object
+function getLeft(theitem){
+ var offsetTrail = theitem;
+ var offsetLeft = 0;
+ while (offsetTrail) {
+ offsetLeft += offsetTrail.offsetLeft;
+ offsetTrail = offsetTrail.offsetParent;
+ }
+ if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined")
+ offsetLeft += document.body.leftMargin;
+ return offsetLeft;
+}
+
+function loadXMLDoc(url,readyStateFunction,async)
+{
+ // branch for native XMLHttpRequest object
+ if (window.XMLHttpRequest) {
+ req = new XMLHttpRequest();
+ req.onreadystatechange = readyStateFunction;
+ req.open("GET", url, async);
+ req.send(null);
+ // branch for IE/Windows ActiveX version
+ } else if (window.ActiveXObject) {
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ if (req) {
+ if(readyStateFunction) req.onreadystatechange = readyStateFunction;
+ req.open("GET", url, async);
+ req.send();
+ }
+ }
+}
+
+function addEvent(obj, evType, fn){
+ if (obj.addEventListener){
+ obj.addEventListener(evType, fn, true);
+ return true;
+ } else if (obj.attachEvent){
+ var r = obj.attachEvent("on"+evType, fn);
+ return r;
+ } else {
+ return false;
+ }
+}
+
+function removeEvent(obj, evType, fn, useCapture){
+ if (obj.removeEventListener){
+ obj.removeEventListener(evType, fn, useCapture);
+ return true;
+ } else if (obj.detachEvent){
+ var r = obj.detachEvent("on"+evType, fn);
+ return r;
+ } else {
+ window.status=("Handler could not be removed");
+ }
+}
+
+function hideSelectBoxes() {
+ var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
+ if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
+ for(var i = 0; i < document.all.length; i++) {
+ if(document.all[i].tagName)
+ if(document.all[i].tagName == "SELECT")
+ document.all[i].style.visibility="hidden";
+ }
+ }
+}
+
+function displaySelectBoxes() {
+ var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
+ if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
+ for(var i = 0; i < document.all.length; i++) {
+ if(document.all[i].tagName)
+ if(document.all[i].tagName == "SELECT")
+ document.all[i].style.visibility="visible";
+ }
+ }
+}
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 81fc1e527b3..05445af2c8b 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -266,6 +266,11 @@ function top_htmlhead($head, $title="", $target="")
print ''."\n";
print ''."\n";
+ if ($conf->use_javascript)
+ {
+ print '';
+ }
+
print "\n";
}
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index 084165aa1a3..afae9e0cfc4 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -394,6 +394,12 @@ if (defined("MAIN_MAIL_NEW_SUBJECT"))
$conf->adherent->email_new_subject=MAIN_MAIL_NEW_SUBJECT;
}
+// Format de la date
+// \todo Mettre format dans fichier langue
+$conf->format_date_text_short="%d %b %Y";
+$conf->format_date_short="%d/%m/%Y";
+
+
/* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de d?sactiver la fonction TVA
* (pour particuliers ou lib?raux en franchise)
* En attendant, valeur forc?e ? 1
diff --git a/htdocs/soc.js.php b/htdocs/soc.js.php
deleted file mode 100644
index 8ec5ffd23f8..00000000000
--- a/htdocs/soc.js.php
+++ /dev/null
@@ -1,29 +0,0 @@
-'."\n";
-print "\n";
-print "\n";
-
-?>