/**
 * jQuery is required
 * @return
 */

// jQuery text() to get alt text
jQuery.fn.textAndAlt =  function( text ) {
		if ( typeof text !== "object" && text != null )
			return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );

		var ret = "";

		jQuery.each( text || this, function(){
			jQuery.each( this.childNodes, function(){
				if ( this.nodeType != 8 )
					if (this.nodeType != 1){
						ret += this.nodeValue;
					} else {
						if (this.alt){
							ret += this.alt;
						}
						ret += jQuery.fn.textAndAlt( [ this ] );
					}
			});
		});

		return ret;
	}

// Nécessite jQuery 1.3
var CheckAccessibility = (function(){
	// contient les resultats des test
	var log = new Array();
	// url de la page testee
	var pageUrl = window.location.pathname + window.location.search
	
	// les tests pris en charge
	var allCheckTest = [
					     '01.1.a',
					     '01.1.b',
					     '01.1.c',
					     /*applet*/'01.1.d',
					     '01.1.e',
					     '01.2.a',
					     '01.2.b',
					     /*applet*/'01.2.c',
					     '01.2.d',
					     '01.4.a',
					     '01.4.b',
					     '01.4.c',
					     /*applet*/'01.4.d',
					     '01.5.a',
					     '01.5.b',
					     '01.7.a',
					     '02.1.a',
					     '02.1.b',
					     '02.7.a',
					     '02.7.b',
					     '02.3.a',
					     '02.3.b',
					     '02.4.a',
					     '02.4.b',
					     '03.3.a',
					     '05.3.a',
					     '05.6.a',
					     '05.6.b',
					     '06.1.a',
					     '06.1.b',
					     '06.1.d',
					     '06.2.a',
					     '06.2.b',
					     '06.2.c',
					     '06.2.d',
					     '06.4.a',
					     '06.4.b',
					     '06.4.c',
					     '06.4.d',
					     '06.5.a',
					     '06.5.b',
					     '06.5.d',
					     '08.3.a',
					     '08.4.a',
					     '08.5.a',
					     '08.7.a'
				]
	
	// outils pour les tests
	/**
	 * Renvoie le chemin d'un élement sous la forme:
	 * .../PARENT#parent_id.parent_class/ELT#elt_id.elt_class
	 * @param elt
	 * @return string
	 */
	var getParentPath = function (elt){
		var path = '';
		while (elt.nodeName.toUpperCase() != 'HTML'){
			var eltSummary = elt.nodeName + '#' + elt.id + '.' + elt.className;
			path = '/' + eltSummary + path;
			elt = elt.parentNode;
		}
		return path;
	}

	/**
	 * Renvoie le premiere noeud frere de type element ou null
	 * @param elt
	 * @return NODE_ELEMENT|null
	 */
	var getNextSibling = function(elt){
		do {
			elt = elt.nextSibling;
		} while (elt != null && elt.nodeType != 1 /*ELEMENT_NODE*/ && elt.nodeType != undefined)
		return elt;
	}

	/**
	 * 
	 * @param str
	 * @return
	 */
	var absorbSpace = function(str){
		return (str.replace(/^\s+|\s+$/g,'').replace(/\s+/g,' '));
	}

	/**
	 * Retourne un tableau de deux éléments
	 *  - le premier est la couleur d'avant plan en tableau (cf. getColorArrayFromStr)
	 *  - le deuxieme est la couleur d'arriere plan en tableau (cf. getColorArrayFromStr)
	 * @param elt
	 * @return
	 */
	var getColorArray = function(elt){
		var col = undefined;
		var bgcol = undefined;
		
		while (elt && elt.nodeName.toUpperCase() != 'HTML'
				&& (col == undefined || bgcol == undefined)){
			if (col == undefined){
				col = getColorArrayFromStr($(elt).css('color'));
			}
			if (bgcol == undefined){
				bgcol = getColorArrayFromStr($(elt).css('background-color'));
			}
			elt = elt.parentNode;
		}
		return [col, bgcol];
	}
	
	/**
	 * Renvoie un tableau de 3 éléments (red, green, blue) ou undefined
	 * 
	 * @param color (retour de $().css('*color') )
	 * @return Array()|undefined
	 */
	var getColorArrayFromStr = function(color) {
		var result;
		var colors = {
				aqua:[0,255,255],
				azure:[240,255,255],
				beige:[245,245,220],
				black:[0,0,0],
				blue:[0,0,255],
				brown:[165,42,42],
				cyan:[0,255,255],
				darkblue:[0,0,139],
				darkcyan:[0,139,139],
				darkgrey:[169,169,169],
				darkgreen:[0,100,0],
				darkkhaki:[189,183,107],
				darkmagenta:[139,0,139],
				darkolivegreen:[85,107,47],
				darkorange:[255,140,0],
				darkorchid:[153,50,204],
				darkred:[139,0,0],
				darksalmon:[233,150,122],
				darkviolet:[148,0,211],
				fuchsia:[255,0,255],
				gold:[255,215,0],
				green:[0,128,0],
				indigo:[75,0,130],
				khaki:[240,230,140],
				lightblue:[173,216,230],
				lightcyan:[224,255,255],
				lightgreen:[144,238,144],
				lightgrey:[211,211,211],
				lightpink:[255,182,193],
				lightyellow:[255,255,224],
				lime:[0,255,0],
				magenta:[255,0,255],
				maroon:[128,0,0],
				navy:[0,0,128],
				olive:[128,128,0],
				orange:[255,165,0],
				pink:[255,192,203],
				purple:[128,0,128],
				violet:[128,0,128],
				red:[255,0,0],
				silver:[192,192,192],
				white:[255,255,255],
				yellow:[255,255,0]
			};
		
		// Check if we're already dealing with an array of colors
		if ( color && color.constructor == Array && color.length == 3 ){
			return color;
		}

		// Look for rgb(num,num,num)
		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)){
			return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
		}

		// Look for rgb(num%,num%,num%)
		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)){
			return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
		}
		// Look for #a0b1c2
		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)){
			return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
		}
		// Look for #fff
		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)){
			return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
		}
		// Otherwise, we're most likely dealing with a named color
		return colors[jQuery.trim(color).toLowerCase()];
	}
	return {
		getLog : function(){return log},
		run: function(checkTest, fromSelector){
				// tableau des résultat
				log = new Array();
				
				if (fromSelector == undefined){
					fromSelector = '';
				}
				
				// variables qualifiant les différents tests
				var test, state, comment;
		
				if (!checkTest) {
					checkTest = allCheckTest;
				}
				
				// ///////// //
				// LES TESTS //
				// ///////// //
				

				// les images
				var images = $(fromSelector + ' img').add(fromSelector + ' object[type^=image/]');
				images.each(function(){
					if ($.inArray('01.1.a', checkTest) != -1){
						test = '01.1.a';
						state = 'FAILED';
						comment = '';
						if (!$(this).attr('alt')){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('01.2.a', checkTest) != -1){
						test = '01.2.a';
						state = 'HUMAN CHECK';
						comment = 'Si l\'image est décorative, OK!';
						if ($(this).attr('alt') == ''){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment + ', src: ' + this.src
							});
						}
					}
					
					if ($.inArray('01.4.a', checkTest) != -1){
						test = '01.4.a';
						state = 'FAILED';
						comment = '';
						if (this.alt.length > 80){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('01.5.a', checkTest) != -1){
						test = '01.5.a';
						state = 'HUMAN CHECK';
						comment = 'Si l\'image ne nécessite pas de longue description, ok!';
						if (!$(this).attr('longdesc')){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment + ' url:' + this.src
							});
						}
					}
					
					if ($.inArray('01.5.b', checkTest) != -1){
						test = '01.5.b';
						state = 'FAILED';
						comment = '';
						
						if ($(this).attr('longdesc')){
							var img = this;
							$.ajax({
								url: $(this).attr('longdesc')
								,error: function(){
											log.push({
												url:pageUrl
												,test:test
												,path: getParentPath(img)
												,state: state
												,comment: comment
											});
										}
								})
						}
							
					}
					
					if ($.inArray('01.7.a', checkTest) != -1){
						test = '01.7.a';
						state = 'FAILED';
						comment = '';
						if ($(this).attr('usemap')){
							var next = getNextSibling(this);
							if (next && next.nodeName.toUpperCase() != 'MAP'){
									log.push({
										url:pageUrl
										,test:test
										,path: getParentPath(this)
										,state: state
										,comment: comment
									});
							} else {
								if ($(next).find('area').length == 0){
									log.push({
										url:pageUrl
										,test:test
										,path: getParentPath(this)
										,state: state
										,comment: comment
									});
								}
							}
						}
					}
				});
				
				// les area
				var area = $(fromSelector + ' area');
				area.each(function(){
					if ($.inArray('01.1.b', checkTest) != -1){
						test = '01.1.b';
						state = 'FAILED';
						comment = '';
						if (!$(this).attr('alt')){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('01.2.b', checkTest) != -1){
						test = '01.2.b';
						state = 'FAILED';
						comment = '';
						if ($(this).attr('nohref') && $(this).attr('alt') != ''){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('01.4.b', checkTest) != -1){
						test = '01.4.b';
						state = 'FAILED';
						comment = '';
						if (this.alt.length > 80){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('06.2.c', checkTest) != -1){
						test = '06.2.c';
						state = 'HUMAN CHECK';
						comment = 'Le titre est-il nécessaire ?';
						if (this.title){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment + ' title: ' + $(this).attr('title') +
										  ' ,lien: ' + absorbSpace($(this).attr('alt'))
							});
						}
					}
					
					if ($.inArray('06.4.c', checkTest) != -1){
						test = '06.4.c';
						state = 'HUMAN CHECK';
						comment = '';
						if (this.alt && this.alt.length > 80){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: this.alt
							});
						}
					}
					
					if ($.inArray('06.5.c', checkTest) != -1){
							test = '06.5.c';
							state = 'HUMAN CHECK';
							comment = '';
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: 'href: ' + this.href + ' ,lien: ' + this.alt
							});
						}
					
				});
				
				// les inputs image
				var inputImage = $(fromSelector + ' input[type=image]');
				inputImage.each(function(){
					if ($.inArray('01.1.c', checkTest) != -1){
						test = '01.1.c';
						state = 'FAILED';
						comment = '';
						if (this.alt == ''){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
				
					if ($.inArray('01.4.c', checkTest) != -1){
						test = '01.4.c';
						state = 'FAILED';
						comment = '';
						if (this.alt.length > 80){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
				});
				
				// les applets
				var applet = $(fromSelector + ' applet');
				applet.each(function(){
					if ($.inArray('01.1.d', checkTest) != -1 || $.inArray('01.2.c', checkTest) != -1){
						test = '01.1.d/01.2.c';
						state = '';
						comment = '';
						if (this.alt == ''){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('01.4.d', checkTest) != -1){
						test = '01.4.d';
						state = 'FAILED';
						comment = '';
						if (this.alt.length > 80){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
				});
				
				// les objets image
				var objectImage = $(fromSelector + ' object[type^=image]');
				objectImage.each(function(){
					if ($.inArray('01.1.e', checkTest) != -1 || $.inArray('01.2.d', checkTest) != -1){
						test = '01.1.e/01.2.d';
						state = 'HUMAN CHECK';
						comment = '';
						if (this.innerHTML.replace(/<!--.*-->/,'').replace(/^\s+|\s+$/, '') == ''){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
				});
				
				// les frame
				var frame = $(fromSelector + ' frame');
				frame.each(function(){
					if ($.inArray('02.1.a', checkTest) != -1){
						test = '02.1.a';
						state = 'FAILED';
						comment = '';
						if ($(this).attr('title') == ''){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('02.7.a', checkTest) != -1){
						test = '02.7.a';
						state = 'FAILED';
						comment = '';
						if (this.scrolling == 'no'){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
				});
				
				// les frameset
				var frameset = $(fromSelector + ' frameset');
				var noframes = $(fromSelector + ' noframes');
				var iframes = $(fromSelector + ' iframe');
				if ($.inArray('02.3.a', checkTest) != -1 || $.inArray('02.4.a', checkTest) != -1){
					frameset.each(function(){
						
						var next = getNextSibling(this);
						
						
						if ($.inArray('02.3.a', checkTest) != -1 ){
							test = '02.3.a';
							state = 'FAILED';
							comment = '';
							if (next == null || next.nodeName.toUpperCase() != 'NOFRAMES'){
								log.push({
									url:pageUrl
									,test:test
									,path: getParentPath(this)
									,state: state
									,comment: comment
								});
							}
						}
						
						// le contenu d'une balise noframes est vu comme du texte
						if ($.inArray('02.4.a', checkTest) != -1 ){
							test = '02.4.a';
							state = 'HUMAN CHECK';
							comment = '';
							if (next && next.nodeName.toUpperCase() == 'NOFRAMES'){
								var frameTitles = '';
								$(this).find('frame').each(function(){
									frameTitles += this.title + ',';
								});
								frameTitles = frameTitles.replace(/,$/,'');
								var noFrameContent = next.innerHTML;
								log.push({
									url:pageUrl
									,test:test
									,path: getParentPath(this)
									,state: state
									,comment: comment +': ' + frameTitles + '|' + noFrameContent
								});
							} else {
								state = 'FAILED';
								comment = 'il n\'y a pas de balise noframes';
								log.push({
									url:pageUrl
									,test:test
									,path: getParentPath(this)
									,state: state
									,comment: comment
								});
							}
						}
					});
				}
				
				// les iframe
				var iframe = $(fromSelector + ' iframe');
				iframe.each(function(){
					if ($.inArray('02.1.b', checkTest) != -1){
						test = '02.1.b';
						state = 'FAILED';
						comment = '';
						if (this.title == ''){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('02.3.b', checkTest) != -1){
						test = '02.3.b';
						state = 'HUMAN CHECK';
						comment = '';
						log.push({
							url:pageUrl
							,test:test
							,path: getParentPath(this)
							,state: state
							,comment: comment + absorbSpace($(this).text())
						});
					}

					if ($.inArray('02.4.b', checkTest) != -1){
						test = '02.4.b';
						state = 'HUMAN CHECK';
						comment = '';
						log.push({
							url:pageUrl
							,test:test
							,path: getParentPath(this)
							,state: state
							,comment: 'src: ' + this.src + ' ,contenu: ' +  absorbSpace($(this).text())
						});
					}
					
					if ($.inArray('02.7.b', checkTest) != -1){
						test = '02.7.b';
						state = 'FAILED';
						comment = '';
						if (this.scrolling == 'no'){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
				});
				
				// les couleurs
				var allElt = $(fromSelector + ' *');
				allElt.each(function(){
					if ($.inArray('03.3.a', checkTest) != -1){
						test = '03.3.a';
						
						var cols = getColorArray(this);
						var col = cols[0];
						var bg = cols[1];
						
						state = 'HUMAN CHECK';
						comment = 'une couleur est transparente ou non définie. background: ' + bg + ', color: ' + col;
						if (bg == undefined || col == undefined){
								log.push({
									url:pageUrl
									,test:test
									,path: getParentPath(this)
									,state: state
									,comment: comment
								});
						} else {
						
							state = 'FAILED';
							comment = '';
							var contrast = Math.max(col[0],bg[0])-Math.min(col[0],bg[0]) +
										   Math.max(col[1],bg[1])-Math.min(col[1],bg[1]) +
										   Math.max(col[2],bg[2])-Math.min(col[2],bg[2]);
					
							if (contrast < 500){
								log.push({
									url:pageUrl
									,test:test
									,path: getParentPath(this)
									,state: state
									,comment: 'contrast:' + contrast + ', col: ' + col +', bg: ' + bg
								});
							}
						}
					}
				});
				
				// les tabeaux
				var table = $(fromSelector + ' table').not('table.jQueryAdded');
				table.each(function(){
					if ($.inArray('05.3.a', checkTest) != -1){
						test = '05.3.a';
						state = 'HUMAN CHECK';
						log.push({
							url:pageUrl
							,test:test
							,path: getParentPath(this)
							,state: state
							,comment: absorbSpace($(this).textAndAlt())
						});
					}
					
					if ($.inArray('05.6.a', checkTest) != -1){
						test = '05.6.a';
						state = 'FAILED';
						comment = '';
						var headCells = $($(this).find('tr')[0]).children();
						var ko = false;
						headCells.each(function(){
							if (!ko && this.nodeName.toUpperCase() != 'TH' ){
								ko = true;
							}
						});
						if (ko){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
					
					if ($.inArray('05.6.b', checkTest) != -1){
						test = '05.6.b';
						state = 'HUMAN CHECK';
						comment = '';
						var lines = $(this).find('tr');
						var ko = false;
						lines.each(function(){
							if (!ko && $(this).find('th').length == 0 ){
								ko = true;
							}
						});
						if (ko){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment
							});
						}
					}
				});
				
				// les liens
				var link = $(fromSelector + ' a');
				link.each(function(){
					isTextLink = false;
					isCompositeLink = false;
					isImageLink = false;
					
					var kids = $(this).find('img');
					isTextLink = kids.length == 0;
					isImageLink = $(this).find('img, object[type=image]').length == 1 && $.trim($(this).text()) == '';
					isCompositeLink = kids.length >= 1 && $.trim($(this).text()) != '';
					
					if (isTextLink && $.inArray('06.1.a', checkTest) != -1){
						test = '06.1.a';
						state = 'HUMAN CHECK';
						comment = '';
						if (!this.title){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: absorbSpace($(this).text())
							});
						}
					}
					
					if (isImageLink && $.inArray('06.1.b', checkTest) != -1){
						test = '06.1.b';
						state = 'HUMAN CHECK';
						comment = '';
						if (!this.title){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: absorbSpace($(this).textAndAlt())
							});
						}
					}
					
					if (isCompositeLink && $.inArray('06.1.d', checkTest) != -1){
						test = '06.1.d';
						state = 'HUMAN CHECK';
						comment = '';
						if (!this.title){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: absorbSpace($(this).textAndAlt())
							});
						}
					}
					
					if (isTextLink && $.inArray('06.2.a', checkTest) != -1){
						test = '06.2.a';
						state = 'HUMAN CHECK';
						comment = 'Le titre est-il nécessaire ?';
						if (this.title){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment + ' title: ' + $(this).attr('title') +
										  ' ,lien: ' + absorbSpace($(this).textAndAlt())
							});
						}
					}
					
					if (isImageLink && $.inArray('06.2.b', checkTest) != -1){
						test = '06.2.b';
						state = 'HUMAN CHECK';
						comment = 'Le titre est-il nécessaire ?';
						if (this.title){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment + ' title: ' + $(this).attr('title') +
										  ' ,lien: ' + absorbSpace($(this).textAndAlt())
							});
						}
					}
					
					if (isCompositeLink && $.inArray('06.2.d', checkTest) != -1){
						test = '06.2.d';
						state = 'HUMAN CHECK';
						comment = 'Le titre est-il nécessaire ?';
						if (this.title){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: comment + ' title: ' + $(this).attr('title') +
										  ' ,lien: ' + absorbSpace($(this).textAndAlt())
							});
						}
					}
					
					if (isTextLink && $.inArray('06.4.a', checkTest) != -1){
						test = '06.4.a';
						state = 'HUMAN CHECK';
						comment = '';
						textLen = $(this).text().length;
						if (textLen > 80){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: 'longueur: ' + textLen + ', texte: ' +$(this).text()
							});
						}
					}
					
					if (isImageLink && $.inArray('06.4.b', checkTest) != -1){
						test = '06.4.b';
						state = 'HUMAN CHECK';
						comment = '';
						if ($(this).textAndAlt().length > 80){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: $(this).textAndAlt()
							});
						}
					}
					
					if (isCompositeLink && $.inArray('06.4.d', checkTest) != -1){
						test = '06.4.d';
						state = 'HUMAN CHECK';
						comment = '';
						var content = absorbSpace($(this).textAndAlt());
						if (content.length > 80){
							log.push({
								url:pageUrl
								,test:test
								,path: getParentPath(this)
								,state: state
								,comment: absorbSpace($(this).textAndAlt())
							});
						}
					}
		
					if ($.inArray('06.5.a', checkTest) != -1
						|| $.inArray('06.5.b', checkTest) != -1
						|| $.inArray('06.5.d', checkTest) != -1){
						test = '06.5.a/06.5.b/06.5.d';
						state = 'HUMAN CHECK';
						comment = '';
						log.push({
							url:pageUrl
							,test:test
							,path: getParentPath(this)
							,state: state
							,comment: new Array(this.href , absorbSpace($(this).textAndAlt()))
						});
					}
				});
				
				// Elements obligatoire
				var html = document.getElementsByTagName('html')[0];
				var title = document.getElementsByTagName('title')[0];
				
				if ($.inArray('08.3.a', checkTest) != -1){
					test = '08.3.a';
					state = 'FAILED';
					comment = '';
					if (!html.lang){
						log.push({
							url:pageUrl
							,test:test
							,path: '/HTML'
							,state: state
							,comment: comment
						});
					}
				}
				
				if ($.inArray('08.4.a', checkTest) != -1){
					test = '08.4.a';
					state = 'HUMAN CHECK';
					comment = '';
					log.push({
						url:pageUrl
						,test:test
						,path: '/HTML'
						,state: state
						,comment: 'lang: ' + html.lang
					});
				}
				
				if ($.inArray('08.5.a', checkTest) != -1){
					test = '08.5.a';
					state = 'FAILED';
					comment = '';
					if (typeof title == 'undefined'){
						log.push({
							url:pageUrl
							,test:test
							,path: ''
							,state: state
							,comment: comment
						});
					}
				}
				
				if ($.inArray('08.7.a', checkTest) != -1){
					test = '08.7.a';
					state = 'HUMAN CHECK';
					comment = '';
					log.push({
						url:pageUrl
						,test:test
						,path: ''
						,state: state
						,comment: $(title).text()
					});
				}
				
				
				
			},
			post: function(postUrl){
				if (postUrl == undefined){
					throw 'Indiquez une url pour poster les logs...'
				}
				var logStr='';
				for (var i = 0, len = log.length; i < len; i++){
					if (log[i].comment instanceof Array){
						var strComment = log[i].comment.join('|');
					} else {
						var strComment = log[i].comment;
					}
					logStr += log[i].url + '|' +  log[i].test + '|' + log[i].path + '|'
							  + log[i].state + '|' + strComment;
					if (i<len -1) {
						logStr += '$';
					}
				}
				
				
				$.post(postUrl, {
					log: logStr
					,url: window.location.pathname + window.location.search
				});
			}
		}
})();

