// JavaScript Document

$(function(){
		   
		   $("input[type='file']").each(function(){
										$(this).wrap("<div class=\"fileinputs\"></div>");
										$(this).after("<div class=\"fakefile\"><input /><img src=\"design/fond/parcourir.png\" alt=\"parcourir\"/></div>");
			})
		   if($(".bigmap").size()!=0){
			   self.location.href='#verscontenu'
		   }
		   
		   $("#annuaire .reloadcarte").click(function(){
				recherche=$("#recherchefiche").val()
						if(recherche){
							$("#recherchelimiter").submit()
						}else{
							$("#annuaire").submit()
						}
				})
					   
		   
		   $(window).scroll(function () { 
									  pos=$(this).scrollTop();
									  hini=$("#outils").innerHeight()+$("#menubloc").innerHeight();
									  if(pos>hini){div=pos-hini;$("#contenu .ssm").css("margin-top",div+"px");}
									  else{$("#contenu .ssm").css("margin-top","10px");}
		   })
		   
		   $("input[name=inscription_news]").focus(function(){if($(this).val()=="e-mail")	$(this).val('')})
		   
		   	   $("input.check").each(function(){
												 
										$(this).wrap("<div class=\"checkinputs\"></div>")
										$(this).after("<div class=\"fakecheck\">&nbsp;</div>")
										   if($(this).attr("checked")){
											 $(this).next(".fakecheck").css("background","url(design/fond/checkactif.png) no-repeat")
										   }
                  					 	
												 
			})
			   
			   $("#affinage div strong").click(function(){
														
														s="#"+$(this).attr("class");
														sv=s+":hidden"
														s=$(s);sv=$(sv)
														if($(sv).size()==1){
													/*		$("#affinage div ul:visible").hide("1000")*/
														$(s).show("1000")
														}else{
														
															$(s).hide()
														}
														
									
									
									})
			   
			
			   
			 	   $(".flux  .listeelem").each(function(){
														$("li",this).each(function(i){
														   if(i/2!=Math.floor(i/2)){
																	$(this).addClass('back')   
														   }
														   
														   
														   })   })
		   
		   $("input.check").click(function(){
										   if($(this).attr("checked")){
											 $(this).next(".fakecheck").css("background","url(design/fond/checkactif.png) no-repeat")
										 	}else{
											 $(this).next(".fakecheck").css("background","url(design/fond/check.png) no-repeat")
											 
											 }
											 
			})
		   
		   
		   
		   
		   
		   
		   $(".textevenements").each(function(){
									    $("*:gt(3)",this).hide();
									   
													 })
		   
		   if($.browser.msie){
		   	$(".jour").each(function(i){
										 h=$(".evenementsjour",this).height()
										 $(".datejour",this).css("height",h-30)
										 
										 
										 })
		   }
		   
		   initFileUploads() 
          $('img[@src$=.png]').ifixpng();
		   })

var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads() {
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	fakeFileUpload.appendChild(document.createElement('input'));
	var image = document.createElement('img');
	image.src='design/fond/parcourir.png';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file hidden';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
		x[i].onchange = x[i].onmouseout = function () {
			this.relatedElement.value = this.value;
		}
	}
}
