// window open
function w(url, w, h)
{
	wdw = window.open(url, "popup", "top=80,left=250,status=no,scrollbars=yes,width=" + w + ",height=" + h);
	wdw.focus(); 
	return false; 
}


// check_text
function check_text(area, limit)
{
	if (area.value.length > limit)
		area.value = area.value.substr(0, limit);
	
	document.getElementById('counter').innerHTML =  area.value.length ;
}

// preloader
function preload(a)
{
	imgload = new Array();
	for(var j=0;j<a.length;j++)
	{
			imgload[j] = new Image();
			imgload[j].src = a[j];
	}
}

function diapo(flag)
{
  	flag = (flag) ? true : false;
	
	var img = $$('#photo li');

  	for(var i=0, li="", nb = img.length; i<nb; i++)
  	{
  	

		li = img[i].next()
		
		if(li==null)
		{	
			li = img[0];
  			//alert(img[0])
			
		}
		if(flag && Element.visible(img[i]))
		{
			show_diapo(img[i], li);
			break;
		}
	}
	
	setTimeout('diapo(true)', 5000);
}



function show_diapo(img1, img2)
{
  	
	new Effect.Fade(img1,{
		duration:0.5
		,afterFinish : function(){
			Effect.Appear(img2,{
				duration:0.8
			});
		}
		,queue:{scope:'scope', position:'front', limit: 1}
	});
}


// window open
function wOpen(img)
{
	w = open("",'image','width=150,height=150,toolbar=no,scrollbars=no,resizable=no'); 
	w.document.write("<html><head><title>Sécurité Routière</title></head>"); 
	w.document.write('<script type="text/javascript">'); 
	w.document.write("function checksize(){if (document.images[0].complete ){window.resizeTo(document.images[0].width + 10, document.images[0].height + 50);}else{setTimeout('checksize()',250)}}"); 
	w.document.write('</script>'); 
	w.document.write('<body onload="checksize()" onblur="window.close()" onclick="window.close()" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">');
	w.document.write("<div style='width:100%;'> ");
	w.document.write("<img src='" + img + "' border=0 alt=''>"); 
	w.document.write("</div>");
	w.document.write("</body></html>"); 
	w.document.close(); 
	return false;	
}




