function clCustomForm(_cID){ this.Bwsr_ns4= false;this.Bwsr_ns6= false;this.Bwsr_ns7= false;this.Bwsr_opera = false;this.Bwsr_ie = false;this.Bwsr_safari= false;this.Bwsr_mozilla  = false;this.Bwsr_Win= false;this.Bwsr_Mac= false;this.m_cFieldsNames= new Array();this.m_cFieldsLabels  = new Array();this.m_cFieldsTypes= new Array();this.m_cFieldsMandatory  = new Array();this.m_nFieldsNames= -1;this.m_cFormsSubmitted= new Array();this.m_nFormsSubmitted= -1;this.m_cCallBackSubmit= '';this.m_bSubmitting = false;this.GetElement= _GetElement;this.GetElementStyle = _GetElementStyle;this.GetElementPosX  = _GetElementPosX;this.GetElementPosY  = _GetElementPosY;this.BrowserDetect= _BrowserDetect;this.LoadFields= _LoadFields;this.AddFieldName = _AddFieldName;this.SubmitFields = _SubmitFields;this.SubmitFileUpload= _SubmitFileUpload;this.CheckFields  = _CheckFields;this.CheckNumber  = _CheckNumber;this.CheckDate = _CheckDate;this.CheckFileUpload = _CheckFileUpload;this.CountString  = _CountString;this.ReplaceStr= _ReplaceStr;this.RightStr  = _RightStr;this.ExtractString= _ExtractString;this.Submitted = _Submitted;this.RemoveLeadingZero = _RemoveLeadingZero;this.BrowserDetect();function _AddFieldName(_cName , _cType , _bMandatory , _cLabel){this.m_nFieldsNames ++;this.m_cFieldsNames[this.m_nFieldsNames]  = _cName;this.m_cFieldsTypes[this.m_nFieldsNames]  = _cType;this.m_cFieldsMandatory[this.m_nFieldsNames] = _bMandatory;this.m_cFieldsLabels[this.m_nFieldsNames] = _cLabel;}function _LoadFields(_cIFrameName){var oIFrame; var oTgtFld; var oSrcFld; var nField = 0; var cName  = ''; oIFrame = GetElement(_cIFrameName); if(oIFrame) {  for( nField=0 ; nField <= this.m_nFieldsNames ; nField++) {  cName = 'META_' + this.m_cFieldsNames[nField] + '_DIV' if((this.Bwsr_ns6) || (this.Bwsr_ns7) || (this.Bwsr_mozilla)) {oSrcFld = this.GetElement(cName , oIFrame.contentDocument); } else { oSrcFld = this.GetElement(cName , eval(_cIFrameName+'.document'));} if(oSrcFld) { oTgtFld = this.GetElement(cName);if(oTgtFld) oTgtFld.innerHTML = oSrcFld.innerHTML; } } }}function _CheckFields(_cIFrameName , _oFieldsError , _oFieldsMandatory , _oFieldsModified){var oSrcFld; var nField = 0; var cType  = ''; var cName  = ''; var nOption= 0; var bSelected = false; var cValue = ''; var bOk = true; var nError = 0; var nMandatory= 0; var nModified = 0;  if(this.m_bSubmitting) return true;  for( nField=0 ; nField <= this.m_nFieldsNames ; nField++) {  cType = ''; if(this.m_cFieldsTypes[nField] == 'TXT') { cType = 'T';} else if(this.m_cFieldsTypes[nField] == 'NUM')  { cType = 'N';} else if(this.m_cFieldsTypes[nField] == 'LST')  { cType = 'L';} else if(this.m_cFieldsTypes[nField] == 'LSTS') { cType = 'LS';} else if(this.m_cFieldsTypes[nField] == 'DATE') { cType = 'D';} else if(this.m_cFieldsTypes[nField] == 'RICHTXT') { cType = 'T';} else if(this.m_cFieldsTypes[nField] == 'FILEUPLD'){ cType = 'F';} cName  = 'Metadatas_'+ cType +'_'+ this.m_cFieldsNames[nField]; oSrcFld = this.GetElement(cName); if(oSrcFld || cType == 'F') {   if(cType == 'N')  {if(! this.CheckNumber( oSrcFld ) ){bOk = false; _oFieldsError[nError] = this.m_cFieldsLabels[nField]; nError ++;}}  else if(cType == 'D')  {cValue = oSrcFld.value;if(! this.CheckDate( oSrcFld ) ){bOk = false; _oFieldsError[nError] = this.m_cFieldsLabels[nField]; nError ++;}else {if( cValue != oSrcFld.value ){bOk = false; _oFieldsModified[nModified] = this.m_cFieldsLabels[nField];nModified ++;}} }    if(this.m_cFieldsMandatory[nField])  {if(cType == 'L' || cType == 'LS')  {bSelected = false;  for(nOption=0 ; nOption < oSrcFld.length ; nOption++)  {if(oSrcFld.options[nOption].selected)  {bSelected = true}}  if(! bSelected)  {bOk = false;  _oFieldsMandatory[nMandatory] = this.m_cFieldsLabels[nField];  nMandatory ++;}}  else if(cType == 'F')  {if( ! this.CheckFileUpload(this.m_cFieldsNames[nField] , _cIFrameName) )  {bOk = false;_oFieldsMandatory[nMandatory] = this.m_cFieldsLabels[nField];nMandatory ++;}}  else {if( oSrcFld.value == '' ){bOk = false; _oFieldsMandatory[nMandatory] = this.m_cFieldsLabels[nField]; nMandatory ++;} }} } } return bOk;}function _CheckFileUpload(_cID,_cIFrameName){var cTgtIframe= ''; var oTgtIframe; var oTgtFld; var oTgtDocument; var cName  = '';   cTgtIframe = 'REQ_FORM_MDTA_' + _cID; cName= 'Metadatas_F_97'; oTgtIframe = GetElement(cTgtIframe);  if(oTgtIframe) {   if((this.Bwsr_ns6) || (this.Bwsr_ns7) || (this.Bwsr_mozilla))  {oTgtDocument = oTgtIframe.contentDocument;oTgtFld  = this.GetElement(cName  , oTgtDocument);}  else { oTgtDocument = eval(cTgtIframe+'.document');oTgtFld  = this.GetElement(cName  , oTgtDocument); }    if(oTgtFld)  {if( oTgtFld.value != '' ) return true;} } return false;}function _SubmitFields(_cIFrameName){var oIFrame; var oIFrameDocument; var oTgtFld; var oSrcFld; var nField = 0; var cType  = ''; var cName  = ''; var nOption= 0; if(this.m_bSubmitting) return; this.m_bSubmitting = true; oIFrame = GetElement(_cIFrameName); if(oIFrame) {   if((this.Bwsr_ns6) || (this.Bwsr_ns7) || (this.Bwsr_mozilla)) {oIFrameDocument = oIFrame.contentDocument; } else { oIFrameDocument = eval(_cIFrameName+'.document');} for( nField=0 ; nField <= this.m_nFieldsNames ; nField++) {  cType = '';  if(this.m_cFieldsTypes[nField] == 'TXT') { cType = 'T';} else if(this.m_cFieldsTypes[nField] == 'NUM')  { cType = 'N';} else if(this.m_cFieldsTypes[nField] == 'LST')  { cType = 'L';} else if(this.m_cFieldsTypes[nField] == 'LSTS') { cType = 'LS';} else if(this.m_cFieldsTypes[nField] == 'DATE') { cType = 'D';} else if(this.m_cFieldsTypes[nField] == 'RICHTXT') { cType = 'T';} else if(this.m_cFieldsTypes[nField] == 'FILEUPLD'){ cType = 'F';} else if(this.m_cFieldsTypes[nField] == 'FREE') { cType = 'T';}  if(this.m_cFieldsTypes[nField] != 'FREE') {cName  = 'Metadatas_'+ cType +'_'+ this.m_cFieldsNames[nField]; } else { cName  = this.m_cFieldsNames[nField];}  if((this.Bwsr_ns6) || (this.Bwsr_ns7) || (this.Bwsr_mozilla)) {oTgtFld = this.GetElement(cName , oIFrame.contentDocument); } else { oTgtFld = this.GetElement(cName , eval(_cIFrameName+'.document'));}  if(oTgtFld || cType == 'F') { oSrcFld = this.GetElement(cName);if(oSrcFld || cType == 'F'){   if(cType == 'L' || cType == 'LS')  {   for( nOption=0 ; nOption < oSrcFld.length ; nOption++)  {oTgtFld.options[nOption].selected = oSrcFld.options[nOption].selected;}}  else if(cType == 'F')  {  this.SubmitFileUpload(this.m_cFieldsNames[nField] , _cIFrameName);}  else  {   oTgtFld.value = oSrcFld.value;}} } } oIFrameDocument.forms[0].submit();  this.m_nFormsSubmitted ++; this.m_cFormsSubmitted[this.m_nFormsSubmitted] = 'MAIN'; }}function _SubmitFileUpload(_cID,_cIFrameName){var oIFrame; var oSrcFld; var cName  = ''; var cName2 = ''; var cTgtIframe= ''; var oTgtIframe; var oTgtDocument; var oTgtFld; var oTgtFld2; oIFrame = GetElement(_cIFrameName); if(oIFrame) {   cName  = 'Metadatas_ConsoID';  cName2 = 'Metadatas_Name';  if((this.Bwsr_ns6) || (this.Bwsr_ns7) || (this.Bwsr_mozilla))  {oSrcFld = this.GetElement(cName , oIFrame.contentDocument);}  else { oSrcFld = this.GetElement(cName , eval(_cIFrameName+'.document')); }    cTgtIframe = 'REQ_FORM_MDTA_' + _cID;  oTgtIframe = GetElement(cTgtIframe);  if(oTgtIframe)  {   if((this.Bwsr_ns6) || (this.Bwsr_ns7) || (this.Bwsr_mozilla))  {oTgtDocument = oTgtIframe.contentDocument;oTgtFld  = this.GetElement(cName  , oTgtDocument);oTgtFld2 = this.GetElement(cName2 , oTgtDocument);}  else { oTgtDocument = eval(cTgtIframe+'.document');oTgtFld  = this.GetElement(cName  , oTgtDocument);oTgtFld2 = this.GetElement(cName2 , oTgtDocument); }    if(oTgtFld)  {oTgtFld.value  = oSrcFld.value;oTgtFld2.value = cTgtIframe;oTgtDocument.forms[0].submit();this.m_nFormsSubmitted ++;this.m_cFormsSubmitted[this.m_nFormsSubmitted] = cTgtIframe;}} } }function _Submitted(_cFormSubmitted){var nForm = 0;var bAllProcessed = true;for(nForm=0 ; nForm <= this.m_nFormsSubmitted ; nForm++){if( this.m_cFormsSubmitted[nForm].toUpperCase() == _cFormSubmitted.toUpperCase() ) {this.m_cFormsSubmitted[nForm] = ''; }}for(nForm=0 ; nForm <= this.m_nFormsSubmitted ; nForm++){if( this.m_cFormsSubmitted[nForm] != '' ) {bAllProcessed = false; }}if( bAllProcessed ){if(this.m_cCallBackSubmit != '') {setTimeout( this.m_cCallBackSubmit , 100 ); }}}function _CheckNumber(_oField){var bOk = false;var cValue = '';var nComma = 0;var nDot= 0;var nLastComma = 0;var nLastDot= 0;cValue = _oField.value;if(cValue == '') return true;nComma = this.CountString(cValue , ',');nDot= this.CountString(cValue , '.');if(nComma != 0 && nDot == 0){if(nComma == 1) {  cValue = this.ReplaceStr(cValue , ',' , '.'); _oField.value = cValue; } else {  cValue = this.ReplaceStr(cValue , ',' , ''); _oField.value = cValue;}}else if(nComma == 0 && nDot != 0){if(nDot != 1) {   cValue = this.ReplaceStr(cValue , '.' , '');  _oField.value = cValue; }}else if(nComma != 0 && nDot != 0){  nLastComma = cValue.lastIndexOf(','); nLastDot= cValue.lastIndexOf('.'); if(nLastComma > nLastDot) {  cValue = this.ReplaceStr(cValue , '.' , ''); if(nComma > 1) {return false;  }  cValue = this.ReplaceStr(cValue , ',' , '.'); } else {  cValue = this.ReplaceStr(cValue , ',' , ''); if(nDot > 1) {return false;  }} _oField.value = cValue;}if( cValue == parseFloat(cValue) ){bOk = true;}return bOk;}function _CheckDate(_oField){var bOk = true;var cValue = '';var nYear  = 0;var nMonth = 0;var nDay= 0;var cChar  = '';var nChar  = 0;var cValueLight  = '';var dDate  = new Date();var cTmp1  = '';var cTmp2  = '';var cTmp3  = '';cValue = _oField.value;if(cValue == '') return true;if(this.CountString(cValue , '/') != 0){cTmp1 = this.ExtractString(cValue , 0 , '/');cTmp2 = this.ExtractString(cValue , 1 , '/');cTmp3 = this.ExtractString(cValue , 2 , '/');if(cTmp1.length == 4){cValue = this.RightStr('00'+cTmp3,2) + this.RightStr('00'+cTmp2,2) + cTmp1;}else {cValue = this.RightStr('00'+cTmp1,2) + this.RightStr('00'+cTmp2,2) + cTmp3;}}for(nChar=0 ; nChar < cValue.length ; nChar++){cChar = cValue.substr(nChar,1); if( cChar == parseInt(cChar) ) {cValueLight += cChar; }}if( cValueLight.length != 8){bOk = false;}cTmp1  = cValueLight.substr(4 , 4);nYear  = parseInt(cTmp1);cTmp1  = this.RemoveLeadingZero(cValueLight.substr(2 , 2));nMonth = parseInt(cTmp1);cTmp1  = this.RemoveLeadingZero(cValueLight.substr(0 , 2));nDay= parseInt(cTmp1);if( isNaN(nYear)  ) nYear  = 0;if( isNaN(nMonth) ) nMonth = 0;if( isNaN(nDay)) nDay= 0;if(nYear <= 999 || nYear > 9999) {bOk = false;}if(nMonth <= 0  || nMonth > 12)  {bOk = false;}if(nDay <= 0 || nDay > 31) {bOk = false;}if(bOk){ dDate.setFullYear(nYear,(nMonth-1),nDay);if(dDate.getFullYear() != nYear || dDate.getMonth() != (nMonth-1) || dDate.getDate() != nDay){bOk = false;}}cValue = '';cValue += this.RightStr('00' + nDay , 2);cValue += '/';cValue += this.RightStr('00' + nMonth  , 2);cValue += '/';cValue += this.RightStr('0000' + nYear , 4);_oField.value = cValue;return bOk;}function _RemoveLeadingZero(_cSource){var nChar = 0;var cChar = '';var cValue = '';var bOther = false;for(nChar=0 ; nChar < _cSource.length ; nChar++){cChar = _cSource.substr(nChar,1); if( cChar != "0" || bOther) {cValue += cChar;  bOther = true; }}return cValue;}function _CountString(_cStringSource,subString){ var nPosOfChar = 0;var nCurrentIndex = 0;var cStringWork= _cStringSource;do{ nPosOfChar = cStringWork.indexOf(subString);if(nPosOfChar > -1){ nCurrentIndex++;cStringWork = cStringWork.substring((nPosOfChar+1),(cStringWork.length)); }}while (nPosOfChar > -1);return nCurrentIndex;}function _RightStr( _cString , _nLength ){var nStart = (_cString.length-_nLength); var nEnd= _cString.length; return _cString.substring(nStart , nEnd );}function _ExtractString(_cStringSource,_nIndexElement,_cSeparator){var arrayOfString;arrayOfString = _cStringSource.split(_cSeparator);if (_nIndexElement > (arrayOfString.length - 1)){return null;}else {return arrayOfString[_nIndexElement];}}function _ReplaceStr( _cString , _cSeek , _cReplace ){ var nPos = 0;var nFound = _cString.indexOf(_cSeek);var cString2 = new String();while(nFound!=-1){ cString2 += _cString.substring(nPos,nFound);cString2 += _cReplace;nPos = nFound + _cSeek.length;nFound = _cString.indexOf(_cSeek,nPos);}cString2 += _cString.substring(nPos,_cString.length);return cString2;}function _BrowserDetect(){ this.Bwsr_ns4=(document.layers)?true:false;this.Bwsr_ns6=(!document.all && document.getElementById)?true:false;this.Bwsr_ns7= false;if (this.Bwsr_ns6){var cStr;cStr = new String(navigator.userAgent);if (cStr.indexOf("/7") != -1){this.Bwsr_ns7 = true; this.Bwsr_ns6 = false;}}this.Bwsr_opera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;this.Bwsr_ie=(document.all)?true:false;this.Bwsr_safari  =(navigator.userAgent.indexOf("Safari")!=-1)?true:false;this.Bwsr_mozilla = false;if ((this.Bwsr_ns6) || (this.Bwsr_ns7)){this.Bwsr_mozilla = (navigator.userAgent.indexOf("Netscape")==-1)?true:false;}this.Bwsr_Win = true;this.Bwsr_Mac = (navigator.appVersion.toLowerCase().indexOf("mac")!=-1)?true:false;if(this.Bwsr_Mac){ this.Bwsr_Win = false;}if (this.Bwsr_opera){ this.Bwsr_ns4 = false;this.Bwsr_ns6 = false;  this.Bwsr_ns7 = false; this.Bwsr_ie = false;this.Bwsr_mozilla = false;}if (this.Bwsr_mozilla) { this.Bwsr_ns4 = false;this.Bwsr_ns6 = false;  this.Bwsr_ns7 = false; this.Bwsr_ie = false;this.Bwsr_opera = false;}}function _GetElement(_cID,_oSrc){var doc;if (this.Bwsr_ns4){eval('doc = document.' + _cID);if (! doc){eval('doc = document.layers["'+_cID+'"]');}}if ((this.Bwsr_ns6) || (this.Bwsr_ns7) || (this.Bwsr_opera) || (this.Bwsr_mozilla)){if(_oSrc){doc = _oSrc.getElementById(_cID);}else { doc = document.getElementById(_cID);}}if (this.Bwsr_ie){if(_oSrc){doc = _oSrc.all[_cID];}else { doc = document.all[_cID];}}return doc;}function _GetElementStyle(_cID){var doc;var doc2;if (this.Bwsr_ns4){eval('doc = document.' + _cID);}if ((this.Bwsr_ns6) || (this.Bwsr_ns7) || (this.Bwsr_opera) || (this.Bwsr_mozilla) || (this.Bwsr_safari)){doc2 = document.getElementById(_cID);if(doc2){ doc = doc2.style;} }if (this.Bwsr_ie){doc2 = document.all[_cID]if (doc2){doc = doc2.style;}}return doc;}function _GetElementPosX(obj){ var curleft = 0;if(obj){ if (obj.offsetParent){ while (obj.offsetParent){ curleft += obj.offsetLeftobj = obj.offsetParent;}}else if (obj.x){curleft += obj.x;}}return curleft;}function _GetElementPosY(obj){ var curtop = 0;if(obj){ if (obj.offsetParent){ while (obj.offsetParent){ curtop += obj.offsetTopobj = obj.offsetParent;}}else if (obj.y){curtop += obj.y;}}return curtop;} }
