//-----------------------------
// Pop up functions
// -----
function popupwin(url)
{
	newwindow=window.open(url,'name');
	if (window.focus) {newwindow.focus()}
	return false;	
}

function popup2(page) { window.open(page,'popup','width=370,height=410,toolbar=false,scrollbars=false,status=yes,resizable=yes');}

function popup1(page) {window.open(page,'popup1','width=370,height=310,toolbar=false,scrollbars=false, status=yes, resizable=yes');}


function popupzoom(url,provider,wsize,hsize)
{
	if (provider=='URG') {provider='Urgences';}
	wsize=wsize+40;
	hsize=hsize+20;
	newwindow=window.open(ctry_img_path+"/fr/"+provider+"/"+url,"name","toolbar=no,location=no,directories=no,status=no,scrollbars=1,resizable=no,copyhistory=no,menuBar=no,width="+wsize+",height="+hsize);
	if (window.focus) {newwindow.focus()}
	return false;	
}


function ext_popup(url)
{
/*
	if (url.indexOf("http://")>=0 || url.indexOf("https://")>=0) {
		newwindow=window.open(url,'Extsite');
	} 
	else {
		newwindow=window.open('http://'+url,'Extsite');
	}
*/
 	window.location = url;


	if (window.focus) {
			window.open('http://local.univadis.fr/disclaimer_out_msd.html','Disclaimer','toolbar=no,location=no,directories=no,status=no,scrollbars=0,resizable=no,copyhistory=no,menuBar=no,height=190,width=280');
			//newwindow.focus();
	}
	return false;
}

//-----------------------------
// Go to archives function

function golist_link(list_name) {
	var tab = new Array();

	tab[0] = new Array("ecg", "/medical_and_more/fr_FR_ECG_Intermediate", "Retour &agrave; la liste des ECG");
	tab[1] = new Array("urg", "/medical_and_more/fr_FR_Urgence_Archive", "Retour &agrave; la liste des Urgences ");
	tab[2] = new Array("IDM", "/medical_and_more/fr_FR_IDM_Archive", "Retour &agrave; la liste des Images du mois");
	tab[3] = new Array("INFM_astuces", "/medical_and_more/fr_FR_INFM_Archive?wireID=02782599917f7e25303a2fd406ddc53e&wirename=Fiches%20conseils%20en%20informatique", "Retour &agrave; la liste des astuces");
	tab[4] = new Array("INFM_sites", "/medical_and_more/fr_FR_INFM_Archive?wireID=3b9b8be9f82a7f60a3ae8442a41f1a62&wirename=Site%20de%20la%20semaine", "Retour &agrave; la liste des analyses de sites");
	tab[5] = new Array("INFM", "/medical_and_more/fr_FR_INFM_Archive?wireID=21cc6262feeac2d89559825b3f7490ce&wirename=Informatique%20M&eacute;dicale", "Retour &agrave; la liste des articles");	
	tab[6] = new Array("IMJ_A", "/medical_and_more/fr_FR_Medico_Archive?wireId=623d4a3f54381ae8bf750c3c1c0395ff", "Retour &agrave; la liste des actualit&eacute;s");
	tab[7] = new Array("IMJ_CP", "/medical_and_more/fr_FR_Medico_Archive?wireId=57ac178c0c5b679fac98b0c387827c20", "Retour &agrave; la liste des cas pratiques");
	tab[8] = new Array("IMJ_F", "/medical_and_more/fr_FR_Medico_Archive?wireId=68e3be32d043a9005603be5ef614baec", "Retour &agrave; la liste des formations");
	tab[9] = new Array("IMJ_QCM", "/medical_and_more/fr_FR_Medico_Archive?wireId=3755bc95b046b73e5b5383953550a238", "Retour &agrave; la liste des QCM");
	tab[10] = new Array("IMJ_SP", "/medical_and_more/fr_FR_Medico_Archive?wireId=d55cf7f28cd57ab874cec66338cac3be", "Retour &agrave; la liste des sujets pratiques");
	tab[11] = new Array("JIM", "javascript:window.history.go(-1);", "Retour &agrave; la liste des actualit&eacute;s");


	var longueur=tab.length;

	for (var i = 0; i < longueur; i++)
	{
		if (list_name == tab[i][0]) 
		{
			document.write("<A href='"+tab[i][1]+"'>"+tab[i][2]+"</A>");
		}
	}
}	

//-----------------------------
// QCM IMJ functions

function testerRadio(radio,answer,yesdiv,nodiv) {

  for (var i=0; i<radio.length;i++) {
	 if (radio[i].checked) {
		if (radio[i].value == answer) {
			objYES = document.getElementById(yesdiv);
			objYES.style.position = 'relative';
			objYES.style.visibility = 'visible';
			objYES.style.height = "auto";
		}
		else {
			objNO = document.getElementById(nodiv);
			objNO.style.position = 'relative';
			objNO.style.visibility = 'visible';
			objNO.style.height = "auto";
		}				
	 }
  }
}	


function open_win(value,new_win_height,new_win_width) {
	var new_win;
	var options = "toolbar=no,location=no,directories=no,scrollbars=yes,status=no,"+ "menubar=no,resizable=no,copyhistory=yes,"+ "width=" + new_win_width + ",height=" + new_win_height + ",alwaysRaised=yes";
	if ((new_win)&&(!new_win.closed)) {new_win.close()};
	new_win=window.open(value,'DocumentMedespace',options);
	new_win.focus();
}


function send_colleague(){
var profileGRP="";
var type="medical";

var page_url=escape(window.location.href); sendURL="/medical_and_more/SendAColleague?deeplnkurl="+page_url+"&profileGRP="+profileGRP+"&type="+type+"&articleType=NewsArticle"; 
OpenNewWindow(sendURL,"no","no",'495','405','Send');
}

function url_champs(nom)
{
	var requete = window.location.search;
	if (requete) {
		requete = unescape(requete) ;
		if(requete.indexOf(nom+"=")!=-1)
			{
				requete = requete.substring(requete.indexOf(nom+"="),requete.length);
				requete = requete.substring(requete.indexOf("=")+1,requete.length);
				if(requete.indexOf("&")!=-1)
				{
					requete = requete.substring(0,requete.indexOf("&"));
				}
			}
			else {
				requete="";
			}
	   	}
		else {
			requete="";
		}
	return requete;
}


// TAG SMART ADD SERVER //
//sas_tmstp=Math.round(Math.random()*10000000000);

var sas_masterflag=1;
var sas_tmstp;

function SmartAdServer(sas_pageid,sas_formatid,sas_target) {
// SI MEDCIN on prend l'insertion HOME medecin //

var Checkgood=univadis_fr_code;
 var longch=Checkgood.length;
 var id=Checkgood.substr(0,1);
 id=id.toLowerCase();
// if((sas_pageid=='1531/11534') && (longch==10) && (id=='m'))
if((univadis_fr_code=='ECHADMIN') || ((longch==10) && (id=='m')))
 {
 	sas_pageid='1531/14771';
// 	sas_tmstp=Math.round(Math.random()*10000000000);
        sas_tmstp=UserName+":"+LastName+":"+FirstName;
 }else
 {
// 	sas_tmstp=Math.round(Math.random()*10000000000);
        sas_tmstp=UserName+":"+LastName+":"+FirstName;
 }
 if (sas_masterflag==1) {sas_masterflag=0;sas_master='M';} else {sas_master='S';};
 document.write('<SCR'+'IPT SRC="http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></SCR'+'IPT>');

}


//-----------------------------
// PPP Download functions

function ppp_download() {
	var index=document.ppp_download.elements[0].options.selectedIndex;
	if (index>0) {
		var page=document.ppp_download.elements[0].options[index].value;
		window.open("http://contenu.univadis.fr/portlet/datas/archives/ppp/"+page,"","");
	}
}

function ppp_download2() {
	var index=document.ppp_download2.elements[0].options.selectedIndex;
	if (index>0) {
		var page=document.ppp_download2.elements[0].options[index].value;
		window.open("http://contenu.univadis.fr/portlet/datas/archives/ppp/"+page,"","");
	}
}

function ppp_download_docs(form_name) {
	var index=document.forms[form_name].elements["docs"].options.selectedIndex;
	if (index>0) {
		var page=document.forms[form_name].elements["docs"].options[index].value;
		window.open("http://contenu.univadis.fr/portlet/datas/archives/ppp/"+page,"","");
	}
}


//-----------------------------
// Admindev Download functions

function admindev_link(value,service,new_win_height,new_win_width) {
	var new_win;
	var options = "toolbar=no,location=no,directories=no,scrollbars=yes,status=no,"+ "menubar=no,resizable=no,copyhistory=yes,"+ "width=" + new_win_width + ",height=" + new_win_height + ",alwaysRaised=yes";
	if ((new_win)&&(!new_win.closed)) {new_win.close()};
	new_win=window.open("http://contenu.univadis.fr/portlet/datas/archives/"+service+"/"+value,'DocumentMedespace',options);
	new_win.focus();
}


//------------------------
// info bulle Acces rapide


var IB=new Object;
var posX=0;posY=0;
var xOffset=-50;yOffset=0;

function AffBulle(titre,service) {
	var texte='';
	
	if (service == 'vidal') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://local.univadis.fr/container/images/fr_img/vidal_logo2.jpg' width=70 align='left' vspace='5' hspace='5' /><strong>Un acc&egrave;s illimit&eacute; et gratuit &agrave; la banque de donn&eacute;es VIDAL sur Internet</strong><br>Recherche rapide d'un m&eacute;dicament par nom, laboratoire, substance active, excipient ou classe th&eacute;rapeutique.<br>Affichage du groupe g&eacute;n&eacute;rique d'un m&eacute;dicament.<br>Consultation et impression d'une monographie...</span>";
	}
	else if (service == 'mmerck') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://local.univadis.fr/container/images/fr_img/mmerck_logo2.jpg' width=70 align='left' vspace='5' hspace='5' /><strong>Acc&eacute;dez au Manuel Merck en fran&ccedil;ais</strong><br>Depuis 1899, le Manuel Merck a &eacute;tabli la norme d'excellence dans la communaut&eacute; m&eacute;dicale en fournissant de l'information actuelle, compl&egrave;te et exhaustive sur tous les aspects de la m&eacute;decine. C'est l'ouvrage m&eacute;dical le plus utilis&eacute; dans le monde et le plus ancien texte de m&eacute;decine g&eacute;n&eacute;rale publi&eacute; de fa&ccedil;on continue</span>";
	}
	else if (service == 'anatomie3d') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://www.univadis.fr/RI/common/Anatomy/a_head130-108_1.jpg' width=70 align='left' vspace='5' hspace='5' /><strong>Atlas d'anatomie en 3D </strong><br>un acc&egrave;s gratuit et illimit&eacute; &agrave; l'atlas d'anatomie en ligne le plus complet et le plus d&eacute;taill&eacute; : des milliers de planches en 3D comment&eacute;es par des experts , des animations interactives, des vid&eacute;os....</span>";
	}	
	else if (service == 'fmc') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://casclinique.univadis.fr/images/cc_logo.jpg' width=70 align='left' vspace='5' hspace='5' /><strong>Retrouvez toute la FMC:</strong><br>ECG de la semaine, Urgence de la semaine, Cas clinique de la semaine, Image du mois...</span>";
	}
	else if (service == 'braunwald') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://upp.spis.co.uk/images/bwplus/Rheumatology.gif' width=70 align='left' vspace='5' hspace='5' />Choisissez parmi plus de 4000 images pour construire vos pr&eacute;sentations ou votre banque d'image personnelle.</span>";
	}	
	else if (service == 'pam') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://local.univadis.fr/container/images/fr_img/pa_logo_70.jpg' width=70 align='left' vspace='5' hspace='5' />univadis, en collaboration avec Medi-Emploi, vous propose ses petites annonces professionnelles: remplacements, cessions, emploi, etc.</span>";
	}	
	else if (service == 'fp') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://fp.univadis.fr/images/fp_logo.jpg' width=70 align='left' vspace='5' hspace='5' /><strong>Fiches conseils patients</strong><br>Nous mettons &agrave; votre disposition des fiches conseils imprimables que vous pourrez remettre &agrave; vos patients.<br>Ces fiches sont &eacute;crites par des m&eacute;decins et class&eacute;es par sp&eacute;cialit&eacute;.</span>";
	}
	else if (service == 'liens_med') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://local.univadis.fr/container/images/fr_img/medlinks_logo.jpg' width=70 align='left' vspace='5' hspace='5' />Retrouvez les liens m&eacute;dicaux class&eacute;s par sp&eacute;cialit&eacute;s et proposez vos sites favoris.</span>";
	}
	else if (service == 'agenda') {
		texte="<span style='FONT: 12px Arial,Helvetica; COLOR: #000000'><img src='http://local.univadis.fr/container/images/fr_img/agenda_logo.jpg' width=70 align='left' vspace='5' hspace='5' />Pour tout suivre de l\'actualit&eacute; des congr&egrave;s</span>";
	}	
	

	if(navigator.userAgent.indexOf("Firefox") != -1)
	{
	   contenu="";
	}
	else if(navigator.userAgent.indexOf("MSIE") != -1)
	{
		contenu="<TABLE border=0 cellspacing=0 cellpadding=0 style='border:1px solid #1A4876;width:300px;'><TR bgcolor='#ffffff'><TD><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='#1A4876' width='300'><TR><TD><span style='FONT: bold 12px Arial,Helvetica; COLOR: #FFFFFF'>"+titre+"</span></TD></TR></TABLE><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='#ffffff' width='300'><TR><TD><span style='FONT: 12px Arial,Helvetica; COLOR: #000000'>"+texte+"</span></TD></TR></TABLE></TD></TR></TABLE>&nbsp;";
	}
	else
	{
		contenu="<TABLE border=0 cellspacing=0 cellpadding=0 style='border:1px solid #1A4876;width:300px;'><TR bgcolor='#ffffff'><TD><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='#1A4876' width='300'><TR><TD><span style='FONT: bold 12px Arial,Helvetica; COLOR: #FFFFFF'>"+titre+"</span></TD></TR></TABLE><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='#ffffff' width='300'><TR><TD><span style='FONT: 12px Arial,Helvetica; COLOR: #000000'>"+texte+"</span></TD></TR></TABLE></TD></TR></TABLE>&nbsp;";
	}


  var finalPosX=posX-xOffset;
  if (finalPosX<0) finalPosX=0;
  if (document.layers) {
    document.layers["bulle"].document.write(contenu);
    document.layers["bulle"].document.close();
    document.layers["bulle"].top=posY+yOffset;
    document.layers["bulle"].left=finalPosX;
    document.layers["bulle"].visibility="show";}
  if (document.all) {
    bulle.innerHTML=contenu;
    document.all["bulle"].style.top=posY+yOffset;
    document.all["bulle"].style.left=finalPosX;//f.x-xOffset;
    document.all["bulle"].style.visibility="visible";
  }
  else if (document.getElementById) {
    document.getElementById("bulle").innerHTML=contenu;
    document.getElementById("bulle").style.top=posY+yOffset;
    document.getElementById("bulle").style.left=finalPosX;
    document.getElementById("bulle").style.visibility="visible";
  }
}


function getMousePos(e) {
  if (document.all) {
  posX=event.x+document.body.scrollLeft;
  posY=event.y+document.documentElement.scrollTop;
  }
  else {
  posX=e.pageX;
  posY=e.pageY; 
  }
}

function HideBulle() {
	if (document.layers) {document.layers["bulle"].visibility="hide";}
	if (document.all) {document.all["bulle"].style.visibility="hidden";}
	else if (document.getElementById){document.getElementById("bulle").style.visibility="hidden";}
}

function InitBulle(ColTexte,ColFond,ColContour,NbPixel) {
	IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
	if (document.layers) {
		window.captureEvents(Event.MOUSEMOVE);window.onMouseMove=getMousePos;
		document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
	}
	if (document.all) {
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
		document.onmousemove=getMousePos;
	}

	else if (document.getElementById) {
	        document.onmousemove=getMousePos;
	        document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
	}

}

function TagXITI(){
	var myDocumentElements;
	if (document.all){
		myDocumentElements=document.all.tags("meta");
	}
	else if (document.documentElement){
		myDocumentElements=document.getElementsByTagName("meta");
	}
	if (typeof(myDocumentElements)!="undefined"){
		for (var i=1;i<=myDocumentElements.length;i++){
			myMeta=myDocumentElements.item(i-1);
			if (myMeta.name){
				if (myMeta.name.indexOf('WT.')==0){
					XITI[myMeta.name.substring(3)]=myMeta.content;
				}
			}
		}
	}
	if(typeof(XITI['cg_n'])== "undefined")
	{	var req=document.location.pathname;
		XITI['cg_n'] = req.substr(req.lastIndexOf("/")+1,(req.length - req.lastIndexOf("/")-1));
		if(XITI['cg_n'] == "")
		{
			XITI['cg_n'] = "Home";
		}
		XITI['cg_s'] = "";
	}
}

function is_med(code){
	var flag=2;
	var longch=code.length;
	var id=code.substr(0,1);
	id=id.toLowerCase();
	if((code.length==10) && (id.charAt(0)>='a' && id.charAt(0)<='z'))
	{
		flag=1;
	}
	return flag;
}

//------------------------


//v1.0 IE flash problem
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}



// First View Fonctions

function showHideItems(myItem, myButton){

var myItem = document.getElementById(myItem);

var myButton = document.getElementById(myButton);
if (myItem.style.display != "none") {
	myItem.style.display = "none";
	swapImage(myButton,"plus");
	}
else {
	myItem.style.display = "inline";
	swapImage(myButton,"minus");
	}
}



//********************************************************************************************************
//  SPECIAL OBJECT ADDED BY FRANCE MCC IT :  provides a disclaimer popover for external links
//
// this behaviour is AUTOMATICALLY added to links with the class attribute 'externalDisclaimer'
// 
//univadis blue       1A4876
//univadis orange     FD9C0C
// 20110322(SR) fix: same url for different links bug
  
  
function dynAddJs(url)
{
    var h  = document.getElementsByTagName("head")[0];
    var s  = document.createElement('script');
    s.src  = url;
    s.type = 'text/javascript';
    h.appendChild(s);
}


function dynAddCss(url)
{
    var h   = document.getElementsByTagName("head")[0];
    var l   = document.createElement('link');
    l.type  = 'text/css';
    l.rel   = 'stylesheet';
    l.href  = url;
    l.media = 'screen';
    h.appendChild(l);
}

//add partial support for a debug console in IE and prevent IE errors
if ( !('console' in window) )
{
    window._FALSE_LOG = '';
    window.console = { log : function(obj){window._FALSE_LOG = window._FALSE_LOG + "\n" + obj;},
                       warn: function(obj){window._FALSE_LOG = window._FALSE_LOG + "\n" + obj;},
                       info: function(obj){window._FALSE_LOG = window._FALSE_LOG + "\n" + obj;},
                       show: function(){alert(window._FALSE_LOG);}
                     };
}


//********************************************************************
// TODO : add content management
// TODO : improve use cases : simple popover along 'special' ones
// TOD  : manage classes and tags better
// TODO : create interceptEvent function
// TODO : position logic in displayXXX functions
// TODO : center popOver vertically according to position in page


var univadisPopOver =  {

    bodyTag          : (function(){return document.getElementsByTagName('body')[0];}),
    htmlTag          : document.getElementsByTagName('html')[0],
    defaultClassName : 'externalDisclaimer', // css must be changed accordingly
    isModal          : true,
    tagBydDefault    : 'a',
    
    popOverId        : 'univadisPopOver', // css must be changed accordingly
    //popOverContent   : ',
    
    overlayId        : 'univadisPopOverOverlay', // css must be changed accordingly

    displayWidth     : (function(){ return univadisPopOver.htmlTag.scrollWidth  || univadisPopOver.getViewportSizes().width ; }), 
    displayHeight    : (function(){ return univadisPopOver.htmlTag.scrollHeight || univadisPopOver.getViewportSizes().height; }),
    
    overlayDismissOnClick : true,
    
    customContent    : null,
    
   
    attach           : function (tagType){
                            console.info('attach');
                            var tag = this.tagBydDefault;
                            if( typeof(tagType) !== 'undefined' )
                            {
                                tag = tagType;
                            }
                            tagLists = document.getElementsByTagName(tag);
                            var i = 0;
                            var imax = tagLists.length;
                            var elementsFound = [];
                            for(i; i<imax ; i++)
                            {
                                var t = tagLists[i];
                                if( t.className === this.defaultClassName )
                                {
                                    t.onclick = this.display;//console.log('trouvÃ©:' + t.tagName);
                                    elementsFound.push(t);
                                }
                            }
                            return elementsFound.length;
                        },
    
    getViewportSizes : (function(){
                            console.info('getViewportSizes');
                           
                            var d = document;
                            var w = window;
                          
                            var height = w.innerHeight || d.documentElement.clientHeight || this.bodyTag.clientHeight;
                            var width  = w.innerWidth  || d.documentElement.clientWidth  || this.bodyTag.clientWidth;

                            return { 'width': width , 'height': height };
                        }),
    
    display          : function(event){
                        console.info('display'); //console.log(event);
                        //prevent link execution
                        var e = event || window.event;
                        if( undefined !== e.preventDefault )// && typeof() === 'function') //stop browser from following href value
                        {
                            e.preventDefault();
                        }
                        else
                        {
                            e.returnValue = false; // IE branch - do more tests if that's not enough
                        }
                        
                        var tag = e.currentTarget || e.srcElement;
                        
                        
                        if( univadisPopOver.isModal )
                        {
                            univadisPopOver.displayOverlay.call(univadisPopOver);
                        }
                        
                        if( typeof(this.customContent) !== 'null' )
                        {
                            univadisPopOver.displayPopOver.call(univadisPopOver, tag);
                        }
                    },
                    
    displayOverlay   : function(customContent){
                        console.info('displayOverlay');//console.log(this);
                        var o = document.getElementById(this.overlayId);
                                                                        
                        if(o)
                        {
                            o.style.display = 'block'; 
                        }
                        else
                        {                            
                            this.bodyTag().appendChild( this.createOverlay() );
                        }
                    },

    displayPopOver   : function(tagObject){
                        console.info('displayPopOver'); //console.log(this);
                        var p = document.getElementById( this.popOverId );
                        var content = this.getContent(tagObject);
                        if(p)
                        {
                            p.innerHTML = content;
                            p.style.display = 'block'; 
                        }
                        else
                        {
                             this.createPopOver(content);
                        }
                    },
                    
    createOverlay    : function(){
                        console.info('createOverlay'); // console.log(this);
                        var overlay = document.createElement('div'); 
                        overlay.setAttribute("id", this.overlayId);

                        var vpSizes = this.getViewportSizes();
                        overlay.style.width  = vpSizes.width  + 'px';
                        // overlay.style.height = vpSizes.height + 'px';
                        overlay.style.height = univadisPopOver.htmlTag.scrollHeight + 'px';
                        overlay.innerHTML    = '&nbsp;';
                        
                        if(this.overlayDismissOnClick){
                            overlay.onclick = univadisPopOver.removePopOver;
                        }
                        return overlay;
                    },
                    
    createPopOver    : function(content){
                        console.info('createPopOver'); 
                        var popOver = document.createElement('div');
                        
                        // popOver settings
                        popOver.setAttribute("id", this.popOverId);                       
                        //popOver content setting
                        var popOverContent = content;
                        if( (typeof(content) === 'undefined')  &&  (typeof(content) === '')  )
                        {
                           popOverContent = this.getContent(); 
                        }
                        popOver.innerHTML = popOverContent;

                        // this 'iframe' tag is appended to avoid z-index bug with form elements in ie6 (it..again)                  
                        popOver.appendChild(document.createElement('iframe'));
                        this.bodyTag().appendChild(popOver);
                        
                        var vpSizes = this.getViewportSizes();
                        
                        var popHeight = popOver.style.height.replace(/px/, '');
                        var popWidth  = popOver.style.width.replace(/px/, '');
                        
                        popOver.style.top  = ( vpSizes.height - popHeight )/2.5 + 'px';
                        popOver.style.left = ( vpSizes.width - popWidth  )/2.5 + 'px';
                                             
                        
                        return popOver;
                    },
                   
    removePopOver    : function(event){
                        console.info('removePopOver'); //console.log(this);
                        //we don't really remove the overlay and popOver divs since we may need them in the future and its faster re-enabling display than creation
                        var popover = document.getElementById(univadisPopOver.popOverId);
                        var overlay = document.getElementById(univadisPopOver.overlayId);
                        
                        overlay.style.display = popover.style.display = "none";
                    },
                    
    getContent       : function(tagObject){
                            console.info('getContent');     
                            if( typeof(tagObject) !== 'object' )
                            {
                                console.error('tagObject: not an objet!');
                                console.error(tagObject);
                                return "Une erreur s'est produite. Veuillez réessayer.";
                            }
                            var customContent = '<a href="' + tagObject.href + '" id="closePopOver" onclick="removePopOver(event);">' + (tagObject.title || tagObject.innerHTML) + '</a>';
                            
                            switch( tagObject.toLowerCase )//is there some specific information to extract (according to tag)
                            {
                                case 'a': break;
                                default: customContent = '<img src="http://www.univadis.fr/RI/fr_FR/univadis.gif" alt="univadis logo - mÃ©dical et davantage"/>' +
                                                          '<br /><br /><p>En cliquant sur "Continuer" vous allez quitter le site univadis.fr.</p>' +
                                                          '<p>Celui-ci restera disponible en arriÃ¨re plan</p>' +
                                                          '<br /><p><a href="' + tagObject.href + '" target="_blank" class="defaultBtn" onclick="univadisPopOver.removePopOver();">Continuer</a></p>';
                            }
                            return customContent;
                       },
                    
    init             : function(){
                            console.info('init');
                            dynAddCss('http://contenu.univadis.fr/univadis/_css/univadisPopOver.css');
                            this.attach();
                        }
};

var old_onload = window.onload;

window.onload = function() {
    univadisPopOver.init();
    if (old_onload){
        old_onload();
    }
};

//********************************************************************************************************

//*********************************************Video Tutorial for Pharmacists START*********************************************************
// IMPORTANT : jQuery is assumed to be present
if( !("console" in window) )
{
	window._console = '###CONSOLE START###';
	var consoleFunction = function(t){window._console += t; };
	window.console = { log :  consoleFunction, 
		               info:  consoleFunction,
		               warn:  consoleFunction,
		               show: alert(window._console)
		             };
}
/**
	Ajoute au dom les scripts(js) + styles(css) qui sont utilisés dans le tutorial video pour les Pharmaciens
*/
function tutorialsAssets()
{
	var d = document;

	//var tutorialJs   = $( d.createElement('script') ).attr('type', 'text/javascript').attr('src', 'http://contenu.univadis.fr/univadis/_js/didacticielPharma/overlayFlashPlayer.js');
	//var flowplayerJs = $(d.createElement('script') ).attr('type', 'text/javascript').attr('src', 'http://contenu.univadis.fr/univadis/_js/flowplayer/flowplayer-3.2.6.min.js');
	var tutorialCss  = $( d.createElement('link') ).attr('type', 'text/css').attr('rel', 'stylesheet').attr('href', 'http://contenu.univadis.fr/univadis/_css/didacticielPharma/didacticiel.css');


	$(tutorialCss).appendTo( $('head') );console.log('loading tutorialCss');
	//$(flowplayerJs).appendTo( $('head') );
	//$(tutorialJs).appendTo( $('head') );console.log('loading tutorialjs');
	
	$.getScript('http://contenu.univadis.fr/univadis/_js/flowplayer/flowplayer-3.2.6.min.js', function(data, textStatus){
	    console.log('loading flowplayerJs');
            $.getScript('http://contenu.univadis.fr/univadis/_js/didacticielPharma/overlayFlashPlayer.js', function(data, textStatus){
	         $(document).ready(tutorialsVideos);console.log('lauching tutorialsVideos()');
	    });
        });
};

var previousOnload = window.onload;

window.onload = function() {
//we wait for jQuery being defined : dirty way to do it but are in a hurry
   //while(typeof(window.$) == "undefined")
//	{
		//do nothing : just wait while loading from another domain
//	}
  //  $(document).ready(tutorialsAssets);
//    if (previousOnload ){
   //    previousOnload();
  //  }
};


//*********************************************Video Tutorial for Pharmacists END***********************************************************

