document.createElement('abbr');

novUtils.addEvent(window,'load',caracInit);

function caracInit() {
	if (novUtils.$('encart_enquete')) initEncartEnquete();
	initImprimer();
	initFavoris();
	initPanno();
	initDesc();

}


/*********************/
/* initEncartEnquete */
/*********************/
function initEncartEnquete() {
	var divEncartEnquete=novUtils.$('encart_enquete');
	divEncartEnquete.style['marginLeft'] = '-250px';
	divEncartEnquete.style['opacity'] = '0';
	divEncartEnquete.style['position'] = 'absolute';
	divEncartEnquete.style['left'] = '50%';
	divEncartEnquete.style['top'] = '250px';
	divEncartEnquete.style['zIndex'] = '1';
	incropacity(divEncartEnquete,0);
	novUtils.$('plusTard').onclick=function(){
		novUtils.$('encart_enquete').style.display='none';
	}


	function incropacity(obj,alpha) {
	if (alpha<=100)
	{
		alpha+=5;
		obj.style['opacity']=alpha/100;
		obj.style['filter']="alpha(opacity="+alpha+")";
		setTimeout(function (){ incropacity(obj,alpha); }, 14);
	}
}

}

/*******************/
/* initTelecharger */
/*******************/
function initImprimer() {
	if(novUtils.$('impression'))
	{
		novUtils.$('impression').style['display'] = "block";
		novUtils.$('impression').onclick=function(){
			print();
			return false;
			};
	}
	return false;
}

/***************/
/* initFavoris */
/***************/
function initFavoris() {
	if (window.ActiveXObject) {
		if(novUtils.$('ajoutFavoris')){
			novUtils.$('ajoutFavoris').style['display'] = "block";
			novUtils.$('ajoutFavoris').onclick=function(){
				window.external.AddFavorite(location.href,document.title);
				return false;
			}
		}
	}
	return false;
}

/***************/
/* initPanno */
/***************/
function initPanno() {
	var pannoViewer=novUtils.getElementsByClassName('viewPanno','div');
	var pannoViewerTmp=novUtils.getElementsByClassName('viewPanno','span');
	if(pannoViewerTmp.length>0)
		pannoViewer = pannoViewer.concat(pannoViewerTmp);

	var pannoViewerLength=pannoViewer.length;
	for(var i=0; i<pannoViewerLength; i++){
		idDivPanno=pannoViewer[i].getAttribute('rel');
		novUtils.$(idDivPanno).style['display'] = "none";
		pannoViewer[i].onmouseover = function(e){
			this.style['textDecoration']='underline';
			this.style['color']='#4B7284';
			this.style['cursor']='pointer';

			//pointeur de fonction
			document.onmousemove = get_mouse;
			return false;
		}
		pannoViewer[i].onmouseout = function(){
			this.style['textDecoration']='';
			this.style['color']='';
			this.style['cursor']='pointer';
			novUtils.$(this.getAttribute('rel')).style['display'] = "none";
			document.onmousemove = null;
			return false;
		}
	}
}

function get_mouse(e) {
	var idRef = novUtils.getEvtTarget(e).getAttribute('rel');
	if (idRef!=null){

		var x = (window.ActiveXObject) ? (event.x)  : e.pageX ;
		var y = (window.ActiveXObject) ? (event.y)  : e.pageY ;
		if(!(window.ActiveXObject))
		{
			x=parseInt(x)-parseInt(novUtils.getLeft(novUtils.$("idFor_"+idRef)))+20;
			y=parseInt(y)-parseInt(novUtils.getTop(novUtils.$("idFor_"+idRef)))-40;
		}
		else
		{
			x=parseInt(x)+20;
			y=parseInt(y)-40;
		}
		//redéfini le style du div à afficher
		novUtils.$(idRef).style['left'] = x+"px";
		novUtils.$(idRef).style['top'] = y+"px";
		novUtils.$(idRef).style['display'] = "block";
		novUtils.$(idRef).style['position'] = "absolute";
		novUtils.$(idRef).style['border'] = "1px solid #528EA5";
		novUtils.$(idRef).style['background'] = "#E7EBF7";
		novUtils.$(idRef).style['width'] = "200px";
		novUtils.$(idRef).style['padding'] = "5px";
		novUtils.$(idRef).style['textDecoration'] = "none";
		novUtils.$(idRef).style['zIndex'] = "10";
		novUtils.$(idRef).style['zoom'] = "1";
	}
}

/***************/
/* initDesc */
/***************/
function initDesc() {
	var descViewer=novUtils.getElementsByClassName('viewDesc','span');
	var descViewerLength=descViewer.length;
	for(var i=0; i<descViewerLength; i++){
		idDivPanno=descViewer[i].getAttribute('rel');
		novUtils.$(idDivPanno).style['display'] = "none";
		descViewer[i].onmouseover = function(e){
			this.style['textDecoration']='underline';
			this.style['color']='#4B7284';
			this.style['cursor']='pointer';

			//pointeur de fonction
			document.onmousemove = get_mouse;
			return false;
		}
		descViewer[i].onmouseout = function(){
			this.style['textDecoration']='';
			this.style['color']='';
			this.style['cursor']='pointer';
			novUtils.$(this.getAttribute('rel')).style['display'] = "none";
			document.onmousemove = null;
			return false;
		}
	}
}

function get_mouse(e) {
	var idRef = novUtils.getEvtTarget(e).getAttribute('rel');
	if (idRef!=null){

		var x = (window.ActiveXObject) ? (event.x)  : e.pageX ;
		var y = (window.ActiveXObject) ? (event.y)  : e.pageY ;
		if(!(window.ActiveXObject))
		{
			x=parseInt(x)-parseInt(novUtils.getLeft(novUtils.$("idFor_"+idRef)))+20;
			y=parseInt(y)-parseInt(novUtils.getTop(novUtils.$("idFor_"+idRef)))+120;
		}
		else
		{
			x=parseInt(x)-120;
			y=parseInt(y)+20;
		}
		//redéfini le style du div à afficher
		novUtils.$(idRef).style['left'] = x+"px";
		novUtils.$(idRef).style['top'] = y+"px";
		novUtils.$(idRef).style['display'] = "block";
		novUtils.$(idRef).style['position'] = "absolute";
		novUtils.$(idRef).style['border'] = "1px solid #528EA5";
		novUtils.$(idRef).style['background'] = "#E7EBF7";
		novUtils.$(idRef).style['width'] = "400px";
		novUtils.$(idRef).style['padding'] = "5px";
		novUtils.$(idRef).style['textDecoration'] = "none";
		novUtils.$(idRef).style['zIndex'] = "10";
		novUtils.$(idRef).style['zoom'] = "1";
	}
}


function IsNumeric(strString)
   //  check for valid numeric strings
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

   
/*************************************/
/* 			readSpeaker 			 */
/*************************************/
var selectedString="";

function getSelectedHTML() {
  selectedString="";
  var rng=undefined;
  if (window.getSelection) {
    selobj = window.getSelection();
    if (!selobj.isCollapsed) {
      if (selobj.getRangeAt) {
        rng=selobj.getRangeAt(0);
      }
      else {
        rng = document.createRange();
        rng.setStart(selobj.anchorNode,selobj.anchorOffset);
        rng.setEnd(selobj.focusNode,selobj.focusOffset);
      }
      if (rng) {
        DOM = rng.cloneContents();
        object = document.createElement('div');
        object.appendChild(DOM.cloneNode(true));
        selectedString=object.innerHTML;
      }
      else {
        selectedString=selobj;
      }
    }
  }
  else if (document.selection) {
    selobj = document.selection;
    rng = selobj.createRange();
    if (rng && rng.htmlText) {
      selectedString = rng.htmlText;
    }
    else if (rng && rng.text) {
      selectedString = rng.text;
    }
  }
  else if (document.getSelection) {
    selectedString=document.getSelection();
  }
  	selectedString = cleanSelectedString(selectedString);
}

function copyselected()
{
  setTimeout("getSelectedHTML()",50);
  return true;
}

document.onmouseup = copyselected;
document.onkeyup = copyselected;

/* The expanding function */

function readspeaker(rs_call)
{
  if (selectedString.length>0) {
    rs_call=rs_call.replace("/cgi-bin/rsent?","/enterprise/rsent_wrapper.php?");
  }
  savelink=rs_call+"&save=1";
  start_rs_table="<table id='playerReadspeaker'><tr><td>";
  rs_embed="<object type='application/x-shockwave-flash' data='http://media.readspeaker.com/flash/readspeaker20.swf?mp3="+escape(rs_call)+"&autoplay=1&rskin=bump&c1=0x4B7284&c2=0x4B7284&c3=0xFFFFFF&c4=0x4B7284&c5=0xBCD0DA&c6=0xBCD0DA&c7=0x4B7284&c8=0x4B7284&c9=0xFFFFFF&c10=0xFFFFFF&c11=0xEEEEEE&c12=0xFFFFFF&c13=0xE3EBEF&c14=0xFFFFFF&c15=0xFFFFFF&c16=0x4B7284' height='20' width='250'><param name='movie' value='http://media.readspeaker.com/flash/readspeaker20.swf?mp3="+escape(rs_call)+"&autoplay=1&rskin=bump' /><param name='quality' value='high' /><param name='SCALE' value='exactfit' /><param name='wmode' value='transparent' /><embed wmode='transparent' src='http://media.readspeaker.com/flash/readspeaker20.swf?mp3="+escape(rs_call)+"&autoplay=1&rskin=bump' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwaveflash' scale='exactfit' height='20' width='250' /></embed></object></td>";
  //rs_downloadlink="<br />Vocalis&eacute; par <a href='http://www.readspeaker.com'>ReadSpeaker</a><br /><a href='"+savelink+"'>T&eacute;l&eacute;charger l&rsquo;audio</a>";
  close_rs="<td style='vertical-align:top;'><a href='#' onclick='close_rs_div(); return false;' title='Fermer le lecteur'><img src='/img/close_player.gif' /></a>";
  end_rs_table="</td></tr></table>";

  var x=document.getElementById('rs_div');

  //x.innerHTML=start_rs_table+rs_embed+rs_downloadlink+close_rs+end_rs_table;
  x.innerHTML=start_rs_table+rs_embed+close_rs+end_rs_table;
}

function close_rs_div()
{
  var x=document.getElementById('rs_div');
  x.innerHTML="";
}

/* Selected text cleaning function */

function cleanSelectedString(theString)
{
	var comments = theString.match(/<!--/gi);
	var temp = "";
	if(comments != undefined)
	{
		for(i=0;i<comments.length;i++)
		{
			var temp = theString.substring(theString.search(/<!--/gi),theString.search(/-->/gi)+3);
			theString = theString.replace(temp,"");
		}
	}
	var regexp = /(<\/?[A-Z]+[0-9]?)\s?[^>]*>/gi
	theString = theString.replace(regexp, "$1>");
	var regexp2 = /<\/?[A-Z]+[0-9]?\s?>/gi
	theString = theString.replace(regexp2, function(m) { return returnTags(m);});
	var regexp_spaces = /\s+?\s*/gi
	theString = theString.replace(regexp_spaces, " ");	
	var regexp_br = /(<br>)+?\s?(<br>\s*)*/gi
	theString = theString.replace(regexp_br, "<br>");	
	return theString;
}

function returnTags(thematch)
{ 
	var regtag = /<\/?(h[1-6]|a|area|ul|ol|dl|dd|dt|li|table|td|tr|th|p|hr|br)>/i
	if(regtag.test(thematch))
	{ 
		return thematch;
	} 
	else 
	{
		return "";
	}
}

/*
function readspeaker(rs_call, rs_file_name)
{
	savelink=rs_call+"&save=1&audiofilename="+rs_file_name;
	rs_call=rs_call+"&output=audio";
	rs_call=escape(rs_call);
	start_rs_table="<table style='border:1px solid #4B7284;'><tr><td >";
	rs_embed="<object type='application/x-shockwave-flash' data='http://media.readspeaker.com/flash/rplayerpro.swf?mp3="+rs_call+"&autoplay=1&rskin=bump' height='20' width='250'><param name='movie' value='http://media.readspeaker.com/flash/rplayerpro.swf?mp3="+rs_call+"&autoplay=1&rskin=bump'><param name='quality' value='high'><param name='SCALE' value='exactfit'><param name='wmode' value='transparent'><embed wmode='transparent' src='http://media.readspeaker.com/flash/rplayerpro.swf?mp3="+rs_call+"&autoplay=1&rskin=bump' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwaveflash' scale='exactfit' height='20' width='250'></embed></object></td>";
	//rs_downloadlink="<br>Speech-enabled by <a href='http://www.readspeaker.com'>ReadSpeaker</a><br><a href='"+savelink+"'>Télécharger le fichier audio</a>";
	//rs_downloadlink="<br><a href='"+savelink+"'>Télécharger le fichier audio</a>";
	close_rs="<td><a href='#' onclick='close_rs_div(); return false;'>Fermer la fenêtre</a>";
	end_rs_table="</td></tr></table>";
	var x=document.getElementById('rs_div');
	//x.innerHTML=start_rs_table+rs_embed+rs_downloadlink+close_rs+end_rs_table;
	x.innerHTML=start_rs_table+rs_embed+close_rs+end_rs_table;
}

function close_rs_div()
{
	var x=document.getElementById('rs_div');
	x.innerHTML="";
}
*/

/*************************************/
/* 			fin readSpeaker 		 */
/*************************************/