
var ns4 = (document.layers)? true:false;
var ie4 = ((document.all) && (!document.getElementById))? true:false;
var ns6 = ((document.getElementById) && (!ie4))? true:false;

var tto;
var thisDiv;

function gety(theitem){
	var obj =eval("document.getElementById('m_" + theitem + "')");
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
			if (document.getElementById("main_frame")!=null) curleft -= document.getElementById("main_frame").offsetLeft;
	return(curleft);
}
function getx(theitem){
	var obj =eval("document.getElementById('m_" + theitem + "')");
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curtop += obj.x;
		return(curtop);
}

function showMenu(theItem){
	
	   var y=gety(theItem);
   var x= getx(theItem);
  clearTimeout(tto);
   if (ns4) {
      thisDiv = document.layers['mc_'+theItem];
	   thisDiv.top=x;
      thisDiv.left=y;
      thisDiv.visibility="show";
	   }
   if (ie4) {
      if ((thisDiv) &&(thisDiv!=document.layers['mc_'+theItem])){
		   thisDiv.visibility='hidden';
	   }
      thisDiv = document.layers['mc_'+theItem];
	   thisDiv.top=x;
      thisDiv.left=y;
      thisDiv.visibility="visible";
      }
   if (ns6) {
      if ((thisDiv) &&(thisDiv!=document.getElementById('mc_'+theItem).style)){
        thisDiv.visibility='hidden';
	   }
   	thisDiv = document.getElementById('mc_'+theItem).style;
		thisDiv.top=x+"px";
      thisDiv.left=y+"px";
      thisDiv.visibility="visible";
      }
}
			
function hideMenu(theItem){
	
   var thetime=400;
   if (ns4) {
      thisDiv = document.layers['mc_'+theItem];
      tto=setTimeout("thisDiv.visibility='hide'",thetime);
      }
   if (ie4) {
      thisDiv = document.layers['mc_'+theItem];
      tto=setTimeout("thisDiv.visibility='hidden'",thetime);
      }
   if (ns6) {
      thisDiv = document.getElementById('mc_'+theItem).style;
      tto=setTimeout("thisDiv.visibility='hidden'",thetime);
      }
}		



var xhr = null;


function getXhr() {
 if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject) { 
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP"); 
		} catch (e) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
 } else { 
	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest, veuillez le mettre à jour"); 
	xhr = false; 
	} 
}


function ajax_send_form(divId, path_file, vars2send, endFunction) {
	
	if (arguments.length == 2 || endFunction=="") var endFunction=undefined;
	
	getXhr(); 
	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && xhr.status == 200) {
			 
																					
						var reg1=new RegExp("[|#f#|]","g");
			if (xhr.responseText != null && xhr.responseText.match(reg1)) {
								var a_func=new Array();
				var a_func=xhr.responseText.split('|#f#|');
				if (a_func.length>1){ 					if (a_func.length==2){
						eval(a_func[1])();
					}
					if (a_func.length==3){
						eval(a_func[1])(a_func[2]);
					}
					if (a_func.length==4){
						eval(a_func[1])(a_func[2],a_func[3]);
					}
					if (a_func.length==5){
						eval(a_func[1])(a_func[2],a_func[3],a_func[4]);
					}
				}
				document.getElementById(divId).innerHTML = a_func[0];
			}else{
				document.getElementById(divId).innerHTML = xhr.responseText;
			}
	
		
			document.getElementById(divId).innerHTML = xhr.responseText; 
			
						
			if (endFunction!=undefined)  eval (endFunction);
		
		}
	}
	 	xhr.open("POST",path_file,true); 
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	
		vars2send = vars2send.replace(/\+/g, "|#plus#|" );
	
	xhr.send(vars2send); 
}


function debug(x){
	document.getElementById('debug').innerHTML = document.getElementById('debug').innerHTML+ "<br>"+ x;
	document.getElementById('debug').style.display='block';
}
function whichBrs() {
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'IE';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
	if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
	return navigator.userAgent.substr(0,agt.indexOf('\/'));}
	else return 'Netscape';} else if (agt.indexOf(' ') != -1)
	return navigator.userAgent.substr(0,agt.indexOf(' '));
	else return navigator.userAgent;
}
_browserName = whichBrs();


function scanObjectById(id){
	var o = document.getElementById(id);
	return scanObject(o);
}
function scanObject(o){
	var res;
	res = "<ul>";
	for(x in o){
		res += "<li style='margin:0px'><span style='color:#f00'>"+x+" : </span>"+o[x]+"</li>";
	}
	res += "</ul>";
	debug (res);
}
function prop_object(id, prop){
	var o = document.getElementById(id);
	var res;
	res = "<span style='color:#f00'>"+prop+" : </span>"+o[prop];
	debug (res);
}
function func(){ }
function reload_page(){
	var url;
	var href = document.location.href;
	if (href.substr(-1, 1) == "#"){ url = href.substr(0, -1) }else{ url = href; } 
	document.location = url;
}
function go2page(page){
	document.location = page;
}
function go2pageget(page, var_name, var_value){
	document.location = page+"?"+var_name+"="+var_value;
}
function openBlankPage(page){
	window.open(page);
	
}

function isset(varname){
	if(typeof( window[ varname ] ) != 'undefined'){
		return true;
	}else{
		return false;
	}
}

function htmlentities(str) {
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}

function stripslashes (str) {
    return (str + '').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {
        case '\\':
            return '\\';
        case '0':
            return '\u0000';
        case '':
            return '';
        default:
            return n1;
        }
    });
}

function addslashes (str) {
	return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}


function nl2br (str, is_xhtml) {
                                                                
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';

    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
}
function trim(str){
	return str.replace(/^\s+|\s+$/g, '') ;
}
function is_string(s){
	return typeof(s)=='string';
}
function cursor_in(o){
	o.style.cursor = 'pointer';
}
function cursor_out(o){
	o.style.cursor = 'auto';
}
function tr_over(tr){
	var l = tr.childNodes;
	for(x in l){
		td = l[x];
		if (td.nodeName=="TD"){
			td.style.backgroundImage="url('images/main/hi50.png')";
		}
	}
}
function tr_out(tr){
	var l = tr.childNodes;
	for(x in l){
		td = l[x];
		if (td.nodeName=="TD"){
			td.style.backgroundImage="none";
		}
	}
}
function put_zero(num){
	if (num<10) num = "0"+num;
	return num;
}

function display_obj(id){
	var o = document.getElementById(id);
	var display = o.tagName == "TR" ? "table-row" : "block";
	o.style.display = display;
}
function hide_obj(id){
	var o = document.getElementById(id);
	o.style.display = 'none';
}
function switch_display_obj(id){
	var o = document.getElementById(id);
	var display = o.tagName == "TR" ? "table-row" : "block";
	var disp = o.style.display == 'none' ? display : "none";
	o.style.display = disp;
}
function switch_display_all(class_name){
	a=new Array();
	a = getElementsByClassName(document, class_name);
	var offon = "";
	for (x in a){
		if (offon == "") offon = a[a.length-1].style.display;
		var display = a[a.length-1].tagName == "TR" ? "table-row" : "block";
		if (a[x].style != undefined)  a[x].style.display = offon == "none" ? display : "none";
	}
}

function hide_all(class_name){
	a=new Array();
	a = getElementsByClassName(document, class_name);
	for (x in a){
		if (a[x].style != undefined) a[x].style.display = "none";
	}
}
function display_popup(openclose){
	
	if (openclose=="open"){
		var h = document.body.scrollHeight+"px";
	}else{
		var h = "0%";
	}
	document.getElementById('popup_mask').style.height = h;
	

	if (openclose=="close"){
		document.getElementById('popup').innerHTML = "";
	}
		
}


function scrollTop (){
	body=document.body
		d=document.documentElement
		if (body && body.scrollTop) return body.scrollTop
		if (d && d.scrollTop) return d.scrollTop
		if (window.pageYOffset) return window.pageYOffset
		return 0
}


function wait_ajax(){
		
	
	
}

document.getElementsByTagAndClassName = function(tagName, className) {
  if ( tagName == null )
     tagName = '*';

  var children = document.getElementsByTagName(tagName) || document.all;
  var elements = new Array();

  if ( className == null )
    return children;

  for (var i = 0; i < children.length; i++) {
    var child = children[i];
    var classNames = child.className.split(' ');
    for (var j = 0; j < classNames.length; j++) {
      if (classNames[j] == className) {
        elements.push(child);
        break;
      }
    }
  }

  return elements;
}


function f_display_list_tab(name, display){
	var lt = document.getElementsByTagAndClassName('td',  'list_tab_'+name);
	var display_value;
	if (display){ display_value = 'table-cell'; }else{ display_value = 'none'; }
	for(var x in lt){
		lt[x].style.display=display_value;
	}
	
}

function getElementsByTagNames(list,obj) {
	if (!obj) var obj = document;
	var tagNames = list.split(',');
	var resultArray = new Array();
	for (var i=0;i<tagNames.length;i++) {
		var tags = obj.getElementsByTagName(tagNames[i]);
		for (var j=0;j<tags.length;j++) {
			resultArray.push(tags[j]);
		}
	}
	var testNode = resultArray[0];
	if (!testNode) return [];
	if (testNode.sourceIndex) {
		resultArray.sort(function (a,b) {
				return a.sourceIndex - b.sourceIndex;
		});
	}
	else if (testNode.compareDocumentPosition) {
		resultArray.sort(function (a,b) {
				return 3 - (a.compareDocumentPosition(b) & 6);
		});
	}
	return resultArray;
}






function verif_mail(email){
		var arobase=email.indexOf("@");
		var point= email.lastIndexOf(".");
		if((arobase < 3)||(point + 2 > email.length) ||(point < arobase+3)){
			return false;
		}else{
			return true;
		}
}



function isDateValid(saisie, year_on_2_numbers) {
	if (saisie == "") return false;
	saisie = (saisie).split("/");
	if ((saisie.length != 3) || isNaN(parseInt(saisie[0])) || isNaN(parseInt(saisie[1])) || isNaN(parseInt(saisie[2]))) return false;
	var laDate = new Date(eval(saisie[2]),eval(saisie[1])-1,eval(saisie[0]));
	if (year_on_2_numbers){
		var annee = saisie[2];
		
		return ((laDate.getDate() == eval(saisie[0])) && (laDate.getMonth() == eval(saisie[1])-1) && (annee.length == 2));
	}else{
		var annee = laDate.getYear();
		if ((Math.abs(annee)+"").length < 4) annee = annee + 1900;
		return ((laDate.getDate() == eval(saisie[0])) && (laDate.getMonth() == eval(saisie[1])-1) && (annee == eval(saisie[2])));
	}
}

function secure_string_for_ajax(str){
	
	var reg=new RegExp("(&)", "g");
	str = str.replace(reg,'|#and#|');
	
	var reg=new RegExp("(\\+)", "g");
	str = str.replace(reg,'|#plus#|');

	
	return str;
}



function vp_button_hi(o){o.style.cursor="pointer"; o.className="button_hover";}
function vp_button_norm(o){o.style.cursor="auto"; o.className="button";}
function vp_button_reactions(o){
	o.onmouseover = function(){ vp_button_hi(o); }
	o.onmouseout = function(){ vp_button_norm(o); }
}
function vp_scan_page(o){
	var atmp;
	var c;
	var l = o.childNodes;
	var x;
	var y;
	for(x in l){
		if (l[x] && l[x].className != undefined){
						c = l[x].className;
			atmp = c.split(' ');
			for (y in atmp){
				if(atmp[y] == "button"){
					vp_button_reactions(l[x]);
				}
			}
			
			if (l[x].childNodes.length > 0) vp_scan_page(l[x]);
		}
	}
}


function getElementsByClassName(node,classname) {
  if (node.getElementsByClassName) {     return node.getElementsByClassName(classname);
  } else {
    return (function getElementsByClass(searchClass,node) {
        if ( node == null )
          node = document;
        var classElements = [],
            els = node.getElementsByTagName("*"),
            elsLen = els.length,
            pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"), i, j;

        for (i = 0, j = 0; i < elsLen; i++) {
          if ( pattern.test(els[i].className) ) {
              classElements[j] = els[i];
              j++;
          }
        }
        return classElements;
    })(classname, node);
  }
}



function open_popup(url, title, width, height, toolbar, menubar, scrollbars, resizable){
	newwindow=window.open (url, title, 'width='+width+', height='+height+', toolbar='+toolbar+', menubar='+menubar+', scrollbars='+scrollbars+', resizable='+resizable+', location=no, directories=no, status=no');

	
}




function hiText(termid, element_id) {

	var tempinnerHTML = document.getElementById(element_id).innerHTML;
	var regex = new RegExp(termid+"(?=[^>]*<)","ig");
	document.getElementById(element_id).innerHTML = tempinnerHTML.replace(regex,'<span class="highlighted">'+termid+'</span>');
}



_LANG_captcha_note ="Veuillez reproduire les lettres que vous pouvez lire à la fin du formulaire.";

_LANG_plz_fill_last_name = "Veuillez remplir le champ \'Votre nom\'";
_LANG_plz_fill_first_name = "Veuillez remplir le champ \'Votre prénom\'";
_LANG_plz_fill_email = "Veuillez entrer votre e-mail";
_LANG_email_invalid = "L'e-mail n'est pas valide";

_LANG_vplogin_login_not_availiable = "Le pseudo choisi n'est pas disponible.";
_LANG_vplogin_email_not_availiable = "L'e-mail choisi n'est pas disponible.";
_LANG_vplogin_accept_rules = "Veuillez accepter le règlement";

_LANG_vplogin_plz_fill_login = "Veuillez entrer un pseudo";
_LANG_vplogin_plz_fill_sex = "Veuillez déterminer votre genre";
_LANG_vplogin_plz_fill_birth_day = "Veuillez entrer votre date de naissance";
_LANG_vplogin_email_confirmation_not_equal = "L'e-mail et sa confirmation ne sont pas identiques";
_LANG_vplogin_plz_fill_zip = "Veuillez entrer votre code postal";
_LANG_vplogin_pass_confirmation_not_equal = "Le mot de passe et sa confirmation ne sont pas identiques";
_LANG_vplogin_plz_fill_pass = "Veuillez entrer votre mot de passe";

_LANG_vplogin_pass_too_short = "Mot de passe trop court (6 caractères minimum).";
_LANG_vplogin_pass_char_limits = "Le mot de passe doit avoir entre 6 et 12 caractères";


_LANG_vplogin_email_not_found_in_base = "L'adresse email entrée n'existe pas en base.";

_LANG_vplogin_login_ok = "Pseudo OK";
_LANG_vplogin_email_ok = "E-mail OK";

_LANG_vplogin_hotmail_alert = "Votre e-mail est une adresse HOTMAIL. Vous ne recevrez pas d'e-mail de confirmation et serez directement inscrits.";


_LANG_comments_plz_fill_pseudo = "Veuillez remplir votre pseudo";
_LANG_comments_plz_fill_message = "Veuillez remplir votre message";
_LANG_comments_accept_rules = "Veuillez accepter les règles des commentaires";


_LANG_nl_unsubscribe_confirm = "Etes vous sûr de bien vouloir vous désabonner de la newsletter ?";


_LANG_mail_plz_fill_one_email = "Veuillez remplir au moins une adresse de destinataire";
_LANG_mail_email1_invalid = "La première adresse mail de destinataire est invalide";
_LANG_mail_email2_invalid = "La deuxième adresse mail de destinataire est invalide";
_LANG_mail_email3_invalid = "La troisième adresse mail de destinataire est invalide";
_LANG_mail_email4_invalid = "La quatrième adresse mail de destinataire est invalide";

_LANG_community_delete_firend_confirm = "Voulez-vous vraiment supprimer cet ami ?\n\nVos scores ne seront plus partagés."

_LANG_admin_member_pass_changed = "<br><br>Bonjour.";
_LANG_admin_member_pass_changed += "<br><br>";
_LANG_admin_member_pass_changed += "Nous avons changé votre mot de passe pour vous permettre de vous identifier :<br><br>";
_LANG_admin_member_pass_changed += "pseudo : {login}<br>";
_LANG_admin_member_pass_changed += "mot de passe : {pass}<br>";
_LANG_admin_member_pass_changed += "<br>Vous pourrez changer votre mot de passe dans votre page 'Mon compte'.";
_LANG_admin_member_pass_changed += "<br><br>Tentez de vous connecter avec ces données.";
_LANG_admin_member_pass_changed += "<br><br>Cordialement.<br><br>";




function comments_form_verif(form_id, free_comments){
	
		form = document.getElementById(form_id);
	
		var keAlerte = "";
	
	if (free_comments){
				if (form.name.value == "" || form.name.value == " ") keAlerte+="\nVeuillez remplir votre pseudo\n";
	}
		if (form.content.value == "" || form.content.value == " ") keAlerte+="\nVeuillez remplir votre message\n";
	if (!form.accept_comments_rules.checked) keAlerte+="\nVeuillez accepter les règles des commentaires\n";
	
		if (keAlerte!=""){
		alert(keAlerte);
		return false;
	}else{
		var tmp = "";
		if (form.post_all_pages && form.post_all_pages.checked) tmp = "&post_all_pages=1"; 		ajax_send_form(	"comments_content_result",
									"plugins/vp_comments/php_scripts/01_comments_action.php",
									"content="+form.content.value+"&page_id="+form.page_id.value+"&name="+form.name.value+tmp, 									""
									);
		
	}

}


function vote_neg(comment_id,page_id){
		ajax_send_form(	"comment_"+comment_id+"_content_result",
									"plugins/vp_comments/php_scripts/02_votes_action.php",
									"comment_id="+comment_id+"&page_id="+page_id,
									""
									);
}

function display_comments_rules(){
	document.getElementById("msg_comments_rules").style.display = "block";
}
function func1(){ alert('test'); }

function form_nl_verif(form_id){
	
		form = document.getElementById(form_id);
	
		var keAlerte = "";
	
		if (form.email.value == "" || form.email.value == " ") keAlerte+="\nVeuillez remplir le champ \'Votre adresse email\'\n";
	if (form.email.value != "" && !verif_mail(form.email.value)) keAlerte += "\nVotre adresse mail est invalide\r";
	
	if (form.nl_out && form.nl_out.checked) if (!confirm("Etes vous sûr de bien vouloir vous désabonner de la newsletter ?")) return false;
		if (keAlerte!=""){
		alert(keAlerte);
		return false;
	}else{
		form.submit();
	}
	
	
}


function verif_mail(email){
		var arobase=email.indexOf("@");
		var point= email.lastIndexOf(".");
		if((arobase < 3)||(point + 2 > email.length) ||(point < arobase+3)){
			return false;
		}else{
			return true;
		}
}




