/**
 * Functions to handle the calendar display on the main home page + other functions
 * if you wanna.
 * @author spiritualmind
 */

/* julia channel calendar dedicated website */
var juliachannel_calendar_url = "http://www.calendrierjuliachannel.com" ;

/* build the calendar box / link */
function buildCalendarBox()
{
	//set the html element
	var calendar_box = document.createElement("a") ;
	calendar_box.setAttribute("id","calendar_box") ;
	calendar_box.setAttribute("href",juliachannel_calendar_url) ;
	calendar_box.onclick = function(){window.open(this.href);return false;}
	
	//set the img element to append into the link
	var calendar_img = document.createElement("img") ;
	calendar_img.setAttribute("src","img/juliacalendar2010.gif") ;
	calendar_img.setAttribute("alt","") ;
	
	//add the img into the link box
	calendar_box.appendChild(calendar_img) ;
	
	//add the element on the page
	var body = document.getElementsByTagName("body")[0] ;
	body.appendChild(calendar_box) ;
}

/* build the mask under the link */
function buildCalendarMask() {
	
	var mask = document.createElement("div") ;
	mask.setAttribute("id","mask") ;
	mask.onclick = removeCalendar ;
	
	//add the element on the page
	var body = document.getElementsByTagName("body")[0] ;
	body.appendChild(mask) ;	
}

/* build all the calendar display */
function buildCalendarAll()
{
	setTimeout("buildCalendarMask()","200") ;
	//display the image a short delay after
	setTimeout("buildCalendarBox()","500") ;
}

/* remove element from the page */
function removeCalendar()
{
	var mask = document.getElementById("mask") ;
	var calendar_box = document.getElementById("calendar_box") ;
	var body = document.getElementsByTagName("body")[0] ;
	
    body.removeChild(calendar_box) ;
	body.removeChild(mask) ;
}


window.onload = function() {
	/* display the calendar */
	buildCalendarAll() ;
	/* set the timer to remove the calendar box */
	setTimeout("removeCalendar()","12000") ; //12 sec	
}