
// Script pour faire apparaître du texte en cliquant sur le lien + détails

function showFullArticle()
  {
  if(document.getElementById)
    {
    tabler = document.getElementById('table');
    if(tabler.style.display=="none")
      {
      document.getElementById('plus').innerHTML = 'Read summary only';
      tabler.style.display="";
      }
    else
      {
      document.getElementById('plus').innerHTML = 'Read full article';
      tabler.style.display="none";
      }
    } 
  }
  
function showPostComment()
  {
  if(document.getElementById)
    {
    tabler = document.getElementById('table2');
    if(tabler.style.display=="none")
      {
      document.getElementById('post').innerHTML = 'Cancel post';
      tabler.style.display="";
      }
    else
      {
      document.getElementById('post').innerHTML = 'Post a comment';
      tabler.style.display="none";
      }
    } 
  }

  function showReadComments()
  {
  if(document.getElementById)
    {
    tabler = document.getElementById('table3');
    if(tabler.style.display=="none")
      {
      document.getElementById('readc').innerHTML = 'Hide comments';
      tabler.style.display="";
      }
    else
      {
      document.getElementById('readc').innerHTML = 'Read comments';
      tabler.style.display="none";
      }
    } 
  }
  function showSendNews()
  {
  if(document.getElementById)
    {
    tabler = document.getElementById('table4');
    if(tabler.style.display=="none")
      {
      document.getElementById('sendnews').innerHTML = 'Do not send';
      tabler.style.display="";
      }
    else
      {
      document.getElementById('sendnews').innerHTML = 'Send to a friend';
      tabler.style.display="none";
      }
    } 
  }
  
// pour limiter le nombre de caractères dans la boîte de texte

//trouvé sur: www.portugal-tchat.com//
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}


function doPopUp( sURL, sName, iWidth, iHeight, iResizable, iScrollbars, iDecoration ) 
{
	sParams = "copyhistory=no";
	if( iWidth > 0 )
		sParams += ",width="+iWidth;
	if( iHeight > 0 )
		sParams += ",height="+iHeight;

	if( iResizable > 0 )
		sParams += ",resizable=yes";
	else
		sParams += ",resizable=no";

	if( iScrollbars > 0 )
		sParams += ",scrollbars=yes";
	else
		sParams += ",scrollbars=no";

	if( iDecoration > 0 )
		sParams += ",toolbar=yes,location=yes,directories=yes,status=yes,top=10,left=50";
	else
		sParams += ",toolbar=no,location=no,directories=no,status=yes,top=10,left=50";

	window.open( sURL, sName, sParams );

}


function wordCount(str) {
var wordArray = new Array();
tempArray = str.split(',').sort();
var count = 1;

// Iterate through all the words
for (var i = 0; i < tempArray.length; i++) {

// If an array element with the same name as
// the current word exists, increment its value by 1
if (wordArray[tempArray[i]]) {
wordArray[tempArray[i]]++;
}

// Otherwise, assign the array element to the 
/// name of the word, and give it a value of 1
else { wordArray[tempArray[i]] = 1; }
}
var arrStr = '';

// Create table rows that display the word and the frequency
for (word in wordArray) {
if (word != "") {
arrStr += '<a href=photos.asp?tag='+word+'>'+word+'</a>&nbsp; &nbsp;';
count++;
}
}
return arrStr;
}
