ObjDate={};//Initialisation mémoire hash

Event.observe(window,"load",initmain)
function initmain(){
	if($("minicalheb1")){
		Event.stopObserving("minicalheb1");
		Event.observe($("minicalheb1"),"click",affCalendrier);
	}
	if($("minicalheb2")){
		Event.stopObserving("minicalheb2");
		Event.observe($("minicalheb2"),"click",affCalendrier);
	}
	if($("departHeb")){
		Event.stopObserving("departHeb");
		Event.observe($("departHeb"),"click",affCalendrier);
	}
	if($("retourHeb")){
		Event.stopObserving("retourHeb");
		Event.observe($("retourHeb"),"click",affCalendrier);
	}
	$$(".descriptif a").each(function(elt){
		Event.observe(elt,"click",function(e){
			Event.stop(e);
			window.open(elt.href);
		})
	})
}

//Inscription newsletter
function inscNews(baseUrl){
	new Ajax.Request(baseUrl + "/main/inscnews",{parameters:{mail:$F("newsMail")},onSuccess:function(transport){
		alert(transport.responseText.strip());
	}})
}
function inscNewsnl(baseUrl){
	new Ajax.Request(baseUrl + "/main/inscnews",{parameters:{mail:$F("newsMail"),lg:'nl'},onSuccess:function(transport){
		alert(transport.responseText.strip());
	}})
}


function overCalendar(event,duree,id){
	var test2=true;
	var test=false;
	var cnt=0;
	$$('.selcal').each(function(elt){
		if (elt.id==id)test=true;
		if(test){
			if(cnt<duree){
				if (elt.className == 'selcal nondispo') {
					test2 = false;
					Event.findElement(event, "td").style.cursor='';
				}
			}
			cnt++;
		}
		});
	test=false;
	cnt=0;
	if(test2){
		$$('.selcal').each(function(elt){
			if (elt.id==id){
				test=true;
			}
			if(test){
				if (cnt < duree) {
					elt.style.backgroundColor = '#406F9F';
					Event.findElement(event, "td").style.cursor='pointer';
				}
				cnt++;
			}
		})
	}
}




function outCalendar(event,duree, id, periodic){
	var test = false;
	var test2 = true;
	var cnt = 0;
	$$('.selcal').each(function(elt){
		if (elt.id == id) 
			test = true;
		if (test) {
			if (cnt < duree) {
				if (elt.className == 'selcal nondispo') 
					test2 = false;
			}
			cnt++;
		}
	});
	test = false;
	cnt = 0;
	if (test2) {
		if ($('testsel'))$('testsel').value=1;
		$$('.selcal').each(function(elt){
			if (elt.id == id) {
				test = true;
			}
			if (test) {
				
				if (cnt == 0) {
					elt.style.backgroundColor = '#99CC33';	
				}
				else 
					if (cnt < duree) {
						if (periodic == 0) {
							elt.style.backgroundColor = '#99CC33';
						}
						else {
							if(elt.style.cursor=='pointer'){
								elt.style.backgroundColor = '#99CC33';
							}else{
								if (!$('nbnuits')) {
									elt.style.backgroundColor = '#C9E493';
								}else{
									elt.style.backgroundColor = '#99CC33';
								}
							}
							
						}
					}
				cnt++;
			}
		})
	}else{
		if ($('testsel'))$('testsel').value=0;
	}
}
