// JavaScript Document
<!--
function form_patience()
{
  document.getElementById('main_form_submit_button').style.display='none';
  document.getElementById('form_patience').style.display='block'
}
function popup(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function linkconfirm(url,msgconfirm)
{
	var a = false, b='';
	a= confirm (msgconfirm);
	if (a)
	b = eval(location.href=url);
}

function link_confirm(confirm_msg)
{
  a= confirm (confirm_msg);
  if (a)
    return true;
  else
    return false;
}

/************************************************************************************************/
/*	freekill (freekill.free.fr) 					*/
/************************************************************************************************/

function countInstances(open,closed) {
	var opening = document.form2.ftexte.value.split(open);
	var closing = document.form2.ftexte.value.split(closed);
	//return opening.length + closing.length - 2;
	return ;
}

function TAinsert(text1,text2,field) {
  if (field == '')
  {
    field = 'ftexte';
	}
  var ta = document.getElementById(field);
	if (document.selection) {
		var str = document.selection.createRange().text;
		ta.focus();
		var sel = document.selection.createRange();
		if (text2!="") {
			sel.text = text1 + sel.text + text2;
		} else sel.text = sel.text + text1;
	} else if (ta.selectionStart || ta.selectionStart == 0) {
		if (ta.selectionEnd > ta.value.length) ta.selectionEnd = ta.value.length;
		var firstPos = ta.selectionStart;
		var secondPos = ta.selectionEnd+text1.length;
		var contenuScrollTop = ta.scrollTop;
		
		ta.value=ta.value.slice(0,firstPos)+text1+ta.value.slice(firstPos);
		ta.value=ta.value.slice(0,secondPos)+text2+ta.value.slice(secondPos);
		
		ta.selectionStart = firstPos+text1.length;
		ta.selectionEnd = secondPos;
		ta.focus();
		ta.scrollTop = contenuScrollTop;
	} else { // Opera
		var sel = document.form2.ftexte;
		var instances = countInstances(text1,text2);
		if (instances%2 != 0 && text2 != "") sel.value = sel.value + text2;
		else sel.value = sel.value + text1;
	}
}

function jumpTo(selectedobj,dest_page){
  if(selectedobj.options[selectedobj.selectedIndex].value != "#")
  {
    eval("window.location='"+dest_page+selectedobj.options[selectedobj.selectedIndex].value+"'");
  }
}


function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                             
    var histogram = {}, tmp_arr = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}
			
			
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
	else{
	  changeOpac(opacEnd, id)
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
  var object = document.getElementById(id); 
  
  if(typeof object.style.opacity == "string") {  
    object.style.opacity = (opacity / 100);  
  } else {
    //here use document.getElementById(id).filters.alpha.opacity for IE
  }
}
			
	
