// (c)2009 Song LAN

function User(id,email,name,birthday,gender)
{this.id=id;this.email=email;this.name=name;this.birthday=birthday;this.gender=gender;};var BoCalendar={today:new Date(),initialize:function()
{this.prepare(["div","td"]);preloader.add("~/static/img/d8_14.gif");preloader.add("~/static/img/d10_14.gif");preloader.add("~/static/moon/p0.gif");preloader.add("~/static/moon/p4.gif");preloader.add("~/static/img/gift.gif");preloader.initialize(BoCalendar.displayToday);BoCheckBox.initialize();namePainter.initialize();},prepare:function(names)
{var t1=new Date();for(var n=0;n<names.length;n++)
{var e;var d;var de=document.getElementsByTagName(names[n]);for(var i=0;i<de.length;i++)
{e=de[i];d=e.id;if(typeof d!="undefined")
$C[d]=e;}}
window.status+=" | "+String((new Date())-t1);},displayToday:function()
{semesterMatrix.initialize(BoCalendar.today);semesterMatrix.display();Timeslider.display(semesterMatrix.year);todayFlasher.start();BoAlphaWindow.autoDisplayToday();},display:function()
{},displayBirthday:function()
{for(var i=0;i<myFriends.length;i++)
{var friend=myFriends[i];if(friend==null)
break;if(friend.birthday.getFullYear()<=semesterMatrix.year)
{var xurl="~/static/img/d10_14.gif";this.setDayImage("bd",friend.birthday.getMonth(),friend.birthday.getDate(),xurl,"birthday: "+friend.name);}}},hideMoonPhase:function()
{preloader.unset("moonphase");},displayMoonPhase:function()
{if(BoCheckBox.flagMoonPhase==false)
return;var phase=0;for(var phase=0;phase<2;phase++)
{var moons=gen(semesterMatrix.year,phase/2);for(var i=0;i<moons.length;i++)
{var moondate=moons[i];if(moondate.getFullYear()==semesterMatrix.year)
{var xurl="~/static/moon/p"+String(phase*4)+".gif";var title=(phase==0)?xcalResx.newMoon:xcalResx.fullMoon;this.setDayImage("moonphase",moondate.getMonth(),moondate.getDate(),xurl,title);}}}},setDayImage:function(type,month,day,imgUrl,title)
{if((semesterMatrix.flipflap==0)&&(month>=6))
return;if((semesterMatrix.flipflap==1)&&(month<6))
return;var xeDImage=$("mx"+String(month%6)+"_i_"+String(day));var img=preloader.set(type,xeDImage,imgUrl,title);}};var BoCheckBox={flagSchoolVacation:true,flagMoonPhase:true,flagSaints:true,initialize:function()
{this.srcOn=myPath.resolveUrl("~/static/img/check-on.gif");this.srcOff=myPath.resolveUrl("~/static/img/check-off.gif");},switchSchoolVacation:function()
{var img=$("checkSchoolVacations");if(this.flagSchoolVacation)
{this.flagSchoolVacation=false;img.src=this.srcOff;BoSchoolVacation.clear();}
else
{this.flagSchoolVacation=true;img.src=this.srcOn;BoSchoolVacation.display();}},switchMoonPhase:function()
{var img=$("checkMoonPhase");if(this.flagMoonPhase)
{this.flagMoonPhase=false;img.src=this.srcOff;BoCalendar.hideMoonPhase();}
else
{this.flagMoonPhase=true;img.src=this.srcOn;BoCalendar.displayMoonPhase();}},switchSaints:function()
{var img=$("checkSaints");if(this.flagSaints)
{this.flagSaints=false;img.src=this.srcOff;namePainter.clear();semesterMatrix.displayDays();}
else
{this.flagSaints=true;img.src=this.srcOn;semesterMatrix.displayDays();}}};var BoSchoolVacation={initialize:function()
{},clear:function()
{for(var month=0;month<6;month++)
for(var i=1;i<=31;i++)
{$("mx"+String(month)+"_s1_"+String(i)).className="schoolClass0";$("mx"+String(month)+"_s2_"+String(i)).className="schoolClass0";$("mx"+String(month)+"_s3_"+String(i)).className="schoolClass0";}},display:function()
{if(BoCheckBox.flagSchoolVacation==false)
return;if(window.schoolVacationData==null)
return;var smFirstDate=semesterMatrix.getFirstDate();var smLastDate=semesterMatrix.getLastDate();var tyData=schoolVacationData[semesterMatrix.year];for(var i in tyData)
{var data=tyData[i];var date=new Date(data.dateStart);if(date>smLastDate)
continue;if(date<smFirstDate)
date=new Date(smFirstDate);var dateEnd=data.dateEnd;if(dateEnd>smLastDate)
dateEnd=smLastDate;while(date<=dateEnd)
{var dd=date.getDate();var ok=semesterMatrix.setDaySchoolVacation(date.getMonth(),dd,data.zone);date.setDate(dd+1);}}}};var namePainter={initialize:function()
{if(window.xcalMonthName!=null)
$("checkSaintsPanel").style.visibility="visible";},clear:function()
{if(window.xcalMonthName==null)
return;for(var month=0;month<6;month++)
{var prefix="mx"+String(month)+"_l_";for(var i=1;i<=31;i++)
{$(prefix+String(i)).innerHTML="";}}},display:function()
{if(BoCheckBox.flagSaints==false)
return;if(window.xcalMonthName==null)
return;for(var m=0;m<6;m++)
{var mm=semesterMatrix.flipflap*6+m;var dateMax=new Date(semesterMatrix.year,mm+1,0).getDate();var prefix="mx"+String(m)+"_l_";for(var i=0;i<dateMax;i++)
{$(prefix+String(i+1)).innerHTML=window.xcalMonthName[mm][i];}}}};var todayFlasher={year:0,tempo:500,start:function()
{this.year=semesterMatrix.year;this.month=semesterMatrix.today.getMonth();this.date=semesterMatrix.today.getDate();this.on();},on:function()
{if(this.year!=semesterMatrix.year)
return;semesterMatrix.setDayStyle(this.month,this.date,"day today",null);if(this.tempo<100)
return;window.setTimeout("todayFlasher.off();",this.tempo);this.tempo-=25;},off:function()
{semesterMatrix.setDayStyle(this.month,this.date,"day",null);window.setTimeout("todayFlasher.on();",this.tempo);this.tempo-=25;}};var yearChanger={hasToStop:false,timerHandler:null,delay:0,rewindStart:function()
{semesterMatrix.flipPrev();this.hasToStop=true;this.delay=200;this.timerHandler=window.setTimeout("yearChanger.rewind();",500);},forwardStart:function()
{semesterMatrix.flipNext();this.hasToStop=true;this.delay=200;this.timerHandler=window.setTimeout("yearChanger.forward();",500);},stop:function(element)
{if(this.hasToStop==false)
return;this.hasToStop=false;window.clearTimeout(this.timerHandler);doAction.doWait(element,'semesterMatrix.display();');Timeslider.display(semesterMatrix.year);},rewind:function()
{$("calendarYear").innerHTML=--semesterMatrix.year;Timeslider.display(semesterMatrix.year);this.timerHandler=window.setTimeout("yearChanger.rewind();",this.delay);if(this.delay>20)
this.delay-=20;},forward:function()
{$("calendarYear").innerHTML=++semesterMatrix.year;Timeslider.display(semesterMatrix.year);this.timerHandler=window.setTimeout("yearChanger.forward();",this.delay);if(this.delay>20)
this.delay-=20;}};function AwItem(type,id,title,date,description)
{this.id=id;this.type=type;this.title=title;this.date=date;this.description=description};var BoAlphaWindow={autoDisplayToday:function()
{var mm=semesterMatrix.today.getMonth()%6;this.display(mm,semesterMatrix.today.getDate(),true);},display:function(mm,dd,nodatanodisplay)
{mm+=6*semesterMatrix.flipflap;var date=new Date(semesterMatrix.year,mm,dd);var title=date.toDateString();var data=[];for(var i=0;i<specialDays.length;i++)
{var sd=specialDays[i];if(sd==null)
break;if((sd.date.valueOf()==date.valueOf())||((sd.type==1)&&(sd.date.getMonth()==mm)&&(sd.date.getDate()==dd)))
{var awItem=new AwItem(0,0,sd.title,sd.date,sd.description);data.push(awItem);}}
for(var i=0;i<myFriends.length;i++)
{var friend=myFriends[i];if(friend==null)
break;if((friend.birthday.getMonth()==mm)&&(friend.birthday.getDate()==dd))
{var awItem=new AwItem(1+friend.gender,friend.id,friend.name,friend.birthday,friend.birthday.toLocaleDateString());data.push(awItem);}}
if(nodatanodisplay&&(data.length==0))
return;AlphaWindow.display(title,data);}};var $C={};function $(id)
{var element=$C[id];if(element==null)
{element=document.getElementById(id);$C[id]=element;}
return element;}
String.prototype.trim=function(){return(this.replace(/^\s+|\s+$/g,""));};String.prototype.toDate=function()
{if((!this)||(this.length==0))return null;var yyyy=this.substr(0,4);var M=Number(this.substr(4,2))-1;var dd=this.substr(6,2);if(this.length==8)
return new Date(yyyy,M,dd);else
{var HH=this.substr(8,2);var mm=this.substr(10,2);return new Date(yyyy,M,dd,HH,mm);}};String.prototype.asIntegerFormat=function(strPattern)
{var pref=strPattern.substring(this.length);return(pref+this);}
Date.prototype.formatDateTime=function(pattern)
{pattern=this.formatDate(pattern);return(this.formatTime(pattern));}
Date.prototype.formatDate=function(pattern)
{var yyyy=String(this.getFullYear()).asIntegerFormat("0000");var yy=String(this.getYear()).asIntegerFormat("0000");var M=String(this.getMonth()+1);var MM=M.asIntegerFormat("00");var d=String(this.getDate());var dd=d.asIntegerFormat("00");pattern=pattern.replace("yyyy",yyyy);pattern=pattern.replace("yy",yy);pattern=pattern.replace("MM",MM);pattern=pattern.replace("M",M);pattern=pattern.replace("dd",dd);pattern=pattern.replace("d",d);return(pattern);}
Date.prototype.formatTime=function(pattern)
{var h=String(this.getHours());var hh=h.asIntegerFormat("00");var m=String(this.getMinutes());var mm=m.asIntegerFormat("00");var s=String(this.getSeconds());var ss=s.asIntegerFormat("00");pattern=pattern.replace("hh",hh);pattern=pattern.replace("h",h);pattern=pattern.replace("mm",mm);pattern=pattern.replace("m",m);pattern=pattern.replace("ss",ss);pattern=pattern.replace("s",s);return(pattern);}
Date.prototype.getDeltaDayDate=function(deltaDay)
{var date=new Date(this);date.setDate(this.getDate()+deltaDay);return(date);}
Date.prototype.quantieme=function()
{return Math.round((this-new Date(this.getFullYear(),0,1))/86400000)+1;}
var dom={"clearChildren":function(element)
{var e=element.lastChild;while(e)
{var z=e.previousSibling;element.removeChild(e);e=z;}},"insertElement":function(parentElement,ename,className)
{var element=document.createElement(ename);if(className)
element.className=className;parentElement.appendChild(element);return(element);},"insertTextNode":function(parentElement,text,className)
{var element=document.createTextNode(text);if(className)
element.className=className;parentElement.appendChild(element);return(element);},"getNextSibling":function(element)
{var nextElement=element.nextSibling;if(element.toString()!=nextElement.toString())
{nextElement=nextElement.nextSibling;}
return nextElement;},getPosX:function(element)
{var x=0;do
{x+=element.offsetLeft;}
while(element=element.offsetParent);return x;},getPosY:function(element)
{var y=0;do
{y+=element.offsetTop;}
while(element=element.offsetParent);return y;}}
var jsCookie={"create":function(name,value,days)
{var expires="";if(days)
{var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires=";expires="+date.toGMTString();}
document.cookie=name+"="+value+expires+";path=/";},"read":function(name)
{var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++)
{var c=ca[i].trim();if(c.indexOf(nameEQ)==0)return(c.substring(nameEQ.length,c.length));}
return(null);},"remove":function(name)
{this.create(name,"",-1);}}
var Mouse={x:0,y:0,callbackMove:null,callbackUp:null,"initialize":function()
{document.onmousemove=Mouse.onmove;document.onmouseup=Mouse.onup;document.onselectstart=function(){return false;};},getMouseXY:function(e)
{if(!e)e=window.event;Mouse.x=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;Mouse.y=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;return true;},process:function()
{if(this.callbackMove!=null)
this.callbackMove();},onmove:function(e)
{if(Mouse.callbackMove==null)
return;Mouse.getMouseXY(e);Mouse.process();},onup:function()
{if(Mouse.callbackUp!=null)
Mouse.callbackUp();}};var my={isWebkit:navigator.userAgent.toLowerCase().indexOf('webkit')>-1,isIE6:navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1,"browserAAA":(window.XMLHttpRequest!=null),"img":function(img,url)
{if(img.onload!=null)
img.onload=null;var isPNG=(url.toLowerCase().indexOf('.png')>0);url=myPath.resolveUrl(url);if(this.browserAAA)
{img.src=url;return;}
if(isPNG)
{img.src=url.replace('.png','.gif');return;if(img.style.filter!=null)
{img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+url+"')";img.src="static/img/blank.gif";return;}}
img.src=url;},"opacity":function(element,x)
{if(element.style.opacity!=null)
element.style.opacity=x;else
element.style.filter="alpha(opacity="+(x*100)+")";}}
var myDate={"day2ms":3600000*24,"getMonthDayCount":function(year,month){return(new Date(year,Number(month)+1,0).getDate());},"getWeeknum":function(year,month,day){var date=new Date(year,month,day);var weekday=date.getDay();var quantieme=date.quantieme();var x=Math.floor((quantieme+10-weekday)/7);return(x);},"getDayCountBetween":function(ds,de){return Math.floor((de-ds)/this.day2ms);}};var myEvent={"add":function addEvent(obj,type,fn)
{if(obj.attachEvent)
{obj.attachEvent('on'+type,fn);}
else
obj.addEventListener(type,fn,true);},"remove":function removeEvent(obj,type)
{if(obj.detachEvent)
{obj.detachEvent('on'+type,obj[type+fn]);}
else
obj.removeEventListener(type,fn,true);}}
var preloader={"list":[],"cache":{},pools:{},poolouts:{},"loadedCount":0,"initialize":function(callback)
{this.callback=callback;for(var index in this.list)
{var src=this.list[index];src=myPath.resolveUrl(src);if(this.cache[src]!=null)
continue;var img=new Image();this.cache[src]=img;img.onload=this.onload;img.onerror=this.onload;img.onabort=this.onload;img.src=myPath.resolveUrl(src);}},"add":function(src)
{if(my.isIE6)
src=src.replace(".png",".gif");this.list.push(src);},"addlist":function(list)
{for(var i=0;i<list.length;i++)
{var src=list[i];if(my.isIE6)
src=src.replace(".png",".gif");this.list.push(src);}},"set":function(type,parentNode,src,title)
{if(my.isIE6)
src=src.replace(".png",".gif");src=myPath.resolveUrl(src);var pool=this.pools[src];var img;if((pool)&&(pool.length>0))
img=pool.pop();else
img=this.cache[src].cloneNode(false);if(title!=null)
img.title=title;parentNode.appendChild(img);var poolout=this.poolouts[type];if(poolout==null)
{poolout=[];this.poolouts[type]=poolout;}
poolout.push(img);return img;},"unset":function(type)
{var poolout=this.poolouts[type];while(poolout.length>0)
{var img=poolout.pop();var parentNode=img.parentNode;parentNode.removeChild(img);var pool=this.pools[img.src];if(pool==null)
{pool=new Array();this.pools[img.src]=pool;}
pool.push(img);}},"unsetAll":function()
{for(var type in this.poolouts)
this.unset(type);},"release":function(parentNode)
{var img=parentNode.lastChild;if(img==null)return;var pool;while(img)
{var z=img.previousSibling;parentNode.removeChild(img);var src=img.src;pool=this.pools[src];if(pool==null)
{pool=new Array();this.pools[src]=pool;}
pool.push(img);img=z;}},"onload":function()
{preloader.loadedCount++;if(preloader.loadedCount==preloader.list.length)
if(preloader.callback)
preloader.callback();else
alert('Preloader completed');}};function JSRequest(url,action,h_params,callbackFnName)
{var params='action='+action;for(var key in h_params)
{params+='&'+key+'='+encodeURIComponent(String(h_params[key]));}
if(callbackFnName)params+='&callback='+callbackFnName;var head=document.getElementsByTagName('head')[0];var script=document.createElement('script');script.setAttribute('type','text/javascript');script.setAttribute('src',url+'?'+params);head.appendChild(script);};var myValidator={email:function(email)
{var re_email=/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/;return re_email.exec(email);}};var Initializer={items:[],initialize:function()
{for(var i=0;i<this.items.length;i++)
{this.items[i].initialize();}},push:function(item)
{this.items.push(item);}};var WindowTrigger={wresizeItems:[],initialize:function()
{window.onresize=WindowTrigger.onresize;},onresize:function()
{for(var i=0;i<WindowTrigger.wresizeItems.length;i++)
{WindowTrigger.wresizeItems[i].resize();}},wresizePush:function(item)
{this.wresizeItems.push(item);}};Initializer.push(WindowTrigger);function TooltipItem(title,xhtml,w,h)
{this.title=title;this.xhtml=xhtml;this.w=w;this.h=h;};var Tooltip={source:null,"matrix_h":{},timerHandler:null,"initialize":function()
{},"displayDelayed":function(e,source,id)
{var d=$(id);if(d==null)
return;this.source=source;this.lastElement=d;if(this.timerHandler!=null)
window.clearTimeout(this.timerHandler);Mouse.getMouseXY(e);this.timerHandler=window.setTimeout("Tooltip.display();",700);},"display":function()
{this.posi();this.lastElement.style.visibility="visible";},"posi":function()
{var d=this.lastElement;if(d==null)
return;var x=Number(Mouse.x)-(d.offsetWidth>>1);var xDelta=d.offsetWidth-document.documentElement.scrollLeft;if(x<0)
x=0;else
if(x+xDelta>document.documentElement.offsetWidth)
x=document.documentElement.offsetWidth-xDelta;d.style.left=String(x)+"px";var y=dom.getPosY(this.source)+this.source.offsetHeight+1;if(y-document.documentElement.scrollTop+d.offsetHeight>document.documentElement.offsetHeight)
y-=d.offsetHeight+this.source.offsetHeight;d.style.top=String(y)+"px";},"move":function(e)
{Mouse.getMouseXY(e);this.posi();return;var d=this.lastElement;if(d==null)
return;var x=Number(Mouse.x)-(d.offsetWidth>>1);var y=Number(Mouse.y)+16;if(y-document.documentElement.scrollTop+d.offsetHeight>document.documentElement.offsetHeight)
y-=d.offsetHeight+32;d.style.left=String(x)+"px";d.style.top=String(y)+"px";},"hide":function()
{if(this.timerHandler!=null)
window.clearTimeout(this.timerHandler);if(this.lastElement!=null)
this.lastElement.style.visibility="hidden";},"displayAuto":function()
{var tooltipItem=Tooltip.matrix_h[this];this.display(tooltipItem.title,tooltipItem.xhtml,tooltipItem.w,tooltipItem.h);},"setAuto":function(element,title,xhtml,w,h)
{this.matrix_h[element]=new TooltipItem(title,xhtml,w,h);element.onmouseover=this.display;element.onmouseout=this.hide;}};Tooltip.initialize();var TooltipDay={xhtml:null,initialize:function()
{this.bubble=$("tooltipDay");this.speakLeft=$("tooltipDaySpeakLeft");this.speakRight=$("tooltipDaySpeakRight");},display:function(x,y,xhtml,modeLeft)
{if(this.timerHandler!=null)
window.clearTimeout(this.timerHandler);if(this.bubble==null)
this.initialize();this.x=x;this.y=y;this.xhtml=xhtml;this.modeLeft=modeLeft;this.timerHandler=window.setTimeout("TooltipDay.displayDelayed();",100);},displayDelayed:function()
{this.bubble.innerHTML=xhtml;if(this.modeLeft)
{this.speakLeft.style.left=String(this.x-5)+"px";this.speakLeft.style.top=String(this.y)+"px";this.speakLeft.style.visibility="visible";this.bubble.style.left=String(this.x-this.bubble.offsetWidth-5)+"px";}
else
{this.speakRight.style.left=String(this.x+1)+"px";this.speakRight.style.top=String(this.y)+"px";this.speakRight.style.visibility="visible";this.bubble.style.left=String(this.x+5)+"px";}
this.bubble.style.top=String(this.y+5-this.bubble.offsetHeight/2)+"px";this.bubble.style.visibility="visible";},hide:function()
{if(this.timerHandler!=null)
window.clearTimeout(this.timerHandler);if(this.bubble==null)
return;this.bubble.style.visibility="hidden";this.speakLeft.style.visibility="hidden";this.speakRight.style.visibility="hidden";}};var MeuhLol=["Tu me fais rire.","Salut !","Ca va ?","Comment tu t'appelles ?<br />Moi c'est Meuhmeuh.","Tu veux ma photo ?","Patate !","Tu es fatigué ?<br />Va te reposer, tu as trop travaillé.","Mouahahahaha","Va mater chez ta collègue<br />pour voir si j'y suis.","Coucou, je suis là.","Je suis fatiguée de te parler<br />dans le vide.","Vas bosser un peu<br />au lieu de me mater STP.","... ","lol","Bosse un peu mon pote,<br />Tu te crois à la SNCF ou quoi.","Ca motive pas de te voir.","Meuuuh meuuuuh, hahaha.","Tu me trouves belle ?","Ca va dans ta campagne ?"];var Meuh={footerPanel:null,meuh:null,meuhSpeaking:null,meuhBubble:null,y:0,initialize:function()
{this.footerPanel=$("footerPanel");this.meuh=$("meuhmeuh");this.meuhSpeaking=$("meuhSpeaking");this.meuhBubble=$("meuhBubble");Meuh.resize();WindowTrigger.wresizePush(this);this.meuh.style.display="block";this.speak("Salut !");},resize:function()
{if(this.meuh==null)
return;var y=dom.getPosY(this.footerPanel);if(y==this.y)
return;this.y=y;this.meuh.style.top=String(this.y-42)+"px";this.meuhSpeaking.style.top=String(this.y-52)+"px";Meuh.meuhSpeaking.style.visibility="hidden";Meuh.meuhBubble.style.visibility="hidden";},speak:function(msg)
{if(msg==null)
{var i=MeuhLol.length;i=Math.floor(Math.random()*i);msg=MeuhLol[i];}
this.meuhBubble.innerHTML=msg;var h=this.meuhBubble.offsetHeight;this.meuhBubble.style.top=String(Meuh.y-51-h)+"px";this.meuhBubble.style.visibility="visible";this.meuhSpeaking.style.visibility="visible";window.setTimeout("Meuh.shutup();",10000);},shutup:function()
{this.meuhBubble.style.visibility="hidden";this.meuhSpeaking.style.visibility="hidden";window.setTimeout("Meuh.speak();",5000);}};var formula={"easter":function(year)
{var b=year-1900;var c=year%19;var d=Math.floor((7*c+1)/19);var e=(11*c+4-d)%29;var f=Math.floor(b/4);var g=(b+f+31-e)%7;var avril=25-e-g;if(avril>0)
return(new Date(year,3,avril));else
return(new Date(year,2,avril+31));},"moon":function()
{}};function getNextMP(date)
{var bluemoon=new Date(1999,11,7,22,32,00);var dayms=3600000*24;var lp=29.5305888;var phasetime=((date-bluemoon)/dayms)%lp;var lpn=lp-phasetime;return lpn;};function proper_ang(big)
{with(Math)
{var tmp=0;if(big>0)
{tmp=big/360.0;tmp=(tmp-floor(tmp))*360.0;}
else
{tmp=ceil(abs(big/360.0));tmp=big+tmp*360.0;}}
return tmp;};function jdn(date)
{var yy=date.getFullYear();var mm=date.getMonth();var dd=date.getDate();with(Math)
{var yyy=yy;var mmm=mm;if(mm<3)
{yyy=yyy-1;mmm=mm+12;}
var day=dd+0.5;var a=floor(yyy/100);var b=2-a+floor(a/4);jd=floor(365.25*yyy)+floor(30.6001*(mmm+1))+day+1720994.5;if(jd>2299160.4999999)jd=jd+b;return jd;}};function dsin(x)
{return Math.sin((x*Math.PI)/180.0);};function dcos(x)
{return Math.cos((x*Math.PI)/180.0);};function truephase(k,phase)
{var SynMonth=29.53058868;k+=phase;var t=k/1236.85;var t2=t*t;var t3=t2*t;var pt=2415020.75933+SynMonth*k+0.0001178*t2-0.000000155*t3
+0.00033*dsin(166.56+132.87*t-0.009173*t2);var m=359.2242+29.10535608*k-0.0000333*t2-0.00000347*t3;var mprime=306.0253+385.81691806*k+0.0107306*t2+0.00001236*t3;var f=21.2964+390.67050646*k-0.0016528*t2-0.00000239*t3;if((phase<0.01)||(Math.abs(phase-0.5)<0.01))
{pt+=(0.1734-0.000393*t)*dsin(m)
+0.0021*dsin(2*m)
-0.4068*dsin(mprime)
+0.0161*dsin(2*mprime)
-0.0004*dsin(3*mprime)
+0.0104*dsin(2*f)
-0.0051*dsin(m+mprime)
-0.0074*dsin(m-mprime)
+0.0004*dsin(2*f+m)
-0.0004*dsin(2*f-m)
-0.0006*dsin(2*f+mprime)
+0.0010*dsin(2*f-mprime)
+0.0005*dsin(m+2*mprime);}
else if((Math.abs(phase-0.25)<0.01||(Math.abs(phase-0.75)<0.01)))
{pt+=(0.1721-0.0004*t)*dsin(m)
+0.0021*dsin(2*m)
-0.6280*dsin(mprime)
+0.0089*dsin(2*mprime)
-0.0004*dsin(3*mprime)
+0.0079*dsin(2*f)
-0.0119*dsin(m+mprime)
-0.0047*dsin(m-mprime)
+0.0003*dsin(2*f+m)
-0.0004*dsin(2*f-m)
-0.0006*dsin(2*f+mprime)
+0.0021*dsin(2*f-mprime)
+0.0003*dsin(m+2*mprime)
+0.0004*dsin(m-2*mprime)
-0.0003*dsin(2*m+mprime);var correction=0.0028-0.0004*dcos(m)+0.0003*dcos(mprime);if(phase<0.5)
pt+=correction;else
pt-=correction;}
return pt;};function gen(year,phase)
{var phaset=[];var k1=Math.floor((year-1900)*12.3685)-4;var i=0;while(true)
{var mtime=truephase(k1,phase);var date=new Date();date.setTime((mtime-2440587.5)*86400000);var yyyy=date.getFullYear();if(yyyy==year)
{phaset[i++]=date;}
if(yyyy>year)
break;k1++;}
return phaset;};var semesterMatrix={flipflap:0,today:new Date(),initialize:function(date)
{this.year=date.getFullYear();var MM=date.getMonth();if(MM>5)
this.flipflap=1;},display:function()
{$("calendarYear").innerHTML=String(this.year);for(var i=0;i<6;i++)
{monthMatrix.initialize(i,this.year,i,this.flipflap);monthMatrix.display();}
this.displayDays();preloader.unsetAll();sDayPainter.display();BoCalendar.displayBirthday();BoCalendar.displayMoonPhase();BoSchoolVacation.clear();BoSchoolVacation.display();if(this.year==this.today.getFullYear())
this.setDayStyle(this.today.getMonth(),this.today.getDate(),"day today",null);},displayDays:function()
{if(BoCheckBox.flagSaints)
namePainter.display();if(typeof resxSemesterMatrix!="undefined")
resxSemesterMatrix.display();holidayPainter.display();},displayPart2:function()
{},displayPart3:function()
{},addYear:function(step)
{this.year+=step;this.display();},flipPrev:function()
{if(this.flipflap==0)
{this.flipflap=1;this.year--;}
else
{this.flipflap=0;}},flipNext:function()
{if(this.flipflap==0)
{this.flipflap=1;}
else
{this.flipflap=0;this.year++;}},getFirstDate:function()
{return new Date(this.year,this.flipflap*6,1);},getLastDate:function()
{return new Date(this.year,this.flipflap*6+6,0);},setDayStyleD:function(date,className,title)
{var MM=date.getMonth();var dd=date.getDate();this.setDayStyle(MM,dd,className,title);},setDayStyle:function(month,day,className,title)
{if((this.flipflap==0)&&(month>=6))
return;if((this.flipflap==1)&&(month<6))
return;var xeDCellId="mx"+String(month%6)+"_c_"+String(day);var xeDCell=$(xeDCellId);xeDCell.className=className;var xeDTitle=$("mx"+String(month%6)+"_l_"+String(day));if(title!=null)
xeDTitle.innerHTML=title;},setDayImage:function(month,day,imgUrl,title)
{if((this.flipflap==0)&&(month>=6))
return;if((this.flipflap==1)&&(month<6))
return;var xeDImage=$("mx"+String(month%6)+"_i_"+String(day));var img=preloader.set("default",xeDImage,imgUrl,title);},setDaySchoolVacation:function(month,day,index)
{if((this.flipflap==0)&&(month>=6))
return false;if((this.flipflap==1)&&(month<6))
return false;var cell=$("mx"+String(month%6)+"_s"+String(index)+"_"+String(day));cell.className="schoolClass"+String(index);return true;}};function SchoolVA(dateStart,dateEnd,zone)
{this.dateStart=dateStart;this.dateEnd=dateEnd;this.zone=zone;};function Holiday(dateStart,title)
{this.dateStart=dateStart;this.title=title;};var holidayPainter={initialize:function()
{},display:function()
{if(window.holidaysData==null)
return;for(var i in window.holidaysData)
{var data=holidaysData[i];var date=data.dateStart;if(date.getFullYear()<=semesterMatrix.year)
semesterMatrix.setDayStyle(date.getMonth(),date.getDate(),"day holiday",data.title);}}};function SDay(date,title,type,description)
{this.date=date;this.title=title;this.type=type;this.description=description;};var sDayPainter={initialize:function()
{},display:function()
{if(window.specialDays==null)
return;for(var i in window.specialDays)
{var data=window.specialDays[i];if(data==null)
break;var date=data.date;var toYear=date.getFullYear();if((toYear==semesterMatrix.year)||((data.type==1)&&(toYear<semesterMatrix.year)))
{semesterMatrix.setDayImage(date.getMonth(),date.getDate(),"~/static/img/d8_14.gif",data.title);}}}};var xcalDayShort=['D','L','M','M','J','V','S'];var xcalMonth=["JANVIER","FEVRIER","MARS","AVRIL","MAI","JUIN","JUILLET","AOUT","SEPTEMBRE","OCTOBRE","NOVEMBRE","DECEMBRE"];var xcalResx={fullMoon:"pleine lune",newMoon:"nouvelle lune"};var resxSemesterMatrix={display:function()
{var sm=semesterMatrix;var easter=formula.easter(sm.year);sm.setDayStyleD(easter.getDeltaDayDate(-7),"day holiday","Rameaux");sm.setDayStyleD(easter,"day holiday","Paques");sm.setDayStyleD(easter.getDeltaDayDate(1),"day holiday","lundi de Paques");sm.setDayStyleD(easter.getDeltaDayDate(39),"day holiday","Ascension");sm.setDayStyleD(easter.getDeltaDayDate(49),"day holiday","Pentecote");sm.setDayStyleD(easter.getDeltaDayDate(50),"day holiday","lundi de Pentecote");sm.setDayStyle(7,15,"day holiday","Assomption");}};var monthMatrix={ONEDAY:3600000*24,initialize:function(index,year,month,flipflap)
{this.index=index;this.year=year;this.month=month+6*flipflap;this.flipflap=flipflap;$("mx"+String(this.index)+'_title').innerHTML=String(xcalMonth[this.month]);},getCellHeight:function()
{switch(myTheme.theme)
{case"normal":return 16;case"small":return 14;default:return 16;};},display:function()
{var date=new Date(this.year,this.month,1);var day=date.getDay();var dateMax=new Date(this.year,this.month+1,0).getDate();var deltaY0=0;var deltaY1=7;var xeWeekNum1Height=112;switch(day)
{case 0:deltaY0=1;break;case 1:deltaY0=0;break;case 2:deltaY0=0;break;case 3:deltaY0=0;deltaY1=5;break;case 4:deltaY0=4;break;case 5:deltaY0=3;break;case 6:deltaY0=2;break;}
var weekNum=myDate.getWeeknum(this.year,this.month,deltaY0+1);var xeWeekNum="mx"+String(this.index)+"_h_";var ch=this.getCellHeight();deltaY0*=ch;deltaY1*=ch;$(xeWeekNum+"0").style.height=String(deltaY0)+"px";$(xeWeekNum+"1").style.height=String(deltaY1)+"px";for(var i=1;i<=4;i++)
{$(xeWeekNum+String(i)).innerHTML=String(weekNum++);}
var prefix="mx"+String(this.index);var xeDCellPrefix=prefix+"_c_";var xeDate=prefix+"_d_";var xeDay=prefix+"_t_";var xeTitle=prefix+"_l_";for(var i=1;i<=dateMax;i++)
{var xeDCell=$(xeDCellPrefix+String(i));switch(day)
{case 0:xeDCell.className="day sunday";break;case 6:xeDCell.className="day saturday";break;default:xeDCell.className="day normal";break;}
$(xeDate+String(i)).innerHTML=String(i);$(xeDay+String(i)).innerHTML=xcalDayShort[day];dom.clearChildren($(xeTitle+String(i)));day=(day+1)%7;}
for(var i=dateMax+1;i<=31;i++)
{var xeDCellId=xeDCellPrefix+String(i);$(xeDCellId).className="day";dom.clearChildren($(xeDate+String(i)));dom.clearChildren($(xeDay+String(i)));dom.clearChildren($(xeTitle+String(i)));}},buildBase:function(mm)
{var table_mm=document.createElement("table");table_mm.setAttribute("cellpadding","0");table_mm.setAttribute("cellspacing","0");table_mm.style.width="100%";var table_mm_tbody=document.createElement("tbody");table_mm_tbody.className="tbody";table_mm.appendChild(table_mm_tbody);for(var i=1;i<=31;i++)
{var tr_c=document.createElement("tr");table_mm_tbody.appendChild(tr_c);var td_c=document.createElement("td");td_c.id="mx"+String(mm)+"_c_"+String(i);td_c.className="day normal";td_c.setAttribute("onclick","BoAlphaWindow.display("+String(mm)+", "+String(i)+");");tr_c.appendChild(td_c);var table=document.createElement("table");table.setAttribute("cellpadding","0");table.setAttribute("cellspacing","0");table.className="calDayPanel";td_c.appendChild(table);var table_tbody=document.createElement("tbody");table_tbody.className="tbody";table.appendChild(table_tbody);var tr=document.createElement("tr");table_tbody.appendChild(tr);var td_d=document.createElement("td");td_d.id="mx"+String(mm)+"_d_"+String(i);td_d.className="calCellDate";tr.appendChild(td_d);var td_t=document.createElement("td");td_t.id="mx"+String(mm)+"_t_"+String(i);td_t.className="calCellDay";tr.appendChild(td_t);var td_k=document.createElement("td");td_k.id="mx"+String(mm)+"_k_"+String(i);td_k.className="calCellTitle";tr.appendChild(td_k);var div_l=document.createElement("div");div_l.id="mx"+String(mm)+"_l_"+String(i);div_l.className="calCellTitleD1";td_k.appendChild(div_l);var div_i=document.createElement("div");div_i.id="mx"+String(mm)+"_i_"+String(i);div_i.className="calCellTitleD2";td_k.appendChild(div_i);var td_s=document.createElement("td");td_s.className="schoolClassCell";tr.appendChild(td_s);var table_s=document.createElement("table");table_s.setAttribute("cellpadding","0");table_s.setAttribute("cellspacing","0");table_s.style.height="100%";td_s.appendChild(table_s);var table_s_tbody=document.createElement("tbody");table_s_tbody.className="tbody";table_s.appendChild(table_s_tbody);var tr_s=document.createElement("tr");table_s_tbody.appendChild(tr_s);var td_s1=document.createElement("td");td_s1.id="mx"+String(mm)+"_s1_"+String(i);td_s1.className="schoolClass0";tr_s.appendChild(td_s1);var td_s2=document.createElement("td");td_s2.id="mx"+String(mm)+"_s2_"+String(i);td_s2.className="schoolClass0";tr_s.appendChild(td_s2);var td_s3=document.createElement("td");td_s3.id="mx"+String(mm)+"_s3_"+String(i);td_s3.className="schoolClass0";tr_s.appendChild(td_s3);$C[td_c.id]=td_c;$C[td_d.id]=td_d;$C[td_t.id]=td_t;$C[td_k.id]=td_k;$C[div_l.id]=div_l;$C[div_i.id]=div_i;$C[td_s1.id]=td_s1;$C[td_s2.id]=td_s2;$C[td_s3.id]=td_s3;}
return table_mm;}};monthMatrix.Tooltip={display:function(element,month,day)
{month+=6*semesterMatrix.flipflap;var date=new Date(semesterMatrix.year,month,day);if(month!=date.getMonth())
return;$("textDOTY").innerHTML=String(date.quantieme());if(element==this.elementToDisplay)
return;if(this.elementToDisplay!=null)
this.elementToDisplay.className=this.elementToDisplayClassName;this.elementToDisplay=element;this.elementToDisplayClassName=element.className;element.className="day overday";return;var x=dom.getPosX(element);var modeLeft=false;if((month%6)<3)
x+=element.offsetWidth;else
modeLeft=true;var y=dom.getPosY(element);xhtml="Jour de l'année : "+String(date.quantieme());xhtml+="<br />Ephéméride : N/A";xhtml+="<br />Fete : N/A";TooltipDay.display(x,y,xhtml,modeLeft);}};var Timeslider={initialize:function()
{this.element=$("buttonTimeslider");WindowTrigger.wresizePush(this);},start:function()
{Mouse.callbackMove=Timeslider.move;Mouse.callbackUp=Timeslider.stop;},stop:function()
{Mouse.callbackMove=null;Mouse.callbackUp=null;semesterMatrix.year=Timeslider.year;semesterMatrix.flipflap=(semesterMatrix.flipflap+1)&1;semesterMatrix.display();},resize:function()
{Timeslider.display(Timeslider.year);},move:function()
{var x=(Mouse.x-21)>>3;var w=document.body.offsetWidth-42;var year=x+2000-(w>>4);Timeslider.display(year);$("calendarYear").innerHTML=year;},display:function(year)
{Timeslider.year=year;var w=document.body.offsetWidth-42;var x=(year-2000+(w>>4))<<3;if(x<0)
x=0;if(x>w)
x=w;Timeslider.element.style.left=String(x)+"px";Timeslider.element.innerHTML=String(this.year);}};var AlphaWindow={initialize:function()
{this.window=$("alphaWindow");this.panelScroller=$("awPanelScroller");this.panel=$("awPanel");this.panelShadow=$("awPanelShadow");this.awData=$("awData");},display:function(title,data)
{this.databind(title,data);this.window.style.width=String(document.documentElement.scrollWidth)+"px";this.window.style.height=String(document.documentElement.scrollHeight)+"px";this.window.style.display="block";var width=this.panel.offsetWidth;var height=this.panel.offsetHeight;this.panelScroller.style.width=String(width)+"px";this.panelScroller.style.height=String(height)+"px";this.panelShadow.style.height=String(height)+"px";this.scrollH=height;this.scroller();},databind:function(title,data)
{$("awTitle").innerHTML=title;dom.clearChildren(this.awData);for(var i in data)
{var item=data[i];if(item.type==0)
this.bindSpecialDay(this.awData,item);else
this.bindBirthday(this.awData,item);}},bindSpecialDay:function(parentNode,item)
{var div=document.createElement("div");div.className="awItem";var title=document.createElement("h4");title.innerHTML=item.title;var description=document.createElement("div");description.innerHTML=item.description;div.appendChild(title);div.appendChild(description);parentNode.appendChild(div);},bindBirthday:function(parentNode,item)
{var div=document.createElement("div");div.className="awItem";var a=document.createElement("a");a.className="linkBirthday";a.href="public/profil.aspx?id="+item.id;var img=preloader.set("default",a,"~/static/img/gift.gif","");img.style.borderWidth=0;a.appendChild(document.createTextNode(" "+item.title));var description=document.createElement("div");description.appendChild(document.createTextNode(item.description));div.appendChild(a);div.appendChild(description);parentNode.appendChild(div);},scroller:function()
{this.scrollH-=8;if(this.scrollH<0)
this.scrollH=0;this.panelScroller.scrollTop=this.scrollH;if(this.scrollH>0)
window.setTimeout("AlphaWindow.scroller();",10);},hide:function()
{this.panel.style.display="none";}};