//<!--
// JS CORE Version 1.0
// (C) SQLPAC 2010.  
//
// Revision dd mm YYYY	
//
//
//

/**
 * This function allows you to add onload functions 
 * without overridding other functions that may have been
 * assigned to window.onLoad()
 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

/** addLoadEvent(function() {
if (document.getElementById) {
	var navRoot = document.getElementById("nav");
	if(navRoot) {
		for (i=0; i < navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI" && node.id) {
				if(document.getElementById("mega" + node.id)) {
					var menu = HeaderMenu(node.id, node);
					node.onmouseover= function(e) {
						this.showMenu(e);
					};
					node.onmouseout = function(e) {
						this.hideMenu(e);
					};
				}
			}
		}
	}
}})
*/

/**-------------------------------------------------------------*/
/**                                    				*/
/** Fonction Javascript de redirection 				*/
/**                                    				*/
/**-------------------------------------------------------------*/
function fc_redirect(url) {
		var i_timeOut=2;
		setTimeout("document.location ='" + url + "'", i_timeOut) 
}

/**-------------------------------------------------------------*/
/**                                    				*/
/** Fonction Javascript d'ouverture de POPUPS 			*/
/**                                    				*/
/** Ancien nom : fc_openPopupWindow                             */
/**-------------------------------------------------------------*/
function fc_openPopupWindow(url,windowname,width,height,status,resizable,scrollbars) {

    width=(width)?width:screen.width/3;
    height=(height)?height:screen.height/3;
    status=(status)?'yes':'no';
    resizable=(resizable)?'yes':'no';
    scrollbars=(scrollbars)?'no':'yes';

    var screenX = (screen.width/2 - width/2);
    var screenY = (screen.height/2 - height/2);
    var features= "width=" + width + ",height=" + height;
    features += ",screenX=" + screenX + ",left=" + screenX;
    features += ",screenY=" + screenY  +",top=" + screenY;
    features += ",status=" + status;
    features += ",resizable=" + resizable;
    features += ",scrollbars=" + scrollbars;
	
	if (url.indexOf("?")==-1) { url += "?"; } else { url += "&"; }
	url += "afwk_sys_ispopup=1";
	 
    var Wop=window.open(url, windowname, features);
    if (Wop)
        Wop.focus();
    else {
          msg  = "L'ouverture des fenêtres Popups est désactivée !\n";
          msg += "Veuillez vérifier la configuration de votre navigateur pour pouvoir utiliser l'application.\n";
          alert(msg);
    }
    return Wop;
}

/**-------------------------------------------------------------*/
/**                                    				            */
/** Fonction Javascript de confirmation de suppression 		    */
/**                                    				            */
/**-------------------------------------------------------------*/
function fc_confirmRemove(value,mode) {
	 if (mode=="file") {
         	var s_message = "Etes vous sûr(e) de vouloir supprimer le fichier : \n";
	 }
	 else {
		var s_message = "Etes vous sûr(e) de vouloir supprimer l\'enregistrement : \n";
	 }
         s_message +=  " \"" + value + " \"";
         s_message += " ?";
         if (confirm(s_message)==1) {return true;}
         return false;
}

function fc_showhideDiv(obj,imgPlus,imgMinus)
{
 /** Simplification du masquage des div */
 if (document.getElementsByName(obj)[0].style.visibility=="hidden" || ! isNaN(document.getElementsByName(obj)[0].style.visibility))  {
     document.getElementById(obj+"_img").src=imgMinus;
     document.getElementById(obj+"_img").title="Réduire";
     document.getElementsByName(obj)[0].style.height = "auto";
     document.getElementsByName(obj)[0].style.visibility="visible";
     document.getElementsByName(obj)[0].style.display="block";
 }
 else {
     document.getElementById(obj+"_img").title="Développer";
     document.getElementById(obj+"_img").src = imgPlus;
     document.getElementsByName(obj)[0].style.visibility="hidden";
     document.getElementsByName(obj)[0].style.display="none";
 }
}



/**-------------------------------------------------------------*/
/**                                                             */
/** Fonction Javascript de check du referrer                    */
/**                                                             */
/**-------------------------------------------------------------*/
function fc_checkReferrer(rules,action) {
    var urlback = document.referrer;
    var wop = window.opener;
    var urltocheck = "";

    if (urlback != "") { urltocheck = urlback;  }
    else {
          if (wop!=null) { urltocheck = wop.document.URL; }
    }

    var hostPrefixPages = rules.split("#");
    var hostName = "http://" +  hostPrefixPages[1];

    pfxPages = hostPrefixPages[0].split("|");

    var isChecked=0;
    if (pfxPages.length > 0) {
     for(var i = 0; i < pfxPages.length; ++i) {
         if (urltocheck.indexOf(pfxPages[i]) >= 0 &&
             urltocheck.indexOf(hostName) >= 0) { isChecked=1; break; }
     }
    }

    if (isChecked==0) { document.location.href=action; };
}

/**-------------------------------------------------------------*/
/**                                                             */
/** Fonction Javascript d'affichage du bandeau                  */
/** Fin support IE 6                                            */
/**-------------------------------------------------------------*/
function fc_buildEndSupport() {
						var agt=navigator.userAgent.toLowerCase();

      var is_ie  = ((agt.indexOf("msie") != -1));
						if (is_ie) {version = parseFloat(navigator.appVersion.split("MSIE")[1]);}
     
      if (is_ie && version <= 6) {        
        document.write("<div style='border:1px dotted silver; width:500px; padding:10px; font-size:10px; margin-bottom:10px; color:maroon;' >");
        document.write("Internet Explorer 6 n'est plus supporté. L'affichage et les nouveautés peuvent ne plus fonctionner avec cette version. ");
        document.write("Au delà de la migration vers Internet Explorer 7, 8 ou 9, les navigateurs autonomes suivants sont supportés et recommandés : ");
        document.write("<br>");
        document.write("<img src='/images/system/icon_chrome.png' alt='Chrome'><a href='http://www.google.com/chrome?hl=fr' onclick='javascript:window.open(this.href); return false;' rel='follow'>Chrome</a> | ");
        document.write("<img src='/images/system/icon_firefox.png' alt='FireFox'><a href='http://www.mozilla-europe.org/fr/' onclick='javascript:window.open(this.href); return false;' rel='follow'>FireFox</a> | ");
        document.write("<img src='/images/system/icon_opera.png' alt='Opera'><a href='http://www.opera.com/' onclick='javascript:window.open(this.href); return false;' rel='follow'>Opera</a> | ");
        document.write("<img src='/images/system/icon_safari.png' alt='Safari'><a href='http://www.apple.com/fr/safari/' onclick='javascript:window.open(this.href); return false;' rel='follow'>Safari</a> ");
        document.write("</div>");       
      }

}


