// JavaScript Document

var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var rbs_error_field="";
var test="";

function f_length(elId){
	return document.getElementById(elId).childNodes.length;
}

function $g(id) {
	return document.getElementById(id);
}

function load_sous_sec(id){
	var xscript=document.createElement("SCRIPT");
	xscript.src="/_includes/mods/rbs/load.php?id="+id;
	document.body.appendChild(xscript);	
}

function load_sec2(id,lng,obj,type){
	var xscript=document.createElement("SCRIPT");
	xscript.src="/_includes/mods/rbs/load2.php?id="+id+"&lg="+lng+"&source="+obj.id+"&type="+type;
	document.body.appendChild(xscript);	
}


function rbs_checkform(mode) {
	var conf_ok=1;
	if (mode=="subscribe") {
		var to_test=new Array();
		to_test[0]="nom";
		to_test[1]="prenom";
		to_test[2]="rue_num";
		to_test[3]="societe";
		to_test[4]="cp";
		to_test[5]="ville";
		to_test[6]="tel";
		to_test[7]="email";
		to_test[8]="login";
		to_test[9]="pass";
		to_test[10]="pass2";

		for (var x=0;x<to_test.length;x++) {
			if ($g("rbs_"+to_test[x])) {
				if($g("rbs_"+to_test[x]).value=="") {
					$g("rbs_"+to_test[x]+"_around").style.background="#E6ADAD";
					conf_ok=0;
				} else {
					$g("rbs_"+to_test[x]+"_around").style.background="#FFFFFF";
				}
			} 
		}

		if (!filter.test($g("rbs_email").value)) {
			$g("rbs_email_around").style.background="#E6ADAD";
			conf_ok=0;
		} else {
			$g("rbs_email_around").style.background="#FFFFFF";
		}
			
		if ($g("rbs_pass").value!="") {
			if ($g("rbs_pass").value!=$g("rbs_pass2").value) {
				$g("rbs_pass_around").style.background="#E6ADAD";
				$g("rbs_pass2_around").style.background="#E6ADAD";
				conf_ok=0;
			} else {
				$g("rbs_pass_around").style.background="#FFFFFF";
				$g("rbs_pass2_around").style.background="#FFFFFF";
			}
		}

		if ($g("m_redir").checked==false && $g("m_acc").checked==false  && $g("m_distrib").checked==false) {
			$g("rbs_m_around").style.background="#E6ADAD";
			$g("rbs_m_around").style.background="#E6ADAD";
			conf_ok=0;
		} else {
			$g("rbs_m_around").style.background="#FFFFFF";
			$g("rbs_m_around").style.background="#FFFFFF";
		}

		var xscript=document.createElement("SCRIPT");
		xscript.src="/_includes/mods/rbs/form.php?login_ko="+rbs_error_login_ko+"&error="+rbs_error_field+"&act=checklogin&state="+conf_ok+"&login="+$g("rbs_login").value;
		document.body.appendChild(xscript);	
		return false;
	}


	if (mode=="account") {
		var to_test=new Array();
		to_test[0]="nom";
		to_test[1]="prenom";
		to_test[2]="rue_num";
		to_test[3]="societe";
		to_test[4]="cp";
		to_test[5]="ville";
		to_test[6]="tel";
		to_test[7]="email";
		to_test[8]="pass";
		to_test[9]="pass2";

		for (var x=0;x<to_test.length;x++) {
			if ($g("rbs_"+to_test[x])) {
				if($g("rbs_"+to_test[x]).value=="") {
					$g("rbs_"+to_test[x]+"_around").style.background="#E6ADAD";
					conf_ok=0;
				} else {
					$g("rbs_"+to_test[x]+"_around").style.background="#FFFFFF";
				}
			} 
		}

		if (!filter.test($g("rbs_email").value)) {
			$g("rbs_email_around").style.background="#E6ADAD";
			conf_ok=0;
		} else {
			$g("rbs_email_around").style.background="#FFFFFF";
		}
			
		if ($g("rbs_pass").value!="") {
			if ($g("rbs_pass").value!=$g("rbs_pass2").value) {
				$g("rbs_pass_around").style.background="#E6ADAD";
				$g("rbs_pass2_around").style.background="#E6ADAD";
				conf_ok=0;
			} else {
				$g("rbs_pass_around").style.background="#FFFFFF";
				$g("rbs_pass2_around").style.background="#FFFFFF";
			}
		}

		if (conf_ok==1) return true;
		else return false;
	}

}





function clearDiv(divId){


	if ($(divId).style.display=='none'){	
		$('listProd9').style.display="none";
		$('listProd').style.display="none";
		$('listProd2').style.display="none";
		$('listProd3').style.display="none";
 		if ($('listProd10')) $('listProd10').style.display="none";	
		$(divId).style.display='block';
	}else{
		$(divId).style.display='none';		
	}
}

function fake_select(obj,source) {
	$(source).innerHTML=obj.innerHTML;
	$(source+"_fake").value=obj.getAttribute("fakeval");
	$("s09_fake").value="";
}

function fake_select_3(obj,source) {
	$(source).innerHTML=obj.innerHTML;
	$(source+"_fake").value=obj.getAttribute("fakeval");
}

function fake_select_bouh(obj,fakesource,source) {
	$(source).innerHTML=obj.innerHTML;
	$(fakesource+"_fake").value=obj.getAttribute("fakeval");
}

function fake_select_2(obj,source,source2) {
	$(source2).innerHTML=obj.innerHTML;
	$(source+"_fake").value=obj.getAttribute("fakeval");
}
