/**************************************************************************************************************/
/**************************************************************************************************************/
var CBON = 1;

var sDateSep =  ".";
var sTimeSep =  ":";

var sTimePattern = /^(\d{1,2}):(\d{2})?$/;
var sDatePattern = /^(\d{1,2}).(\d{1,2}).(\d{2,4})?$/;

var iHreMin   =    0; var iHreMax   =   23; 
var iMinMin   =    0; var iMinMax   =   59;
var iSecMin   =    0; var iSecMax   =   59;
var iYearMin  = 1900; var iYearMax  = 2100;
var iMonthMin =    0; var iMonthMax =   12; 
var iDayMin   =    0; var iDayMax   =   31; 


dToday = new Date(); 
var isIE      = ((navigator.userAgent.indexOf("MSIE")    >= 0) ? 1 : 0);
var isFirefox = ((navigator.userAgent.indexOf("Firefox") >= 0) ? 1 : 0);
var isSafari  = ((navigator.userAgent.indexOf("Safari")  >= 0 && navigator.vendor.indexOf("Apple")   >= 0) ? 1 : 0);
// alert("isIE ? " + isIE + "\n" + "isFirefox ? " + isFirefox + "\n" + "isSafari ? " + isSafari );

function getSiteExtention(){ 
    var site          = window.location.host;
    var siteExtension = site.substring(site.lastIndexOf('.')+1, site.length);
    return (siteExtension); 
};

var complStatus = '';
//window.defaultStatus = complStatus + 'MAVALA INTERNATIONAL SA';
window.Status = 'MAVALA INTERNATIONAL SA';

var iWidth  = 0  ;
var iHeight = 0 ;
/**************************************************************************************************************/
/**************************************************************************************************************/

function show_hide(obj)      { if (isDisplayed(obj) ){ hide     (obj) }else{ show   (obj) }};
function visibility(obj)     { if (isVisible  (obj) ){ invisible(obj) }else{ visible(obj) }} ;

function visible(obj)    { obj.style.visibility = 'visible'; };
function invisible(obj)  { obj.style.visibility = 'hidden';  };
function isVisible(obj)  { return (obj.style.visibility != 'hidden');};

function show(obj)       { obj.style.display = 'inline'    };
function hide(obj)       { obj.style.display = 'none';     };
function isDisplayed(obj){ return (obj.style.display != 'none' && obj.style.display != '') ;};
function getDisplayed(obj){ return (obj.style.display); };

function selectImag(objImagSelected, objImagPlaceHolder, objValue, objNamePlaceHolder){
    objValue.value         = objImagSelected.id;  
    objImagPlaceHolder.src = objImagSelected.src; 
}
/*============================================================================================================*/
// placer des div                                                                                               
function placeAndShow( objDiv, objDivSelectImag, objClick, objValue, e){
 	var posx = 0;
  	var posy = 0;
    var referenceObject = document.getElementById('divBody');
    var posDivLeft = document.getElementById('divBody').offsetLeft;
    var posDivTop  = document.getElementById('divBody').offsetTop;
   	if (!e) var e = window.event;
   	if (e.pageX || e.pageY){
   		posx = e.pageX-posDivLeft+referenceObject.scrollLeft + 10;
   		posy = e.pageY-posDivTop+referenceObject.scrollTop + 10;
   	}else if (e.clientX || e.clientY){
   		posx = e.clientX + document.body.scrollLeft;
   		posy = e.clientY + document.body.scrollTop;
   	}
    //alert(getAbsoluteLeft(objClick) + " x " + getAbsoluteTop(objClick));
    //objDiv.style.left = getAbsoluteLeft(objClick) + objClick.width - posDivLeft;
    //objDiv.style.top  = getAbsoluteTop(objClick) + objClick.height - posDivTop;

    //alert(e.pageX + " x " + e.pageY + "\n" + (e.clientX+document.body.scrollLeft) + " x " + (e.clientY+document.body.scrollTop) + "\n" + document.body.scrollLeft + " x " + document.body.scrollTop);
    //  alert((posx-posDivLeft) + " x " + (posy-posDivTop));
    objDiv.style.left = posx ;
    objDiv.style.top  = posy ;
    //alert(e.pageX + " x " + e.pageY + "\n" + objDiv.style.left + " x " + objDiv.style.top);
    //alert(posDivLeft + " x " + posDivTop);
    if ((objValue == null) || getCBState(objValue)==CBON) show_hide (objDiv);

    //objDivSelectImag.style.height = iHeight-posy-40-140-41;
}

/*============================================================================================================*/
// valider mon email                                                                                            
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
/*============================================================================================================*/
// trier mon select                                                                                             
function sortArray(objSelect){
    Liste= new Array();

    for(i = 0 ; i < objSelect.options.length ; i++){
        Liste[i]=new Array()
        Liste[i][0] = objSelect.options[i].text
        Liste[i][1] = objSelect.options[i].value
    }
    Liste=Liste.sort()

    for(i=0;i < objSelect.options.length;i++){
        objSelect.options[i].text=Liste[i][0]
        objSelect.options[i].value=Liste[i][1]
    }
}
/*============================================================================================================*/
// ajouter les éléments à une liste déroulante                                                                  
function addOption(objLb, strText, strValue, strStyle){
    var opt = new Option(strText, strValue, false, false );
    if (strStyle!='') opt.className=strStyle;
 
    objLb[objLb.length] = opt;
}
/*============================================================================================================*/
// passer des éléments d'une liste déroulante à l'autre                                                         
function moveOption(objFrom, objTo, strStyle){
    if (objFrom.selectedIndex<0) return;
    if (objFrom.options[objFrom.selectedIndex].value == 0) return;
    var opt = new Option(objFrom.options[objFrom.selectedIndex].text, 
                                     objFrom.options[objFrom.selectedIndex].value,
                                     false,
                                     false
                                    );
    if (strStyle!='') opt.className=strStyle;
   
    objTo[objTo.length] = opt;
    objFrom.options[objFrom.selectedIndex] = null;
}

/*============================================================================================================*/
// Calcul des tailles de la fenetre                                                                             
function setSizes(){
    if (isFirefox || isSafari) {
        iWidth  = window.innerWidth  ;
        iHeight = window.innerHeight ;
    }else{
        iWidth  = document.body.offsetWidth  ;
        iHeight = document.body.offsetHeight ;
    }
}
/*============================================================================================================*/
// Calcul des tailles de la surface affichable                                                                  
function getDisplaySize(){   
    setSizes();
    return (iHeight - 25/*bannUp*/ - 78/*bann*/ - 25/*navi*/ - 25/*menu*/ - 0/* main */ - 53/*bott*/);
}
/*============================================================================================================*/
// Set de l'image CB                                                                                            
function clickCB(imgObj, inputObj, path, valOn, valOff){
    if ( inputObj.value == valOn){
        imgObj.src = path + valOff + '.gif';
        inputObj.value = valOff;
    }else{
        imgObj.src = path + valOn + '.gif';
        inputObj.value = valOn;
    }    
}
/*============================================================================================================*/
// get de l'état d'une image CB                                                                                 
function getCBState(inputObj){
    return (inputObj.value);
}

/*============================================================================================================*/
// Renvoie le left absolu de l'objet                                                                            
function getAbsoluteLeft(oNode){
   var oCurrentNode=oNode;
   var iLeft=0;
   while(oCurrentNode.tagName!="BODY"){
      iLeft+=oCurrentNode.offsetLeft;
      oCurrentNode=oCurrentNode.offsetParent;
   }
   return (iLeft);
}
/*============================================================================================================*/
// Renvoie le top absolu de l'objet                                                                             
function getAbsoluteTop(oNode){
   var oCurrentNode=oNode;
   var iTop=0;
   while(oCurrentNode.tagName!="BODY"){
      iTop+=oCurrentNode.offsetTop;
      oCurrentNode=oCurrentNode.offsetParent;
   }
   return (iTop);
}
/*============================================================================================================*/
// cette fonction a pour objectif de faire fonctionner les rollOver sur toutes les pages                        
function OCRollOver240903Jom() { 
    if (!document.getElementById) return;
    var imgOriginSrc;
    var imgTemp  = new Array();
    var imgAlpha = new Array();
    var imgarr = document.getElementsByTagName('img');
    for (var i = 0; i < imgarr.length; i++) {
        if (imgarr[i].getAttribute('hsrc')) {
            imgTemp[i]            = new Image();
            imgTemp[i].src        = imgarr[i].getAttribute('hsrc');
            imgarr[i].onmouseover = function() {
                                        imgOriginSrc = this.getAttribute('src');
                                        this.setAttribute('src',this.getAttribute('hsrc'));
                                    }
            imgarr[i].onmouseout = function() {this.setAttribute('src',imgOriginSrc);};
        }
    }
}
/*============================================================================================================*/

function tdSet (obj, iScheme){
    obj.style.cursor = 'pointer';
    switch(iScheme){
    case  1 : // scheme pour la navi                                                                            
              obj.style.color = '#666666'; obj.style.background = '#ffffff';                                        
              break;
    case  2 : // scheme pour le menu                                                                            
              obj.style.color = '#666666'; obj.style.background = '#ffffff'; 
              break;
    case  3 : // langues dans la page d'index                                                                   
              obj.style.color = '#ffffff'; 
              break;
    case  4 : // scheme pour les bannUp                                                                         
              obj.style.color = '#666666'; obj.style.background = '#ffffff'; 
              break;
    case 41 : // ?                                                                                              
              obj.style.border = "0px"; obj.style.borderBottomColor="#555555";
              break;
    case 42 : // ?                                                                                              
              obj.style.border = "0px"; obj.style.borderBottomColor="#aaaaaa";
              break;
    case  5 : // ?                                                                                              
              obj.style.background = "#d0d0d0"; obj.style.borderBottomColor="red"; obj.style.borderRightColor="#B0B0B0";
              break;
    case  51: // scheme pour pour les membres                                                                   
              obj.style.background = "#efefef";
              break;
    case  52: // scheme pour pour les membres                                                                   
              obj.style.background = "#dddddd";
              break;
    case  6 : // ?                                                                                              
              obj.style.color = '#efefef'; obj.style.background='gray';
              break;
    case  7 : // ?                                                                                              
              obj.style.backgroundColor='#ffffff';
              break;
    default : // par défaut, si pas de scheme sélectionné, on prend case 1 par défaut.                          
              obj.style.color = '#ffffff'; obj.style.background = '#005782';
    }
}

/*============================================================================================================*/

function tdReset (obj, iScheme){
    switch(iScheme){
    case  1 : // scheme pour la navi                                                                            
              obj.style.color = '#666666'; obj.style.background = '#ffffff'; 
              break;
    case  2 : // scheme pour le menu                                                                            
              obj.style.color = '#666666'; obj.style.background = '#ffffff'; 
              break;
    case  3 : // langues dans la page d'index                                                                   
              obj.style.color = '#aaaaaa'; 
              break;
    case  4 : // langues dans la page d'index                                                                   
              obj.style.color = '#666666'; obj.style.background = '#ffffff'; 
              break;
    case 41 : // ?                                                                                              
              obj.style.border="0px"; obj.style.borderBottomColor="#aaaaaa";
              break;
    case 42 : // ?                                                                                              
              obj.style.border="0px"; obj.style.borderBottomColor="#efefef";
              break;
    case  5 : // ?                                                                                              
              obj.style.background = "#efefef"; obj.style.borderBottomColor="#e3e3e3"; obj.style.borderRightColor="#e3e3e3";
              break;
    case  51: // scheme pour pour les membres                                                                   
              obj.style.background = "#ffffff";
              break;
    case  52: // scheme pour pour les membres                                                                   
              obj.style.background = "#efefef";
              break;
    case  6 : // ?                                                                                              
              obj.style.color = 'gray'; obj.style.background='#efefef';
              break;
    case  7 : // ?                                                                                              
              obj.style.backgroundColor='#efefef';
              break;
    default : // par défaut, si pas de scheme sélectionné, on prend case 1 par défaut.                          
              obj.style.color = '';     obj.style.background = '';
    }
}
/*============================================================================================================*/
//activation et desactivation d'une image en estompee                                                           
//les deux lignes suivantes sont a activer dans le cas d'une utilisation de la fonction nereidFade.             
/**************************************************************************************************************/
/**************************************************************************************************************/
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
/**************************************************************************************************************/
/**************************************************************************************************************/

// object - image to be faded (actual object, not name);                                                        
// destop - destination transparency level (ie 80, for mostly solid)                                            
// rate   - time in milliseconds between trasparency changes (best under 100)                                   
// delta  - amount of change each time (ie 5, for 5% change in transparency)                                    

function nereidFade(object, destOp, rate, delta){
    if (!document.all) return;
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp) direction = -1;
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}
// Exemple
//<img src="B2iconcrop.gif" style="filter:alpha(opacity=10)" onmouseover="nereidFade(this,100,30,5)" onmouseout="nereidFade(this,10,50,5)">

function dispHiddenFields(){
    var tabInput = document.getElementByTagName('input');
    if (!document.getElementById) return;
    for (var i = 0; i < tabInput.length; i++) {
        if (tabInput[i].getAttribute('type')) {
            typeInput = tabInput[i].getAttribute('type');
            if (typeInput=='hidden') {
                tabInput[i].setAttribute('type', 'text', 0);
            }
        }
    }
}

/*============================================================================================================*/
function onLoadPage2(){
    OCRollOver240903Jom();
    //dispHiddenFields();
}                        
/*============================================================================================================*/
function onUnloadPage2(){}
/*============================================================================================================*/

/**************************************************************************************************************/
/**************************************************************************************************************/
onload   = onLoadPage2;
onunload = onUnloadPage2;
/**************************************************************************************************************/
/**************************************************************************************************************/

