// JavaScript Document
var lg;
						
/* Fonction de verification de validite des formulaires  */
isEmail = function(emailStr) {
	var checkTLD = 1;
	var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|fr)$/;
	var emailPat = /^(.+)@(.+)$/;
	var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars = "\[^\\s" + specialChars + "\]";
	var quotedUser = "(\"[^\"]*\")";
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom = validChars + '+';
	var word = "(" + atom + "|" + quotedUser + ")";
	var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray = emailStr.match(emailPat);
	if (matchArray == null) { return false; }
	var user = matchArray[1];
	var domain = matchArray[2];
	for (i=0; i < user.length; i++) {

		if (user.charCodeAt(i) > 127) { return false; }
	}
	for (i=0; i < domain.length; i++) {
		if (domain.charCodeAt(i) > 127) { return false; }
	}
	if (user.match(userPat) == null) { return false; }
	var IPArray=domain.match(ipDomainPat);
	if (IPArray != null) {
		for (var i=1; i<=4; i++) {
			if (IPArray[i] > 255) { return false; }
		}
		return true;
	}
	var atomPat = new RegExp("^" + atom + "$");
	var domArr = domain.split(".");
	var len = domArr.length;
	for (i=0; i<len; i++) {
		if (domArr[i].search(atomPat) == -1) { return false; }
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { return false; }
	if (len < 2) { return false; }
	return true;
}

function view_ong(num)
{
	for(cpt=0; cpt <28; cpt++)
	{
		if(document.getElementById('ong_1_' + cpt))
		{
			document.getElementById('ong_1_' + cpt).style.cssText='background:url(design/Onglet_1.png) top left no-repeat; border-bottom: #999 solid 1px;';
			document.getElementById('ong_2_' + cpt).style.cssText='background:url(design/Onglet_2.png) top; padding-top:4px; padding-bottom:3px; border-bottom: #999  solid 1px;';
			document.getElementById('ong_3_' + cpt).style.cssText='background:url(design/Onglet_3.png) top right no-repeat; border-bottom: #999  solid 1px;';
			document.getElementById('table_' + cpt).style.display = 'none';
			document.getElementById('lien_' + cpt).className = 'lien_onglet';
		}
	}
	
	document.getElementById('ong_1_' + num).style.cssText='background:url(design/Onglet_1.png) top left no-repeat; border-bottom: #44b7ea solid 0px;';
	document.getElementById('ong_2_' + num).style.cssText='background:url(design/Onglet_2.png) top; padding-top:4px; padding-bottom:3px; border-bottom: #44b7ea solid 0px;';
	document.getElementById('ong_3_' + num).style.cssText='background:url(design/Onglet_3.png) top right no-repeat; border-bottom: #44b7ea solid 0px;';
	document.getElementById('table_' + num).style.display = 'block';
	document.getElementById('lien_' + num).className = 'lien_onglet_selected';
	if(num == 3 && document.getElementById('iff').src == "") { document.getElementById('iff').src = "map.asp?num=" + numauto + "&amp;l=" + l; }
	nd();
	return false;
}

function view_ong_Fiche(num)
{
	for(cpt=0; cpt <28; cpt++)
	{
		if(document.getElementById('ong_1_' + cpt))
		{
			document.getElementById('ong_1_' + cpt).style.cssText='background:url(design/Ong_Fiche_1.png) top left no-repeat;';
			document.getElementById('ong_2_' + cpt).style.cssText='background:url(design/Ong_Fiche_2.png) top; padding-top:4px; padding-bottom:3px;';
			document.getElementById('ong_3_' + cpt).style.cssText='background:url(design/Ong_Fiche_3.png) top right no-repeat;';
			document.getElementById('table_' + cpt).style.display = 'none';
			document.getElementById('lien_' + cpt).className = 'lien_onglet_Fiche';
		}
	}
	
	document.getElementById('ong_1_' + num).style.cssText='background:url(design/Ong_Fiche_1.png) top left no-repeat; ';
	document.getElementById('ong_2_' + num).style.cssText='background:url(design/Ong_Fiche_2.png) top; padding-top:4px; padding-bottom:3px;';
	document.getElementById('ong_3_' + num).style.cssText='background:url(design/Ong_Fiche_3.png) top right no-repeat;';
	document.getElementById('table_' + num).style.display = 'block';
	document.getElementById('lien_' + num).className = 'lien_onglet_Fiche_Selected';
	if(num == 3 && document.getElementById('iff').src == "") { document.getElementById('iff').src = "map.asp?num=" + numauto + "&amp;l=" + l; }
	nd();
	return false;
}

function r()
{
	if(document.getElementById('pr').value > 0) {
		document.getElementById('admm').submit();	
		return false;
	}
	
	if(document.getElementById('c').value > 0) {
		document.getElementById('admm').submit();	
		return false;
	}
	
	if(lg == 1) {
		alert("Veuillez sp\350cifier au moins la promotion ou la cat\350gorie pour lancer la recherche !");
	}
	if(lg == 2){
		alert("Gelieve ten minste de promotie of categorie aan te geven !");
	}
	if(lg == 2){
		alert("Please specify at least the promotion or category to search !");
	}
	return false;
}
