
function createRequestObject() {
	FORM_DATA = new Object();
	separator = ',';
	query = '' + this.location;
	query = query.substring((query.indexOf('?')) + 1);
	if (query.length < 1) { return false; }
	keypairs = new Object();
	numKP = 1;
	while (query.indexOf('&') > -1) {
		keypairs[numKP] = query.substring(0,query.indexOf('&'));
		query = query.substring((query.indexOf('&')) + 1);
		numKP++;
	}

	keypairs[numKP] = query;
	for (i in keypairs) {
		keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
		keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
		while (keyValue.indexOf('+') > -1) {
			keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
		}
    
		keyValue = unescape(keyValue);
      
		if (FORM_DATA[keyName]) {
			FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
		} else {
			FORM_DATA[keyName] = keyValue;
		}
	}
	return FORM_DATA;
}
FORM_DATA = createRequestObject();
//==========================================
function getCurntDate() {
	var temp;
	var arr = document.cookie.toString().split(";");
	for (var i=0; i < arr.length; i++) {
		if (arr[i].length > 1) {
			if (arr[i].indexOf("=")) {
				temp = arr[i].split("=");
				if (temp[0] == "curntDate") {
					curntDate = temp[1];
				}
			}
		}
	}
	if (curntDate.length > 0) {
		curntDate = new Date(curntDate);
	}
}
curntDate = "";
formelement = "DateIn";
formname = "resform";
getCurntDate();
for (i in FORM_DATA) {
	if (i == "curntdate" || i == "curntDate") {
		curntDate = FORM_DATA[i];
		curntDate = new Date(curntDate);
	}else if (i == "formelement") {
		formelement = FORM_DATA[i];
	}else if (i == "formname") {
		formname = FORM_DATA[i];
	}
}
sURL = "&formname=" + formname + "&formelement=" + formelement;
if (!curntDate) {
	curntDate = new Date();
}
//==========================================
firstDate = new Date(curntDate.getFullYear(),curntDate.getMonth(),1);
lastMonth = new Date(curntDate.getFullYear(),curntDate.getMonth()-1,1);
nextMonth = new Date(curntDate.getFullYear(),curntDate.getMonth()+1,1);
offSet   = firstDate.getDay() + 1;
lastSlot = offSet + ((nextMonth - firstDate)/(3600*24*1000)) - 1;
lastSlot = Math.round(lastSlot);
calWeeks = Math.ceil(lastSlot/7);
calDays  = calWeeks * 7;
day = 1;

function return_date(zzz){
	var mm = eval("opener.document." + formname + "." + formelement);
	document.cookie = "curntDate=" + (curntDate.getMonth()+1) + "/" + zzz + "/" + curntDate.getFullYear();
	mm.value = (curntDate.getMonth()+1) + "/" + zzz + "/" + curntDate.getFullYear();
	mm.focus();
	window.close();

}
function jump(d){
	location.href="calendar.html?curntdate=" + d.mm[d.mm.selectedIndex].value + "/1/" + d.yy[d.yy.selectedIndex].value + sURL;
}
fullMonth = ["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"];
today = new Date();



/***********************************************
* Random Content Order script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function randomizeContent(classname){
var contents=randomizeContent.collectElementbyClass(classname)
contents.text.sort(function() {return 0.5 - Math.random();})
var tbodyref=contents.ref[0].tagName=="TR"? contents.ref[0].parentNode : new Object()
for (var i=0; i<contents.ref.length; i++){
if (tbodyref.moveRow) //if IE
tbodyref.moveRow(0, Math.round(Math.random()*(tbodyref.rows.length-1)))
else
contents.ref[i].innerHTML=contents.text[i]
contents.ref[i].style.visibility="visible"
}
}

randomizeContent.collectElementbyClass=function(classname){ //return two arrays containing elements with specified classname, plus their innerHTML content
var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") //regular expression to screen for classname within element
var contentobj=new Object()
contentobj.ref=new Array() //array containing references to the participating contents
contentobj.text=new Array() //array containing participating contents' contents (innerHTML property)
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (var i=0; i<alltags.length; i++){
if (typeof alltags[i].className=="string" && alltags[i].className.search(classnameRE)!=-1){
contentobj.ref[contentobj.ref.length]=alltags[i]
contentobj.text[contentobj.text.length]=alltags[i].innerHTML
}
}
return contentobj
}


// <![CDATA[     

// A quick test of the setGlobalVars method 
datePickerController.setGlobalVars({"split":["-dd","-mm"]});

/* 

   The following function dynamically calculates Easter Monday's date.
   It is used as the "redraw" callback function for the second last calendar on the page
   and returns an empty object.
   
   It dynamically calculates Easter Monday for the year in question and uses
   the "adddisabledDates" method of the datePickercontroller Object to
   disable the date in question.
   
   NOTE: This function is not needed, it is only present to show you how you
   might use this callback function to disable dates dynamically!
   
*/
function disableEasterMonday(argObj) { 
        // Dynamically calculate Easter Monday - I've forgotten where this code 
        // was originally found and I don't even know if it returns a valid
        // result so don't use it in a prod env...
        var y = argObj.yyyy,
            a=y%4,
            b=y%7,
            c=y%19,
            d=(19*c+15)%30,
            e=(2*a+4*b-d+34)%7,
            m=Math.floor((d+e+114)/31),
            g=(d+e+114)%31+1,            
            yyyymmdd = y + "0" + m + String(g < 10 ? "0" + g : g);         
        
        datePickerController.addDisabledDates(argObj.id, yyyymmdd); 
        
        // The redraw callback expects an Object as a return value
        // so we just give it an empty Object... 
        return {};
};

/* 

   The following functions updates a span with an "English-ised" version of the
   currently selected date for the last datePicker on the page. 
   
   NOTE: These functions are not needed, they are only present to show you how you
   might use callback functions to use the selected date in other ways!
   
*/
function createSpanElement(argObj) {
        // Make sure the span doesn't exist already
        if(document.getElementById("EnglishDate")) return;

        // create the span node dynamically...
        var spn = document.createElement('span');
            p   = document.getElementById(argObj.id).parentNode;
            
        spn.id = "EnglishDate";
        p.parentNode.appendChild(spn);
        
        // Remove the bottom margin on the input's wrapper paragraph
        p.style.marginBottom = "0";
        
        // Add a whitespace character to the span
        spn.appendChild(document.createTextNode(String.fromCharCode(160)));
};

function showEnglishDate(argObj) {
        // Grab the span & get a more English-ised version of the selected date
        var spn = document.getElementById("EnglishDate"),
            formattedDate = datePickerController.printFormattedDate(argObj.date, "l-cc-sp-d-S-sp-F-sp-Y", false);
        
        // Make sure the span exists before attempting to use it!
        if(!spn) {
                createSpanElement(argObj); 
                spn = document.getElementById("EnglishDate");
        };
        
        // Note: The 3rd argument to printFormattedDate is a Boolean value that 
        // instructs the script to use the imported locale (true) or not (false)
        // when creating the dates. In this case, I'm not using the imported locale
        // as I've used the "S" format mask, which returns the English ordinal
        // suffix for a date e.g. "st", "nd", "rd" or "th" and using an
        // imported locale would look strange if an English suffix was included
        
        // Remove the current contents of the span
        while(spn.firstChild) spn.removeChild(spn.firstChild);
        
        // Add a new text node containing our formatted date
        spn.appendChild(document.createTextNode(formattedDate));
};

// ]]>


		$(document).ready(function() {
			$('#slideshow').slideshow({
				timeout: 6000,
				type: 'sequence',
				pauselink: 'pause1',
				pausecallback: function(self){
					self.html('Play')
				},
				playcallback: function(self){
					self.html('Pause');
				}
			});
			$('#slideshow2').slideshow({
				timeout: 6000,
				type: 'sequence',
				pauselink: 'pause2'
			});
					$('#slideshow3').slideshow({
				timeout: 2000,
				type: 'sequence',
				pauselink: 'pause2'
			});
	        });
	


Spry.Utils.addLoadListener(function() {

MenuBar9 = new Spry.Widget.MenuBar("MenuBar9", {imgDown:"spry/SpryMenuBarDownHover.gif", imgRight:"spry/SpryMenuBarRightHover.gif"});
MenuBar8 = new Spry.Widget.MenuBar("MenuBar8", {imgDown:"spry/SpryMenuBarDownHover.gif", imgRight:"spry/SpryMenuBarRightHover.gif"});
MenuBar7 = new Spry.Widget.MenuBar("MenuBar7", {imgDown:"spry/SpryMenuBarDownHover.gif", imgRight:"spry/SpryMenuBarRightHover.gif"});
MenuBar6 = new Spry.Widget.MenuBar("MenuBar6", {imgDown:"spry/SpryMenuBarDownHover.gif", imgRight:"spry/SpryMenuBarRightHover.gif"});
MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"spry/SpryMenuBarDownHover.gif", imgRight:"spry/SpryMenuBarRightHover.gif"});

});
