// * g?rer le focu et le blur des champs input *
function inFoc(objet){objet.className='input_focus';}
function inBlu(objet){objet.className='input_normal';}

// * convertit valeur objet en integer *
function toGoodInt(object) {
	object.value = verifyContain(object.value, "0123456789","", 0);
}

// * convertit valeur objet en float *
function toGoodFloat(object) {
	object.value = verifyContain(object.value, "0123456789.", ",.", 0);
}

// *** fonctions priv?es ***
function verifyContain(valueToVerify, accepted, replace, maxlength) {
	var acceptedValues = accepted;
	var result = "";
	for (i=0;i<valueToVerify.length;i++)  {
	  	var trouve = false;
		for (j=0;j<replace.length;j+=2) {
  			if (valueToVerify.charAt(i) == replace.charAt(j))
				result += replace.charAt(j+1);
		}
		for (j=0;j<acceptedValues.length;j++) {
  			if (valueToVerify.charAt(i) == acceptedValues.charAt(j))
				result += valueToVerify.charAt(i);
		}
	}
	if (maxlength != 0)
	if (result.length > maxlength)
  	result = result.substring(0, maxlength);
	return result;
}

// permet pour un ID donne de faire varier sa visibilite
function alternateVisibility(objectID) {
	var domStyle = findDOM(objectID,1);
	if (domStyle.display =='block') 
		domStyle.display='none';
	else domStyle.display='block';
	return false;
}

function alternateVisibilityDble(objectID, objectID1) {
	alternateVisibility(objectID);
	alternateVisibility(objectID1);
	return false;
}

// fonction demandant confirmation d'une action
// envoi vrai si action = OK
function askConfirm(message) {
    if (confirm(message)) {
       return true;
    }else{
       return false;
    }
}

function toVisible(objectID) {
	var domStyle = findDOM(objectID,1);
	domStyle.display ='block';
	return false;
}
function toNotVisible(objectID) {
	var domStyle = findDOM(objectID,1);
	domStyle.display ='none';
	return false;
}

function toVisibleInline(objectID) {
	var domStyle = findDOM(objectID,1);
	domStyle.display ='inline';
	return false;
}
function toNotVisibleInline(objectID) {
	var domStyle = findDOM(objectID,1);
	domStyle.display ='none';
	return false;
}

// use for openning a popup with the exact image size

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

var PositionX = 100;
var PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

var defaultWidth  = 500;
var defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;


//
// Deprecated
//
// This method was replaced by lightbox script available in revision 597 for plici release further plici_1.0.0.RC.3.r.582
// Is always used for compatibility

// fonction qui permet d'afficher une image en popup avec les bonnes dimensions
function popImage(imageURL,imageTitle, defaultWidthSet, defaultHeightSet ){
	if (defaultWidthSet != null) {
	    defaultWidth = defaultWidthSet;
	}
	if (defaultHeightSet != null) {
	    defaultHeight = defaultHeightSet;
	}
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
    canIPreview = true;
     if (imageURL=="")
        canIPreview = false;
     if (canIPreview == false) {
		alert('Aucune image ? voir');
		return false;
     }
    if (isNN)
       {imgWin=window.open('about:blank','',optNN);}
    else /*if (isIE)*/
       {imgWin=window.open('about:blank','',optIE);}
    with (imgWin.document){
        writeln('<html><head><title></title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
        writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
        writeln('width=100-(document.body.clientWidth-document.images[0].width);');
        writeln('height=100-(document.body.clientHeight-document.images[0].height);');
        writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
        writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
        writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
        if (!AutoClose) 
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
        else 
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
        writeln('<img name="not_used" src="'+imageURL+'" style="display:block"></body></html>');
        close();        
    }
    return true;
}



// used for InfoBulle Collapse style

var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;
if (document.getElementById) {
	isID = 1; isDHTML = 1;
} else {
	browserVersion = parseInt(navigator.appVersion);
	if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
		isLayers = 1; isDHTML = 1;
	} else {
		if (document.all) {
			isAll = 1; isDHTML = 1;
		}
	}
}


function findDOM(objectID,withStyle) {
var menuArea = "menuArea";
    if (withStyle == 1) {
        if (isID) { return (document.getElementById(objectID).style) ; }
        else { 
            if (isAll) { return (document.all[objectID].style); }
        else {
            if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
        };}
    }
    else {
        
        if (isID) { return (document.getElementById(objectID)) ; }
        else { 
            if (isAll) { return (document.all[objectID]); }
        else {
            if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
        };}
    }
    return null;
}





// ********* START FOR PRINTING METHOD ************



function replaceIntoTags(start_separator, end_separator, replaceString, content, case_sensitive) {


	var mustNotStop = true;
	var i = 0;
	
	var contentForFind = content;
	if (!case_sensitive) {
		contentForFind 	= contentForFind.toUpperCase();
		start_separator = start_separator.toUpperCase();
		end_separator 	= end_separator.toUpperCase();
	}	 
	
	var tmp;
	var tmp2;
	var start_index;
	var end_index;
	for (i=0; (i<10 && mustNotStop); i++)
	 {
		tmp="";
		tmp2="";
		start_index = contentForFind.indexOf(start_separator);
		end_index   = contentForFind.indexOf(end_separator);

		if (start_index>=0 && end_index>=0) {
			tmp += content.substring(0, start_index);
			tmp += replaceString;
			tmp += content.substring(end_index+end_separator.length);
			content = tmp;
			
			tmp2 += contentForFind.substring(0, start_index);
			tmp2 += replaceString;
			tmp2 += contentForFind.substring(end_index+end_separator.length);
			contentForFind = tmp2;
		} else {
			mustNotStop = false;
		}
	
	}
	
	return content;
}

//	bodyLine = getIntoTagsFirst("<body",">", contentNoBorder, false);
//
function getIntoTagsFirst(start_separator, end_separator, content, case_sensitive) {

	stringFinded = "";

	mustNotStop = true;
	i = 0;

	contentChanged = content;
	if (!case_sensitive) {
		contentChanged 	= contentChanged.toUpperCase();
		start_separator = start_separator.toUpperCase();
		end_separator 	= end_separator.toUpperCase();
	}

	start_index = contentChanged.indexOf(start_separator);
	end_index   = contentChanged.indexOf(end_separator);
	
	//alert(start_index+"<=>"+end_index);
	
	if (start_index>=0 && end_index>=0) {
		stringFinded = content.substring(start_index, end_index+end_separator.length);
	}
	
	
	return stringFinded;
}

function popForPrinting(){
        var pageWin=window.open('about:blank','_blank', 'menubar=yes');
	var contentNoBorder = document.getElementsByTagName('html')[0].innerHTML;
	// on remplace pour le tag de haut niveau si il existe
	var eXpr = new RegExp("id=(['\"]?)body(['\"]?)([ >])");
        var eXpr_script = new RegExp('\\s*<script[^>]*>[\\s\\S]*?</script>\\s*','ig');
        contentNoBorder = contentNoBorder.replace(eXpr, "id=$1body_print$2$3");
        contentNoBorder = contentNoBorder.replace(eXpr_script, "");
	contentNoBorder = contentNoBorder.replace("<"+"!"+"--*JS:FORCE_PRINTING*-"+"-"+">","<"+"SCRIPT"+" language='javascript'"+">"+" window.print();<"+"/"+"SCRIPT"+">");
        pageWin.document.writeln(contentNoBorder);
        pageWin.document.close();
    return false;
}
// ********* END FOR PRINTING METHOD ************



// ********* START FOR HIGHTLIGTH From Google or From local ************
/* New: Variable searchhi_string to keep track of words being searched. */
var searchhi_string = '';

var plop_i = 0;

/* http://www.kryogenix.org/code/browser/searchhi/ */
/* Modified 20021006 to fix query string parsing and add case insensitivity */
function highlightWord(node,word) {
	

	
	// Iterate into this nodes childNodes
	if (node.hasChildNodes) {
		var hi_cn;
		for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
			highlightWord(node.childNodes[hi_cn],word);
		}
	}
	
	// And do this node itself
	if (node.nodeType == 3) { // text node
		var tempNodeVal = node.nodeValue.toLowerCase();
		var tempWordVal = word.toLowerCase();
		if (tempNodeVal.indexOf(tempWordVal) != -1) {
			var pn = node.parentNode;
			if (pn.className != "searchword") {
				// word has not already been highlighted!
				var nv = node.nodeValue;
				var ni = tempNodeVal.indexOf(tempWordVal);
				// Create a load of replacement nodes
				var before = document.createTextNode(nv.substr(0,ni));
				var docWordVal = nv.substr(ni,word.length);
				var after = document.createTextNode(nv.substr(ni+word.length));
				var hiwordtext = document.createTextNode(docWordVal);
				var hiword = document.createElement("span");
				hiword.className = "searchword";
				hiword.appendChild(hiwordtext);
				pn.insertBefore(before,node);
				pn.insertBefore(hiword,node);
				pn.insertBefore(after,node);
				pn.removeChild(node);
			}
		}
	}
}

function googleSearchHighlight() {
	if (!document.createElement) return;
	var ref = document.referrer;
        ref = ref.replace(/\/search\/web\//,'?search&q='); // Most WebCrawler searches
	if (ref.indexOf('?') == -1) return;
	var qs = ref.substr(ref.indexOf('?')+1);
    var qsa = qs.split('#');
        qs = qsa[0];
        qs = qs.replace(/(^|&)p=Q&ts=e&/,'&'); // Most Eurekster searches
        qs = qs.replace(/(^|&)query=/,'&q='); // Most Lycos searches
        qs = qs.replace(/(^|&)key=/,'&q='); // Most Walhello searches
        qs = qs.replace(/(^|&)keywords=/i,'&q='); // Most Overture searches
        qs = qs.replace(/(^|&)searchfor=/,'&q='); // Most Mysearch.com searches
        qs = qs.replace(/(^|&)qt=/,'&q='); // Most Acoona.com searches
	qsa = qs.split('&');
	var qsip;
	for (var i=0;i<qsa.length;i++) {
		qsip = qsa[i].split('=');
	        if (qsip.length == 1) continue;
        	if (qsip[0] == 'q' || qsip[0] == 'p' || qsip[0] == 'w') { // q= for Google, p= for Yahoo, w= for Eurekster
			// Trim leading and trailing spaces after unescaping
			qsip[1] = unescape(qsip[1]).replace(/^\s+|\s+$/g, "");
			if( qsip[1] == '' ) continue;
                        phrases = qsip[1].replace(/\+/g,' ').split(/\"/);
			for(p=0;p<phrases.length;p++) {
			        phrases[p] = unescape(phrases[p]).replace(/^\s+|\s+$/g, "");
				if( phrases[p] == '' ) continue;
				if( p % 2 == 0 ) words = phrases[p].replace(/([+,()]|%(29|28)|\W+(AND|OR)\W+)/g,' ').split(/\s+/);
				else { words=Array(1); words[0] = phrases[p]; }
	                	for (w=0;w<words.length;w++) {
					if( words[w] == '' ) continue;
					highlightWord(document.getElementsByTagName("body")[0],words[w]);
					if( p % 2 == 0 ) searchhi_string = searchhi_string + ' ' + words[w];
					else searchhi_string = searchhi_string + ' "' + words[w] + '"';
                		}
			}

	        }
	}
}

// Everything form this point on is modified to allow for highlighting
// of terms found in the REQUEST URI
function localSearchHighlight(terms, divIdWhereToFind) {
			
			//alert(document.getElementsByTagName(divIdWhereToFind).length);
			//alert(document.getElementsByTagName("body")[0]);
			
			if (findDOM(divIdWhereToFind))
				var start_search_here = findDOM(divIdWhereToFind);
			else
				return;
				
			var qsip = Array();
			// Trim leading and trailing spaces after unescaping
			qsip[0] = 'h';
			qsip[1] = terms;
			if (qsip[1] == '' ) return;
			
			qsip[1] = unescape(qsip[1]).replace(/^\s+|\s+$/g, "");
            var phrases = qsip[1].replace(/\+/g,' ').split(/\"/);
            var words;
			for(var p=0;p<phrases.length;p++) {
			        phrases[p] = unescape(phrases[p]).replace(/^\s+|\s+$/g, "");
				if( phrases[p] == '' ) continue;
				if( p % 2 == 0 ) words = phrases[p].replace(/([+,()]|%(29|28)|\W+(AND|OR)\W+)/g,' ').split(/\s+/);
				else { words=Array(1); words[0] = phrases[p]; }
	                	for (var w=0;w<words.length;w++) {
					if( words[w] == '' ) continue;
					highlightWord(start_search_here,words[w]);
					if( p % 2 == 0 ) searchhi_string = searchhi_string + ' ' + words[w];
					else searchhi_string = searchhi_string + ' "' + words[w] + '"';
                		}
			}
}

var global_terms_for_search = "";

function setGlobalSearch(terms){
	global_terms_for_search = terms;
}

function SearchHighlight() {
	googleSearchHighlight();
	if (global_terms_for_search != "") {
		localSearchHighlight(global_terms_for_search, "where_to_search_in_1");
		localSearchHighlight(global_terms_for_search, "where_to_search_in_2");
	}
        // Trim any leading or trailing space
        // (this is an overkill way of getting rid of the leading
        //  space that always is present in searchhi_string)
        searchhi_string = searchhi_string.replace(/^\s+|\s+$/g, "");

        // In MSIE, sometimes the dynamic generation of the spans
        // for the highlighting takes the anchor out of focus.
        // Here, we put it back in focus.
        if( location.hash.length > 1 ) location.hash = location.hash;
}

//window.onload = SearchHighlight;
// ********* END FOR HIGHTLIGTH From Google or From local ************



function favoris(url, title) {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel(title,url,""); }
else { window.external.AddFavorite(url,title); } }
