
// JScript File

/****************Begin*********************** Index *******************Begin*********************/
// 0:
// 1:
// 2:
// 3:
// 4:
// 5:
// 6:
// 7:
// 8:
// 9:
/****************End************************* Index *******************End***********************/

/****************Begin********************* Global Variables *******************Begin*******************/

// arrays of slider objects
var sliderObjectsAsia = new Array();
var sliderObjectsAmer = new Array();
var sliderObjectsEuro = new Array();
var sliderObjectsBest = new Array();

var sliderObjectsYear = new Array();
var sliderObjectsSpa = new Array();
var sliderObjectsRestaurant = new Array();

var sliderObjectsHotels = new Array();
var sliderObjectsSpaQuotes = new Array();
var sliderObjectsRBQuotes = new Array();

//var sliderObjectsTTD = new Array();
//var sliderObjectsTTS = new Array();
//var sliderObjectsWTS = new Array();
//var sliderObjectsWTD = new Array();

//var sliderObjectsRooms = new Array();
/****************End*********************** Global Variables *******************End*********************/

/****************Begin*********************** Generic Interactivity Functions *******************Begin*********************/

function revealInteractive() {
    var toolboxWrapper = document.getElementById("toolboxWrapper");
    var roomsWrapper = document.getElementById("roomsAndSuitesWrapper");
    var spaTreatments = document.getElementById("spaTreatments");
    var meetingSpaces = document.getElementById("meetingSpaces");
    var meetingServices = document.getElementById("meetingServices");
    var ttdsWrapper = document.getElementById("ttdsWrapper");
    var mapWrapper = document.getElementById("interactiveMap");
    var galleryWrapper = document.getElementById("revolverContainer2");
    var loaderdiv = document.getElementById("loaderDiv");
    if (toolboxWrapper != null){
        toolboxWrapper.style.visibility = "visible";
        toolboxWrapper.style.display = "block";
    }
    else if (roomsWrapper != null){
        roomsWrapper.style.display = "block";
    }
    else if (spaTreatments != null){
        spaTreatments.style.display = "block";
    }
    else if (meetingSpaces != null){
        meetingSpaces.style.display = "block";
    }
    else if (meetingServices != null){
        meetingServices.style.display = "block";
    }
    else if (ttdsWrapper != null){
        ttdsWrapper.style.display = "block"; 
    }
    else if (mapWrapper != null){
        mapWrapper.style.visibility = "visible";
    }
    else if (galleryWrapper != null){
        galleryWrapper.style.display = "block";
    }
    if (loaderdiv != null){
        loaderdiv.style.display= "none";        
    }
}

function setIds(arrayObj, baseId, numIds) {
    for (i = 0; i < numIds; i++) {
        arrayObj[i] = baseId + (i+1);
    }
    return(arrayObj);
}

function setSliderObjects(arrayObj, arrayIds, numIds, mode) {
    for (i = 0; i < numIds; i++) {
        var sliderObj = new Fx.Slide(arrayIds[i], {mode: mode});
        arrayObj[i] = sliderObj;
    }
    return(arrayObj);
}

function hideAllSliders(arrayObj, numIds) {
    for (i = 0; i < numIds; i++) {
        var sliderObj = arrayObj[i];
        sliderObj.hide();
    }
}

function slideInAllSliders(arrayObj, numIds) {
    for (i = 0; i < numIds; i++) {
        var sliderObj = arrayObj[i];
        sliderObj.slideIn();
    }
}

function slideOutAllSliders(arrayObj, numIds) {
    for (i = 0; i < numIds; i++) {
        var sliderObj = arrayObj[i];
        sliderObj.slideOut();
    }
}

function showAllSliders(arrayObj, numIds) {
    for (i = 0; i < numIds; i++) {
        var sliderObj = arrayObj[i];
        sliderObj.show();
    }
}

// add functions to do the above allowing for start and indexes as well
function slideInRangeSliders(arrayObj, startIndex, endIndex) {
    for (i = startIndex; i <= endIndex; i++) {
        var sliderObj = arrayObj[i];
        sliderObj.slideIn();
    }
}

function slideOutRangeSliders(arrayObj, startIndex, endIndex) {
    for (i = startIndex; i <= endIndex; i++) {
        var sliderObj = arrayObj[i];
        sliderObj.slideOut();
    }
}

// add functions to do the above except for one
function hideAllSlidersButOne(arrayObj, numIds, index) {
    for (i = 0; i < numIds; i++) {
        if (i != index){
            arrayObj[i].hide();
        }
    }
}

function slideOutAllSlidersButOne(arrayObj, numIds, index) {
    for (i = 0; i < numIds; i++) {
        if (i != index)
            arrayObj[i].slideOut();
    }
}

// this is the function to call on the toggle within the html file
// need to make customizable
function slideInSlider(arrayObj, numIds, index, hotelName) {
    hideAllSliders(arrayObj, numIds);
    arrayObj[index].slideIn();
    setText(hotelName);
}

function createCollection(sliderObjects, sliderIdBase, numIds, mode) {
    var sliderIds = new Array();
    sliderIds = setIds(sliderIds, sliderIdBase, numIds);
    sliderObjects = setSliderObjects(sliderObjects, sliderIds, numIds, mode);
    return(sliderObjects);
}

/****************End************************* Generic Interactivity Functions *******************End***********************/

/****************Begin*********************** Global Home - Emotional Navigation *******************Begin*********************/
var tabArray = new Array();
tabArray[0] = "fans_tab";
tabArray[1] = "hotels_tab";
tabArray[2] = "spa_tab";
tabArray[3] = "leisure_tab";
tabArray[4] = "occasions_tab";
tabArray[5] = "weddings_tab";
tabArray[6] = "meetings_tab";
tabArray[7] = "residences_tab";
function hover(thisObj) {
	if (thisObj.className != "tab_selected") {
		thisObj.className = "tab_hover";
	}
}
function dehover(thisObj) {
	if (thisObj.className != "tab_selected") {
		thisObj.className = "tab";
	}
}
function sethover(thisObj) {
	thisObj.className = "tab_selected";
	// change back all others
	var tab = null;
	for (i = 0; i < 8; i++) {
		if (tabArray[i] == thisObj.id) {}
		else {
			tab = document.getElementById(tabArray[i]);
			tab.className = "tab";
		}
	}
}
var setNum = 1;
function globalBanner() {
    var transition1 = new Fx.Tween('fans1', {property: 'opacity', duration: 500});
    var transition2 = new Fx.Tween('fans2', {property: 'opacity', duration: 500});
    var transition3 = new Fx.Tween('fans3', {property: 'opacity', duration: 500});
    var transition4 = new Fx.Tween('fans4', {property: 'opacity', duration: 500});
    var transition5 = new Fx.Tween('fans5', {property: 'opacity', duration: 500});
    var transition6 = new Fx.Tween('fans6', {property: 'opacity', duration: 500});
    var transition7 = new Fx.Tween('fans7', {property: 'opacity', duration: 500});
    var transition8 = new Fx.Tween('fans8', {property: 'opacity', duration: 500});
    /*event = new Event(event).stop(); */
    function transitionOut() {
        switch (setNum) {
        case 1:
            transition1.start(1, 0);
            break
        case 2:
            transition2.start(1, 0);
            break
        case 3:
            transition3.start(1, 0);
            break
        case 4:
            transition4.start(1, 0);
            break
        case 5:
            transition5.start(1, 0);
            break
        case 6:
            transition6.start(1, 0);
            break
        case 7:
            transition7.start(1, 0);
            break
        case 8:
            transition8.start(1, 0);
            break
        default:
            
        }
    }

    $('fans_tab').addEvent('mouseover', function(event) {setNum = 1;transition1.start(0, 1); });
	$('hotels_tab').addEvent('mouseover', function(event) {setNum = 2;transition2.start(0, 1);  });
	$('spa_tab').addEvent('mouseover', function(event) {setNum = 3;transition3.start(0, 1); });
	$('leisure_tab').addEvent('mouseover', function(event) {setNum = 4;transition4.start(0, 1); });
	$('occasions_tab').addEvent('mouseover', function(event) {setNum = 5;transition5.start(0, 1);  });
	$('weddings_tab').addEvent('mouseover', function(event) {setNum = 6;transition6.start(0, 1);  });
	$('meetings_tab').addEvent('mouseover', function(event) {setNum = 7;transition7.start(0, 1);  });
	$('residences_tab').addEvent('mouseover', function(event) {setNum = 8;transition8.start(0, 1);  });
    
    $('fans_tab').addEvent('mouseout', function(event) {transitionOut(); });
	$('hotels_tab').addEvent('mouseout', function(event) {transitionOut();  });
	$('spa_tab').addEvent('mouseout', function(event) {transitionOut(); });
	$('leisure_tab').addEvent('mouseout', function(event) {transitionOut(); });
	$('occasions_tab').addEvent('mouseout', function(event) {transitionOut(); });
	$('weddings_tab').addEvent('mouseout', function(event) {transitionOut();  });
	$('meetings_tab').addEvent('mouseout', function(event) {transitionOut();  });
	$('residences_tab').addEvent('mouseout', function(event) {transitionOut();});
}
function changeImage(fileName) {
	var fansObj = document.getElementById("fans");
	fansObj.src = fileName;
}

function showImage(id) {
    var image = document.getElementById(id);
    image.className = "image";
}
function hideAll(id1, id2, id3, id4, id5, id6, id7) {
    var image1 = document.getElementById(id1);
    var image2 = document.getElementById(id2);
    var image3 = document.getElementById(id3);
    var image4 = document.getElementById(id4);
    var image5 = document.getElementById(id5);
    var image6 = document.getElementById(id6);
    var image7 = document.getElementById(id7);
    image1.className = "image2";
    image2.className = "image2";
    image3.className = "image2";
    image4.className = "image2";
    image5.className = "image2";
    image6.className = "image2";
    image7.className = "image2";
}	
/****************End************************* Global Home - Emotional Navigation *******************End***********************/

/*******************Begin******************** Corporate Photo Gallery ********************Begin*******************/
var globalName = 'Welcome to our photo gallery - click on your desired Mandarin Oriental hotel above.';
        
function hotelGallery() {
    sliderObjectsAsia = createCollection(sliderObjectsAsia, "asiaHSlider", 11, 'vertical');
    sliderObjectsAmer = createCollection(sliderObjectsAmer, "amerHSlider", 5, 'vertical');
    sliderObjectsEuro = createCollection(sliderObjectsEuro, "euroHSlider", 4, 'vertical');
    sliderObjectsBest = createCollection(sliderObjectsBest, "bestHSlider", 7, 'vertical');
    
    hideAllSliders(sliderObjectsAsia, 11);
    hideAllSliders(sliderObjectsAmer, 5);
    hideAllSliders(sliderObjectsEuro, 4);
    hideAllSliders(sliderObjectsBest, 7);
    
    $('asiaHToggle1').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[0].slideIn(); e.stop(); setText('Bangkok');});
    $('asiaHToggle2').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[1].slideIn(); e.stop(); setText('Chiang Mai');});
    $('asiaHToggle3').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[2].slideIn(); e.stop(); setText('Hong Kong - Mandarin Oriental');});
    $('asiaHToggle4').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[3].slideIn(); e.stop(); setText('Hong Kong - The Landmark');});
    $('asiaHToggle5').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[4].slideIn(); e.stop(); setText('Hong Kong - The Excelsior');});
    $('asiaHToggle6').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[5].slideIn(); e.stop(); setText('Jakarta');});
    $('asiaHToggle7').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[6].slideIn(); e.stop(); setText('Kuala Lumpur');});
    $('asiaHToggle8').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[7].slideIn(); e.stop(); setText('Macau');});
    $('asiaHToggle9').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[8].slideIn(); e.stop(); setText('Manila');});
    $('asiaHToggle10').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[9].slideIn(); e.stop(); setText('Singapore');});
    $('asiaHToggle11').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAsia, 11); sliderObjectsAsia[10].slideIn(); e.stop(); setText('Tokyo');});

    $('amerHToggle1').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAmer, 5); sliderObjectsAmer[0].slideIn(); e.stop(); setText('Bermuda');});
    $('amerHToggle2').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAmer, 5); sliderObjectsAmer[1].slideIn(); e.stop(); setText('Miami');});
    $('amerHToggle3').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAmer, 5); sliderObjectsAmer[2].slideIn(); e.stop(); setText('New York');});
    $('amerHToggle4').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAmer, 5); sliderObjectsAmer[3].slideIn(); e.stop(); setText('San Francisco');});
    $('amerHToggle5').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsAmer, 5); sliderObjectsAmer[4].slideIn(); e.stop(); setText('Washington DC');});

    $('euroHToggle1').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsEuro, 4); sliderObjectsEuro[0].slideIn(); e.stop(); setText('Geneva');});
    $('euroHToggle2').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsEuro, 4); sliderObjectsEuro[1].slideIn(); e.stop(); setText('London');});
    $('euroHToggle3').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsEuro, 4); sliderObjectsEuro[2].slideIn(); e.stop(); setText('Munich');});
    $('euroHToggle4').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsEuro, 4); sliderObjectsEuro[3].slideIn(); e.stop(); setText('Prague');});

    $('bestHToggle1').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsBest, 7); sliderObjectsBest[0].slideIn(); e.stop(); setText('Restaurants');});
    $('bestHToggle2').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsBest, 7); sliderObjectsBest[1].slideIn(); e.stop(); setText('Spas');});
    $('bestHToggle3').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsBest, 7); sliderObjectsBest[2].slideIn(); e.stop(); setText('Spa Products');});
    $('bestHToggle4').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsBest, 7); sliderObjectsBest[3].slideIn(); e.stop(); setText('Leisure');});
    $('bestHToggle5').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsBest, 7); sliderObjectsBest[4].slideIn(); e.stop(); setText('Meetings');});
    $('bestHToggle6').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsBest, 7); sliderObjectsBest[5].slideIn(); e.stop(); setText('Service');});
    $('bestHToggle7').addEvent('click', function(e){e = new Event(e); hideAllSliders(sliderObjectsBest, 7); sliderObjectsBest[6].slideIn(); e.stop(); setText('Developments');});

    function hideAll() {
        hideAllSliders(sliderObjectsAsia, 11);
        hideAllSliders(sliderObjectsAmer, 5);
        hideAllSliders(sliderObjectsEuro, 4);
        hideAllSliders(sliderObjectsBest, 7);
/*
        asiaHSlide1.hide(); asiaHSlide2.hide(); asiaHSlide3.hide(); asiaHSlide4.hide(); asiaHSlide5.hide(); asiaHSlide6.hide(); asiaHSlide7.hide(); asiaHSlide8.hide(); asiaHSlide9.hide(); asiaHSlide10.hide(); asiaHSlide11.hide();
        amerHSlide1.hide(); amerHSlide2.hide(); amerHSlide3.hide(); amerHSlide4.hide(); amerHSlide5.hide();
        euroHSlide1.hide(); euroHSlide2.hide(); euroHSlide3.hide(); euroHSlide4.hide();
        bestHSlide1.hide(); bestHSlide2.hide(); bestHSlide3.hide(); bestHSlide4.hide(); bestHSlide5.hide(); bestHSlide6.hide(); bestHSlide7.hide();
*/
    }

    var asiaHotelsSlide = new Fx.Slide('asiaHotels');
    var amerHotelsSlide = new Fx.Slide('amerHotels');
    var euroHotelsSlide = new Fx.Slide('euroHotels');
    var bestHotelsSlide = new Fx.Slide('bestHotels');

    asiaHotelsSlide.hide();
    amerHotelsSlide.hide();
    euroHotelsSlide.hide();
    //bestHotelsSlide.hide();

    $('asiaLink').addEvent('click', function(e){e = new Event(e); asiaHotelsSlide.slideIn(); amerHotelsSlide.hide(); euroHotelsSlide.hide(); bestHotelsSlide.hide(); hideAll(); e.stop();});
    $('amerLink').addEvent('click', function(e){e = new Event(e); amerHotelsSlide.slideIn(); asiaHotelsSlide.hide(); euroHotelsSlide.hide(); bestHotelsSlide.hide(); hideAll(); e.stop();});
    $('euroLink').addEvent('click', function(e){e = new Event(e); euroHotelsSlide.slideIn(); asiaHotelsSlide.hide(); amerHotelsSlide.hide(); bestHotelsSlide.hide(); hideAll(); e.stop();});
    $('bestLink').addEvent('click', function(e){e = new Event(e); bestHotelsSlide.slideIn(); asiaHotelsSlide.hide(); amerHotelsSlide.hide(); euroHotelsSlide.hide(); hideAll(); e.stop();});
	
	function hotelRedirect(id){
		//alert('domain: ' + document.domain);
		var selectionPath = document.getElementById(id).value;
		alert("something: " + selectionPath);
		alert("redirect path will equal: " + document.domain + "/" + selectionPath + ".html");
		if (selectionPath != "_" && selectionPath != undefined){
			if (window.location = "/" + selectionPath + ".html" == undefined){
				window.location = "/" + selectionPath + ".htm";
			}else{
				window.location = "/" + selectionPath + ".html";
			}
		}
	}
	$('quickSearchService').addEvent('change', function(e){e = new Event(e); alert('testing 123!'); hotelRedirect(this.id); bestHotelsSlide.slideIn(); asiaHotelsSlide.hide(); amerHotelsSlide.hide(); euroHotelsSlide.hide(); hideAll();  e.stop();});
	$('quickSearchHotel').addEvent('change', function(e){e = new Event(e); alert('testing ABC!'); bestHotelsSlide.slideIn(); asiaHotelsSlide.hide(); amerHotelsSlide.hide(); euroHotelsSlide.hide(); hideAll(); e.stop();});
	//quickSearchService
	//quickSearchHotel
}
/* new function */
function setMarginTop(id, marginPx) {
    document.getElementById(id).style.marginTop = marginPx+'px';
}

function changeHotel(hotelName) {
    var nameWrapperObj = document.getElementById("nameWrapper");
    nameWrapperObj.innerHTML = "<h3>" + hotelName + "</h3>";
}
function setText(strName) {
    //var saveObj = document.getElementById('nameSave');
    //saveObj.innerHTML = strName;
    globalName = strName;
}
function setOut() {
    var nameWrapperObj = document.getElementById("nameWrapper");
    //var saveObj = document.getElementById('nameSave');
    //nameWrapperObj.innerHTML = "<h3>" + saveObj.innerHTML + "</h3>";
    nameWrapperObj.innerHTML = "<h3>" + globalName + "</h3>";
}
function changeTab(num) {
    var obj1 = document.getElementById('tb1');
    var obj2 = document.getElementById('tb2');
    var obj3 = document.getElementById('tb3');
    var obj4 = document.getElementById('tb4');
    var link1 = document.getElementById('asiaLink');
    var link2 = document.getElementById('amerLink');
    var link3 = document.getElementById('euroLink');
    var link4 = document.getElementById('bestLink');
    switch (num) {
    case 1:
        obj1.className = "tabSelected";
        obj2.className = "tab tabBorder";
        obj3.className = "tab tabBorder";
        obj4.className = "tab";
        link1.className = "tabSelected";
        link2.className = "tab";
        link3.className = "tab";
        link4.className = "tab";
        break
    case 2:
        obj1.className = "tab";
        obj2.className = "tabSelected tabBorder";
        obj3.className = "tab tabBorder";
        obj4.className = "tab";
        link1.className = "tab";
        link2.className = "tabSelected";
        link3.className = "tab";
        link4.className = "tab";
        break
    case 3:
        obj1.className = "tab";
        obj2.className = "tab tabBorder";
        obj3.className = "tabSelected tabBorder";
        obj4.className = "tab";
        link1.className = "tab";
        link2.className = "tab";
        link3.className = "tabSelected";
        link4.className = "tab";
        break
    case 4:
        obj1.className = "tab";
        obj2.className = "tab tabBorder";
        obj3.className = "tab tabBorder";
        obj4.className = "tabSelected";
        link1.className = "tab";
        link2.className = "tab";
        link3.className = "tab";
        link4.className = "tabSelected";
        break
    default:
    }
}
/********************End********************* Corporate Photo Gallery *********************End********************/

/*******************Begin******************** Awards ********************Begin*******************/
var tabClass = "";
function highlight(thisObj) {
    tabClass = "tab selected";
    thisObj.className = "tab selected";
}
function dehighlight(firstObj, secondObj) {
    var objOne = document.getElementById(firstObj);
    var objTwo = document.getElementById(secondObj);
    objOne.className = "tab";
    objTwo.className = "tab";
}
function hover(thisObj) {
    tabClass = thisObj.className;
    thisObj.className = "tab hover";
}
function dehover(thisObj) {
    if (tabClass == "tab selected") {
        thisObj.className = tabClass;
    } else {
        thisObj.className = "tab";
    }
}
function hl(thisObj) {
    thisObj.className = "yearTab selectedYear";
}
function dhl(a, b, c) {
    var aObj = document.getElementById(a);
    var bObj = document.getElementById(b);
    var cObj = document.getElementById(c);
    aObj.className = "yearTab";
    bObj.className = "yearTab";
    cObj.className = "yearTab";
}
function dhl5(a, b, c, d, e) {
    var aObj = document.getElementById(a);
    var bObj = document.getElementById(b);
    var cObj = document.getElementById(c);
    var dObj = document.getElementById(d);
    var eObj = document.getElementById(e);
    aObj.className = "yearTab";
    bObj.className = "yearTab";
    cObj.className = "yearTab";
    dObj.className = "yearTab";
    eObj.className = "yearTab";
}
function changeTab(num) {
	var obj1 = document.getElementById('tb1');
	var obj2 = document.getElementById('tb2');
	//var obj3 = document.getElementById('tb3');
	var obj4 = document.getElementById('tb4');
	var link1 = document.getElementById('yearToggle');
	var link2 = document.getElementById('spaToggle');
	//var link3 = document.getElementById('euroLink');
	var link4 = document.getElementById('restaurantToggle');
	switch (num) {
	case 1:
		obj1.className = "tabSelected";
		obj2.className = "tab tabBorder";
		//obj3.className = "tab tabBorder";
		obj4.className = "tab";
		link1.className = "tabSelected";
		link2.className = "tab";
		//link3.className = "tab";
		link4.className = "tab";
		break
	case 2:
		obj1.className = "tab";
		obj2.className = "tabSelected tabBorder";
		//obj3.className = "tab tabBorder";
		obj4.className = "tab";
		link1.className = "tab";
		link2.className = "tabSelected";
		//link3.className = "tab";
		link4.className = "tab";
		break
	case 3:
		obj1.className = "tab";
		obj2.className = "tab tabBorder";
		//obj3.className = "tabSelected tabBorder";
		obj4.className = "tab";
		link1.className = "tab";
		link2.className = "tab";
		//link3.className = "tabSelected";
		link4.className = "tab";
		break
	case 4:
		obj1.className = "tab";
		obj2.className = "tab tabBorder";
		//obj3.className = "tab tabBorder";
		obj4.className = "tabSelected";
		link1.className = "tab";
		link2.className = "tab";
		//link3.className = "tab";
		link4.className = "tabSelected";
		break
	default:
	}
}
function awardsGallery() {

    var scroll = new Fx.Scroll('year_2007', {wait: false, duration: 1500, offset: {'x': -200, 'y': -50}, transition: Fx.Transitions.Quad.easeInOut});
    $('more').addEvent('click', function(event) {event = new Event(event).stop(); scroll.toElement('last'); var transition = new Fx.Tween('firstBox', {property: 'opacity', duration:1500}); transition.start(1, 0); var transition2 = new Fx.Tween('secondBox', {property: 'opacity', duration:1500}); transition2.start(0, 1);});
    $('prev').addEvent('click', function(event) {event = new Event(event).stop(); scroll.toElement('first');var transition = new Fx.Tween('firstBox', {property: 'opacity', duration:1500}); transition.start(0, 1); var transition2 = new Fx.Tween('secondBox', {property: 'opacity', duration:1500}); transition2.start(1, 0);});

    var yearSlide = new Fx.Slide('subYear', {mode: 'horizontal'});
    //yearSlide.hide();
    
    //sliderObjectsYear = createCollection(sliderObjectsYear, "yearSlider", 4, 'vertical');
    //sliderObjectsSpa = createCollection(sliderObjectsSpa, "spaSlider", 6, 'vertical');
    //sliderObjectsRestaurant = createCollection(sliderObjectsRestaurant, "restaurantSlider", 6, 'vertical');
    //hideAllSliders(sliderObjectsYear, 4);
    //hideAllSliders(sliderObjectsSpa, 6);
    //hideAllSliders(sliderObjectsRestaurant, 6);

    var mySlide_2007 = new Fx.Slide('year_2007');
    var mySlide_2006 = new Fx.Slide('year_2006');
    var mySlide_2005 = new Fx.Slide('year_2005');
    var mySlide_2004 = new Fx.Slide('year_2004');

    var mySlide_sBK = new Fx.Slide('spaBangkok');
    var mySlide_sHK = new Fx.Slide('spaHongKong');
    var mySlide_sLD = new Fx.Slide('spaLondon');
    var mySlide_sMI = new Fx.Slide('spaMiami');
    var mySlide_sNY = new Fx.Slide('spaNewYork');
    var mySlide_sPR = new Fx.Slide('spaPrague');

    var mySlide_pBK = new Fx.Slide('restaurantBangkok');
    var mySlide_pHK = new Fx.Slide('restaurantHongKong');
    var mySlide_pLD = new Fx.Slide('restaurantLondon');
    var mySlide_pMI = new Fx.Slide('restaurantMiami');
    var mySlide_pNY = new Fx.Slide('restaurantNewYork');
    var mySlide_pPR = new Fx.Slide('restaurantPrague');

    //mySlide_2007.hide();
    mySlide_2006.hide();
    mySlide_2005.hide();
    mySlide_2004.hide();

    mySlide_sBK.hide();
    mySlide_sHK.hide();
    mySlide_sLD.hide();
    mySlide_sMI.hide();
    mySlide_sNY.hide();
    mySlide_sPR.hide();

    mySlide_pBK.hide();
    mySlide_pHK.hide();
    mySlide_pLD.hide();
    mySlide_pMI.hide();
    mySlide_pNY.hide();
    mySlide_pPR.hide();

    $('toggle_2007').addEvent('click', function(e){e = new Event(e); mySlide_2007.slideIn(); mySlide_2006.hide(); mySlide_2005.hide(); mySlide_2004.hide();e.stop();});
    $('toggle_2006').addEvent('click', function(e){e = new Event(e); mySlide_2006.slideIn(); mySlide_2007.hide(); mySlide_2005.hide(); mySlide_2004.hide();e.stop();});
    $('toggle_2005').addEvent('click', function(e){e = new Event(e); mySlide_2005.slideIn(); mySlide_2007.hide(); mySlide_2006.hide(); mySlide_2004.hide();e.stop();});
    $('toggle_2004').addEvent('click', function(e){e = new Event(e); mySlide_2004.slideIn(); mySlide_2007.hide(); mySlide_2006.hide(); mySlide_2005.hide();e.stop();});

    $('toggle_sBK').addEvent('click', function(e){e = new Event(e); mySlide_sBK.toggle(); mySlide_sHK.hide(); mySlide_sLD.hide(); mySlide_sPR.hide(); mySlide_sNY.hide(); mySlide_sMI.hide(); e.stop();});
    $('toggle_sHK').addEvent('click', function(e){e = new Event(e); mySlide_sHK.toggle(); mySlide_sBK.hide(); mySlide_sLD.hide(); mySlide_sPR.hide(); mySlide_sNY.hide(); mySlide_sMI.hide(); e.stop();});
    $('toggle_sLD').addEvent('click', function(e){e = new Event(e); mySlide_sLD.toggle(); mySlide_sPR.hide(); mySlide_sBK.hide(); mySlide_sHK.hide(); mySlide_sNY.hide(); mySlide_sMI.hide(); e.stop();});
    $('toggle_sPR').addEvent('click', function(e){e = new Event(e); mySlide_sPR.toggle(); mySlide_sLD.hide(); mySlide_sBK.hide(); mySlide_sHK.hide(); mySlide_sNY.hide(); mySlide_sMI.hide(); e.stop();});
    $('toggle_sMI').addEvent('click', function(e){e = new Event(e); mySlide_sMI.toggle(); mySlide_sNY.hide(); mySlide_sBK.hide(); mySlide_sHK.hide(); mySlide_sLD.hide(); mySlide_sPR.hide(); e.stop();});
    $('toggle_sNY').addEvent('click', function(e){e = new Event(e); mySlide_sNY.toggle(); mySlide_sMI.hide(); mySlide_sBK.hide(); mySlide_sHK.hide(); mySlide_sLD.hide(); mySlide_sPR.hide(); e.stop();});

    $('toggle_pBK').addEvent('click', function(e){e = new Event(e); mySlide_pBK.toggle(); mySlide_pHK.hide(); mySlide_pLD.hide(); mySlide_pPR.hide(); mySlide_pNY.hide(); mySlide_pMI.hide(); e.stop();});
    $('toggle_pHK').addEvent('click', function(e){e = new Event(e); mySlide_pHK.toggle(); mySlide_pBK.hide(); mySlide_pLD.hide(); mySlide_pPR.hide(); mySlide_pNY.hide(); mySlide_pMI.hide(); e.stop();});
    $('toggle_pLD').addEvent('click', function(e){e = new Event(e); mySlide_pLD.toggle(); mySlide_pPR.hide(); mySlide_pBK.hide(); mySlide_pHK.hide(); mySlide_pNY.hide(); mySlide_pMI.hide(); e.stop();});
    $('toggle_pPR').addEvent('click', function(e){e = new Event(e); mySlide_pPR.toggle(); mySlide_pLD.hide(); mySlide_pBK.hide(); mySlide_pHK.hide(); mySlide_pNY.hide(); mySlide_pMI.hide(); e.stop();});
    $('toggle_pMI').addEvent('click', function(e){e = new Event(e); mySlide_pMI.toggle(); mySlide_pNY.hide(); mySlide_pBK.hide(); mySlide_pHK.hide(); mySlide_pLD.hide(); mySlide_pPR.hide(); e.stop();});
    $('toggle_pNY').addEvent('click', function(e){e = new Event(e); mySlide_pNY.toggle(); mySlide_pMI.hide(); mySlide_pBK.hide(); mySlide_pHK.hide(); mySlide_pLD.hide(); mySlide_pPR.hide(); e.stop();});

    var mySlide8 = new Fx.Slide('sliderWrapper', {mode: 'horizontal'});
    mySlide8.hide();

    var restAwar = new Fx.Slide('restAwar', {mode: 'horizontal'});
    restAwar.hide();

    $('yearToggle').addEvent('click', function(e){
        var thisObj = document.getElementById('toggle_2007');
        hl(thisObj);
        dhl('toggle_2006', 'toggle_2005', 'toggle_2004');
        e = new Event(e); restAwar.hide(); mySlide8.hide(); yearSlide.slideIn(); mySlide_sBK.hide(); mySlide_sHK.hide(); mySlide_sLD.hide(); mySlide_sPR.hide(); mySlide_sNY.hide(); mySlide_sMI.hide(); mySlide_pBK.hide(); mySlide_pHK.hide(); mySlide_pLD.hide(); mySlide_pPR.hide(); mySlide_pNY.hide(); mySlide_pMI.hide(); mySlide_2007.slideIn(); mySlide_2006.hide(); mySlide_2005.hide(); mySlide_2004.hide(); e.stop();
    });
    $('spaToggle').addEvent('click', function(e){
        var thisObj = document.getElementById('toggle_sBK');
        hl(thisObj);
        dhl5('toggle_sHK', 'toggle_sNY', 'toggle_sMI', 'toggle_sLD', 'toggle_sPR');
        e = new Event(e); restAwar.hide(); mySlide8.slideIn(); yearSlide.hide(); mySlide_sBK.slideIn(); mySlide_sHK.hide(); mySlide_sLD.hide(); mySlide_sPR.hide(); mySlide_sNY.hide(); mySlide_sMI.hide(); mySlide_pBK.hide(); mySlide_pHK.hide(); mySlide_pLD.hide(); mySlide_pPR.hide(); mySlide_pNY.hide(); mySlide_pMI.hide(); mySlide_2007.hide(); mySlide_2006.hide(); mySlide_2005.hide(); mySlide_2004.hide(); e.stop();
    });
    $('restaurantToggle').addEvent('click', function(e){
        var thisObj = document.getElementById('toggle_pBK');
        hl(thisObj);
        dhl5('toggle_pHK', 'toggle_pNY', 'toggle_pMI', 'toggle_pLD', 'toggle_pPR');
        e = new Event(e); restAwar.slideIn(); mySlide8.hide(); yearSlide.hide(); mySlide_sBK.hide(); mySlide_sHK.hide(); mySlide_sLD.hide(); mySlide_sPR.hide(); mySlide_sNY.hide(); mySlide_sMI.hide(); mySlide_pBK.slideIn(); mySlide_pHK.hide(); mySlide_pLD.hide(); mySlide_pPR.hide(); mySlide_pNY.hide(); mySlide_pMI.hide(); mySlide_2007.hide(); mySlide_2006.hide(); mySlide_2005.hide(); mySlide_2004.hide(); e.stop();
    });

    /* Tips 2 */
    var Tips2 = new Tips($$('.Tips2'), {
        maxTitleChars: 100,
        initialize:function(){
        this.fx = new Fx.Tween(this.toolTip, {property: 'opacity', duration: 500, wait: false}).set(0);
        },
        onShow: function(toolTip) {
            this.fx.start(1);
        },
        onHide: function(toolTip) {
            this.fx.start(0);
        }
    });
}

var award_2007_captions = new Array();
var award_covers_2007 = new Array();

/*
    var obj2007 = document.getElementById("year_2007").getElementsByTagName("img");
    for (i = 0; i <= 23; i++) {
        award_2007_captions[i] = obj2007[i].title;
    }
*/
award_2007_captions[0]="Modern Bride<br />World’s Best Honeymoons – August-September<br />2007 :: Mandarin Oriental, San Francisco<br />Resorts With the Best Bathrooms<br /><br />Mandarin Oriental Hotel Group<br />Best Hotel Brands";
award_2007_captions[1]="Institutional Investor<br />The World’s Best Hotels 2007 :: Mandarin Oriental, Washington DC<br />No.1 - Best in North America overall<br /><br />The Oriental, Bangkok<br />No.2 – Best hotel in Asia overall<br />Top 10 Hotel Bars<br /><br />Mandarin Oriental, Hong Kong<br />Top 10 Hotel Bars";
award_2007_captions[2]="Travel + Leisure US<br />World’s Best Awards 2007 – August 2007 :: The Oriental, Bangkok<br />No.3 – Top 100 Hotels Overall<br />No.2 – Top 50 Hotels in Asia<br /><br />Mandarin Oriental, Munich<br />No.8 – Top 100 Hotels Overall<br />No.4 – Top 50 Hotels in Europe<br />No. 7 - Top 15 Small Hotels<br /><br />Mandarin Oriental, Kuala Lumpur<br />No.37 – Top 50 Hotels in Asia<br /><br />Mandarin Oriental, Hong Kong<br />No.41 – Top 50 Hotels in Asia<br /><br />Mandarin Oriental Dhara Dhevi, Chiang Mai<br />No.45 – Top 50 Hotels in Asia<br /><br />Mandarin Oriental, Miami<br />No.60 – Top 100 Hotels in Continental U.S. and Canada<br /><br />Mandarin Oriental, New York<br />No.81 – Top 100 Hotels in Continental U.S. and Canada<br /><br />Mandarin Oriental, San Francisco<br />No.94 – Top 100 Hotels in Continental U.S. and Canada<br /><br />Mandarin Oriental, Prague<br />15 to Watch";
award_2007_captions[3]="Travel + Leisure<br />Readers’ Poll World’s Best Service – Jun 2007 :: The Oriental, Bangkok<br />No.9 in Top Hotels for Service (Overall)<br />No.7 in Top Hotels for Service (Asia)";
award_2007_captions[4]="Travel + Leisure<br />The IT List: 25 Best New Hotels – Jun 2007 :: Mandarin Oriental, Prague<br />New Urbanists";
award_2007_captions[5]="Conde Nast Traveller - UK<br />Gold List 2007 – January 2007 :: Mandarin Oriental Dhara Dhevi, Chiang Mai<br />Best For Facilities<br /><br />Mandarin Oriental, New York<br />Best For Food<br /><br />Mandarin Oriental Hyde Park, London<br />Best For Location<br /><br />The Landmark Mandarin Oriental, Hong Kong<br />Best For Rooms";
award_2007_captions[6]="ForbesTraveler.com<br />400 The World’s Very Best Hotels & Resorts – January 2007 :: Mandarin Oriental, San Francisco<br />Mandarin Oriental, Miami<br />Mandarin Oriental, New York<br />Mandarin Oriental, Washington DC<br />Mandarin Oriental Hyde Park, London<br />Mandarin Oriental, Munich<br />The Landmark Mandarin Oriental, Hong Kong<br />Mandarin Oriental, Tokyo<br />Mandarin Oriental, Kuala Lumpur<br />The Oriental, Bangkok";
award_2007_captions[7]="Zagat<br />World’s Top Hotels, Resorts & Spas 2007/2008 :: Mandarin Oriental Hotel Group<br />Top Hotel Chains<br /><br />The Oriental, Bangkok<br />Top Hotels<br />Top Service<br /><br />Mandarin Oriental, Miami<br />Mandarin Oriental, Tokyo<br />Top Hotels<br />Top Rooms<br /><br />Mandarin Oriental, New York<br />The Landmark Mandarin Oriental, Hong Kong<br />Mandarin Oriental, Washington DC<br />Mandarin Oriental, Hong Kong<br />Mandarin Oriental, San Francisco<br />Mandarin Oriental, Kuala Lumpur<br />Top Hotels<br /><br />Mandarin Oriental Hyde Park, London<br />Top Destination Spas<br /><br />Mandarin Oriental, Prague<br />Key Newcomers";
award_2007_captions[8]="Conde Nast Traveler, USA –<br />Readers’ Poll Top 55 Spas – April 2007 :: Mandarin Oriental, Miami<br />No.19 in Resort Spas<br /><br />Mandarin Oriental, New York<br />No.1 in Urban Hotel Spas";
award_2007_captions[9]="Conde Nast Traveler - US<br />Hot List 2007– May 2007 :: Mandarin Oriental, Hong Kong<br />Hot List<br />Hot Spas<br />Hot Tables-Pierre<br /><br />Mandarin Oriental, Prague<br />Hot List<br />Hot Spas";
award_2007_captions[10]="Conde Nast Traveller - UK<br />Hot List 2007 – May 2007 :: Mandarin Oriental, Prague<br />Hot List";
award_2007_captions[11]="Mobil Travel Guide<br />Four-Star and Five-Star Awards- April 2007 :: Mandarin Oriental, New York<br />Mobil Five-Star Hotels<br />Mobil Five-Star Spas<br />Mobil Four-Star Restaurants-Asiate<br /><br />Mandarin Oriental, San Francisco<br />Mobil Four-Star Hotels<br />Mobil Three-Star Restaurant-Silks<br /><br />Mandarin Oriental, Washington DC<br />Mobil Four-Star Hotels<br />Mobil Four-Star Spas<br />Mobil Four-Star Restaurants-CityZen<br /><br />Mandarin Oriental, Miami<br />Mobil Four-Star Hotels<br />Mobil Four-Star Spas<br />Mobil Four-Star Restaurants-Azul";
award_2007_captions[12]="Conde Nast Traveller - UK<br />Readers’ Spa Awards-March 2007 :: Mandarin Oriental, New York<br />No.2 Hotel Spas-The Americas & Caribbean<br />No.7 Urban Day Spas-Overseas<br />No.6 The World’s Top 25<br /><br />Mandarin Oriental Hyde Park, London<br />No.2 Urban Day Spas-UK<br />No.24 The World’s Top 25<br /><br />Mandarin Oriental, Miami<br />No.1 Urban Day Spas-Overseas<br />No.3 The World’s Top 25<br /><br />The Oriental, Bangkok<br />No.8 Urban Day Spas-Overseas";
award_2007_captions[13]="Travel + Leisure<br />World’s Best Values-March 2007 :: Mandarin Oriental, Dhara Dhevi, Chiang Mai<br />No.14 in Top 20 Hotels For Value Overall<br /><br />Mandarin Oriental, Kuala Lumpur<br />No.2 in Under USD 250 a night-Asia<br /><br />The Oriental, Bangkok<br />No.5 in USD 250 to USD 400 a night-Asia";
award_2007_captions[14]="SpaAsia<br />150 World-Class Spas – March/April 2007 :: Mandarin Oriental, Hong Kong<br />Hong Kong<br /><br />Mandarin Oriental, Tokyo<br />Japan<br /><br />Mandarin Oriental Dhara Dhevi, Chiang Mai<br />Thailand<br /><br />Mandarin Oriental, New York<br />Mandarin Oriental, Miami<br />North America<br /><br />Mandarin Oriental Hyde Park, London<br />England";
award_2007_captions[15]="Asiamoney<br />2007 Asiamoney Polls – March 2007 :: Mandarin Oriental Hotel Group<br />No.5 in Asia’s Best Hotel Brands for Business<br /><br />The Oriental, Bangkok<br />No.5 in Asia’s Best Business Hotels<br />No.3 in Asia’s Best Spas<br />No.1 in Asia’s Best Hotels in Bangkok<br /><br />Mandarin Oriental, Hong Kong<br />No.5 in Asia’s Best Hotels in Hong Kong<br /><br />Mandarin Oriental, Kuala Lumpur<br />No.1 in Asia’s Best Hotels in Kuala Lumpur<br /><br />Mandarin Oriental, Manila<br />No.3 in Asia’s Best Hotels in Manila<br /><br />Mandarin Oriental, Tokyo<br />No.4 in Asia’s Best Hotels in Tokyo";
award_2007_captions[16]="Institutional Investor<br />Best Hotels By City - January 2007 :: The Oriental, Bangkok<br />Mandarin Oriental, Kuala Lumpur<br />Mandarin Oriental, Miami<br />Mandarin Oriental, Washington DC";
award_2007_captions[17]="Conde Nast Traveller - Italy<br />Hot List 2007 – February 2007 :: Mandarin Oriental, Prague<br />Hot List";
award_2007_captions[18]="DestinAsian<br />2007 Readers’ Choice Awards – Feb-Mar 2007 :: The Oriental, Bangkok<br />Best Hotels And Resorts<br /><br />Mandarin Oriental, Kuala Lumpur<br />Best Hotels And Resorts";
award_2007_captions[19]="Global Traveler<br />The Best of 2006 – January 2007 :: Mandarin Oriental Hotel Group<br />Best Asian Hotel Chain";
award_2007_captions[20]="Travel + Leisure US<br />World Best Awards - T+L 500 – January 2007 :: Mandarin Oriental, San Francisco<br />Mandarin Oriental, Miami<br />Mandarin Oriental, New York<br />Mandarin Oriental Hyde Park, London<br />Mandarin Oriental, Munich<br />Mandarin Oriental, Hong Kong<br />Mandarin Oriental, Kuala Lumpur<br />The Oriental, Singapore<br />The Oriental, Bangkok<br />Mandarin Oriental Dhara Dhevi, Chiang Mai";
award_2007_captions[21]="Conde Nast Traveler USA –<br />Gold List 2007 – January 2007 :: The Oriental, Bangkok<br />The Best by Food in Asia, Australia & Pacific Nations<br />Gold List<br /><br />Mandarin Oriental, San Francisco<br />Mandarin Oriental, Miami<br />Mandarin Oriental, New York<br />Mandarin Oriental Hyde Park, London<br />Mandarin Oriental, Munich<br />The Landmark Mandarin Oriental, Hong Kong<br />Mandarin Oriental, Hong Kong<br />Mandarin Oriental, Kuala Lumpur<br />The Oriental, Singapore<br />Gold List";
award_2007_captions[22]="Tatler Travel Guide<br />101 Best Hotels – January 2007 :: Mandarin Oriental, Tokyo<br />101 Best Hotels - Fabulous Cities<br /><br />Mandarin Oriental, Prague<br />101 Best Hotels - Romantic Weekends<br /><br />The Oriental, Bangkok<br />101 Best Hotels – Rooms with a View";
award_2007_captions[23]="Zagat Survey<br />2007 Top U.S. Hotels, Resort & Spas :: Mandarin Oriental, Miami<br />Top Large Hotels<br />Top Rooms<br />Tops in Area – Miami & Miami Beach<br />Tops in State - Florida<br /><br />Mandarin Oriental, New York<br />Top Large Hotels<br />Top Rooms<br />Top Public Facilities<br />Tops in City – New York City<br /><br />Mandarin Oriental, Washington DC<br />Top Large Hotels<br />Tops in District – District of Columbia<br /><br />Mandarin Oriental, San Francisco<br />Top Large Hotels<br />Tops in Area – San Francisco";
award_2007_captions[24]="Conde Nast Traveller<br />Readers’ Travel Awards-October 2007 :: Mandarin Oriental Dhara Dhevi, Chiang Mai<br />No.3 in Overseas Leisure Hotels- Asia &amp; the Indian Subcontinent<br /><br />The Oriental, Bangkok<br />No.8 in Overseas Leisure Hotels- Asia &amp; the Indian Subcontinent<br />No.5 in Overseas Hotel Spas<br /><br />Mandarin Oriental, New York<br />No.5 in Overseas Leisure Hotels-The Americas &amp; the Caribbean<br />No.10 in Overseas Business Hotels &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp; <br /><br />Mandarin Oriental Hyde Park, London<br />No.4 in UK Leisure Hotels<br />No.2 in UK Hotel Spas<br /><br />The Landmark Mandarin Oriental, Hong Kong<br />No.2 in Overseas Business Hotels<br />";

award_covers_2007[0] = ["images/magazines/modern-bride_large.jpg", award_2007_captions[0]];
award_covers_2007[1] = ["images/magazines/instinv-07_large.jpg", award_2007_captions[1]];
award_covers_2007[2] = ["images/magazines/aug07-worldsbest_large.jpg", award_2007_captions[2]];
award_covers_2007[3] = ["images/magazines/TLjune07_large.jpg", award_2007_captions[3]];
award_covers_2007[4] = ["images/magazines/tljune07_large.jpg", award_2007_captions[4]];
award_covers_2007[5] = ["images/magazines/cntgold_07_large.jpg", award_2007_captions[5]];
award_covers_2007[6] = ["images/magazines/forbstrav_large.jpg", award_2007_captions[6]];
award_covers_2007[7] = ["images/magazines/zagat0708_large.jpg", award_2007_captions[7]];
award_covers_2007[8] = ["images/magazines/cnt-apr-spa_large.jpg", award_2007_captions[8]];
award_covers_2007[9] = ["images/magazines/cnt-may-hot-list_large.jpg", award_2007_captions[9]];
award_covers_2007[10] = ["images/magazines/hothotels_trav_large.jpg", award_2007_captions[10]];
award_covers_2007[11] = ["images/magazines/mobiltg_img_large.jpg", award_2007_captions[11]];
award_covers_2007[12] = ["images/magazines/100best_img_large.jpg", award_2007_captions[12]];
award_covers_2007[13] = ["images/magazines/travlei_img_large.jpg", award_2007_captions[13]];
award_covers_2007[14] = ["images/magazines/spa_asia_img_large.jpg", award_2007_captions[14]];
award_covers_2007[15] = ["images/magazines/asiamon_07_large.jpg", award_2007_captions[15]];
award_covers_2007[16] = ["images/magazines/in_in_img_large.jpg", award_2007_captions[16]];
award_covers_2007[17] = ["images/magazines/condeitaly_large.jpg", award_2007_captions[17]];
award_covers_2007[18] = ["images/magazines/desasian07_large.jpg", award_2007_captions[18]];
award_covers_2007[19] = ["images/magazines/globtrav_large.jpg", award_2007_captions[19]];
award_covers_2007[20] = ["images/magazines/worldbest_large.jpg", award_2007_captions[20]];
award_covers_2007[21] = ["images/magazines/conde_large.jpg", award_2007_captions[21]];
award_covers_2007[22] = ["images/magazines/tatler07_large.jpg", award_2007_captions[22]];
award_covers_2007[23] = ["images/magazines/zag07_large.jpg", award_2007_captions[23]];
award_covers_2007[24] = ["images/magazines/traveller_oct_2007_large.jpg", award_2007_captions[24]];
/********************End********************* Awards *********************End********************/

/*******************Begin******************** Press Quotes ********************Begin*******************/

function quotesGallery() {

    //var yearSlide = new Fx.Slide('subYear', {mode: 'horizontal'});
    //yearSlide.hide();

    sliderObjectsHotels = createCollection(sliderObjectsHotels, "hSlide", 17, 'vertical');
    sliderObjectsSpaQuotes = createCollection(sliderObjectsSpaQuotes, "sSlide", 6, 'vertical');
    sliderObjectsRBQuotes = createCollection(sliderObjectsRBQuotes, "rSlide", 4, 'vertical');
    hideAllSliders(sliderObjectsHotels, 17);
    hideAllSliders(sliderObjectsSpaQuotes, 6);
    hideAllSliders(sliderObjectsRBQuotes, 4);

    // hotels
    $('hToggle1Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[0].toggle(); e.stop();}); $('closehToggle1').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[0].slideOut(); e.stop();});
    $('hToggle2Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[1].toggle(); e.stop();}); $('closehToggle2').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[1].slideOut(); e.stop();});
    $('hToggle3Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[2].toggle(); e.stop();}); $('closehToggle3').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[2].slideOut(); e.stop();});
    $('hToggle4Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[3].toggle(); e.stop();}); $('closehToggle4').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[3].slideOut(); e.stop();});
    $('hToggle5Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[4].toggle(); e.stop();}); $('closehToggle5').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[4].slideOut(); e.stop();});
    $('hToggle6Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[5].toggle(); e.stop();}); $('closehToggle6').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[5].slideOut(); e.stop();});
    $('hToggle7Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[6].toggle(); e.stop();}); $('closehToggle7').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[6].slideOut(); e.stop();});
    $('hToggle8Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[7].toggle(); e.stop();}); $('closehToggle8').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[7].slideOut(); e.stop();});
    $('hToggle9Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[8].toggle(); e.stop();}); $('closehToggle9').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[8].slideOut(); e.stop();});
    $('hToggle10Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[9].toggle(); e.stop();}); $('closehToggle10').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[9].slideOut(); e.stop();});
    $('hToggle11Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[10].toggle(); e.stop();}); $('closehToggle11').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[10].slideOut(); e.stop();});
    $('hToggle12Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[11].toggle(); e.stop();}); $('closehToggle12').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[11].slideOut(); e.stop();});
    $('hToggle13Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[12].toggle(); e.stop();}); $('closehToggle13').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[12].slideOut(); e.stop();});
    $('hToggle14Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[13].toggle(); e.stop();}); $('closehToggle14').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[13].slideOut(); e.stop();});
    $('hToggle15Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[14].toggle(); e.stop();}); $('closehToggle15').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[14].slideOut(); e.stop();});
    $('hToggle16Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[15].toggle(); e.stop();}); $('closehToggle16').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[15].slideOut(); e.stop();});
    $('hToggle17Title').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[16].toggle(); e.stop();}); $('closehToggle17').addEvent('click', function(e){e = new Event(e); sliderObjectsHotels[16].slideOut(); e.stop();});

    // spa
    $('sToggle1Title').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[0].toggle(); e.stop();}); $('closesToggle1').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[0].slideOut(); e.stop();});
    $('sToggle2Title').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[1].toggle(); e.stop();}); $('closesToggle2').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[1].slideOut(); e.stop();});
    $('sToggle3Title').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[2].toggle(); e.stop();}); $('closesToggle3').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[2].slideOut(); e.stop();});
    $('sToggle4Title').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[3].toggle(); e.stop();}); $('closesToggle4').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[3].slideOut(); e.stop();});
    $('sToggle5Title').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[4].toggle(); e.stop();}); $('closesToggle5').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[4].slideOut(); e.stop();});
    $('sToggle6Title').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[5].toggle(); e.stop();}); $('closesToggle6').addEvent('click', function(e){e = new Event(e); sliderObjectsSpaQuotes[5].slideOut(); e.stop();});

    // restaurant and bars
    $('rToggle1Title').addEvent('click', function(e){e = new Event(e); sliderObjectsRBQuotes[0].toggle(); e.stop();}); $('closerToggle1').addEvent('click', function(e){e = new Event(e); sliderObjectsRBQuotes[0].slideOut(); e.stop();});
    $('rToggle2Title').addEvent('click', function(e){e = new Event(e); sliderObjectsRBQuotes[1].toggle(); e.stop();}); $('closerToggle2').addEvent('click', function(e){e = new Event(e); sliderObjectsRBQuotes[1].slideOut(); e.stop();});
    $('rToggle3Title').addEvent('click', function(e){e = new Event(e); sliderObjectsRBQuotes[2].toggle(); e.stop();}); $('closerToggle3').addEvent('click', function(e){e = new Event(e); sliderObjectsRBQuotes[2].slideOut(); e.stop();});
    $('rToggle4Title').addEvent('click', function(e){e = new Event(e); sliderObjectsRBQuotes[3].toggle(); e.stop();}); $('closerToggle4').addEvent('click', function(e){e = new Event(e); sliderObjectsRBQuotes[3].slideOut(); e.stop();});

    // expand/close all toggles
    $('hotelsToggleExpand').addEvent('click', function(e){
        e = new Event(e);
        if (this.innerHTML == "Expand all") {
            for (i = 1; i <= 17; i++) {
                openQuote('hToggle' + i, 'hSlide' + i);
            }
            slideInAllSliders(sliderObjectsHotels, 17);
            this.innerHTML = "Close all";
        } else {
            for (i = 1; i <= 17; i++) {
                closeQuote('hToggle' + i, 'hSlide' + i);
            }
            slideOutAllSliders(sliderObjectsHotels, 17);
            this.innerHTML = "Expand all";
        }
        e.stop();
    });
    
    $('spaToggleExpand').addEvent('click', function(e){
        e = new Event(e);
        if (this.innerHTML == "Expand all") {
            for (i = 1; i <= 6; i++) {
                openQuote('sToggle' + i, 'sSlide' + i);
            }
            slideInAllSliders(sliderObjectsSpaQuotes, 6);
            this.innerHTML = "Close all";
        } else {
            for (i = 1; i <= 6; i++) {
                closeQuote('sToggle' + i, 'sSlide' + i);
            }
            slideOutAllSliders(sliderObjectsSpaQuotes, 6);
            this.innerHTML = "Expand all";
        }
        e.stop();
    });
    
    $('diningToggleExpand').addEvent('click', function(e){
        e = new Event(e);
        if (this.innerHTML == "Expand all") {
            for (i = 1; i <= 4; i++) {
                openQuote('rToggle' + i, 'rSlide' + i);
            }
            slideInAllSliders(sliderObjectsRBQuotes, 4);
            this.innerHTML = "Close all";
        } else {
            for (i = 1; i <= 4; i++) {
                closeQuote('rToggle' + i, 'rSlide' + i);
            }
            slideOutAllSliders(sliderObjectsRBQuotes, 4);
            this.innerHTML = "Expand all";
        }
        e.stop();
    });
    
    var groupSlide = new Fx.Slide('groupQuotes', {
        duration:500,
        onComplete: function(){
            var wrapperObj = document.getElementById('groupQuotes').parentNode;
            if (wrapperObj.offsetHeight != 0)
                wrapperObj.setStyle('height', 'auto');
        }
    });
    var hotelsSlide = new Fx.Slide('hotelsQuotes', {
        duration:500,
        onComplete: function(){
            var wrapperObj = document.getElementById('hotelsQuotes').parentNode;
            if (wrapperObj.offsetHeight != 0)
                wrapperObj.setStyle('height', 'auto');
        }
    });
    var spaSlide = new Fx.Slide('spaQuotes', {
        duration:500,
        onComplete: function(){
            var wrapperObj = document.getElementById('spaQuotes').parentNode;
            if (wrapperObj.offsetHeight != 0)
                wrapperObj.setStyle('height', 'auto');
        }
    });
    var diningSlide = new Fx.Slide('diningQuotes', {
        duration:500,
        onComplete: function(){
            var wrapperObj = document.getElementById('diningQuotes').parentNode;
            if (wrapperObj.offsetHeight != 0)
                wrapperObj.setStyle('height', 'auto');
        }
    });

    //groupSlide.hide();
    hotelsSlide.hide();
    spaSlide.hide();
    diningSlide.hide();

    var groupTransition = new Fx.Morph('groupToggle', {duration:1000, transition:Fx.Transitions.linear});
    var hotelsTransition = new Fx.Morph('hotelsToggle', {duration:1000, transition:Fx.Transitions.linear});
    var spaTransition = new Fx.Morph('spaToggle', {duration:1000, transition:Fx.Transitions.linear});
    var diningTransition = new Fx.Morph('diningToggle', {duration:1000, transition:Fx.Transitions.linear});
    var tbTransition = new Fx.Morph('topBorder', {duration:1000, transition:Fx.Transitions.linear});
    var bbTransition = new Fx.Morph('bottomBorder', {duration:1000, transition:Fx.Transitions.linear});

    $('groupToggle').addEvent('click', function(e){
        e = new Event(e); groupSlide.toggle(); /* groupSlide.slideIn(); hotelsSlide.slideOut(); spaSlide.slideOut(); diningSlide.slideOut(); */ e.stop();
        var tObj = document.getElementById("groupToggle");
        var aObj1 = document.getElementById("groupToggle1");
        var aObj2 = document.getElementById("groupToggle2");
        if (aObj1.className == "up") {
            tObj.className = "header_selected header_border_closed header_top";
            groupTransition.start({'color': ['#333333', '#ffffff'], 'background-color': ['#ffffff', '#666666']});
            tbTransition.start({'color': ['#333333', '#ffffff'], 'background-color': ['#ffffff', '#666666']});
            aObj1.className = "down";
            aObj2.className = "down";
        } else {
            tObj.className = "header header_border_opened header_top";
            groupTransition.start({'color': ['#ffffff', '#333333'], 'background-color': ['#666666', '#ffffff']});
            tbTransition.start({'color': ['#ffffff', '#333333'], 'background-color': ['#666666', '#ffffff']});
            aObj1.className = "up";
            aObj2.className = "up";
        }
    });
    $('hotelsToggle').addEvent('click', function(e){
        e = new Event(e); hotelsSlide.toggle(); /* hotelsSlide.slideIn(); groupSlide.slideOut(); spaSlide.slideOut(); diningSlide.slideOut(); */ e.stop();
        var tObj = document.getElementById("hotelsToggle");
        var aObj1 = document.getElementById("hotelsToggle1");
        var aObj2 = document.getElementById("hotelsToggle2");
        var eObj = document.getElementById("hotelsToggleExpand");
        if (aObj1.className == "up") {
            tObj.className = "header_selected header_border_closed";
            hotelsTransition.start({'color': ['#333333', '#ffffff'], 'background-color': ['#ffffff', '#666666']});
            aObj1.className = "down";
            aObj2.className = "down";
            eObj.className = "toggleAll";
        } else {
            tObj.className = "header header_border_opened";
            hotelsTransition.start({'color': ['#ffffff', '#333333'], 'background-color': ['#666666', '#ffffff']});
            aObj1.className = "up";
            aObj2.className = "up";
            eObj.className = "toggleAll2";
        }
    });
    $('spaToggle').addEvent('click', function(e){
        e = new Event(e); spaSlide.toggle(); /* spaSlide.slideIn(); groupSlide.slideOut(); hotelsSlide.slideOut(); diningSlide.slideOut(); */ e.stop();
        var tObj = document.getElementById("spaToggle");
        var aObj1 = document.getElementById("spaToggle1");
        var aObj2 = document.getElementById("spaToggle2");
        var eObj = document.getElementById("spaToggleExpand");
        if (aObj1.className == "up") {
            tObj.className = "header_selected header_border_closed";
            spaTransition.start({'color': ['#333333', '#ffffff'], 'background-color': ['#ffffff', '#666666']});
            aObj1.className = "down";
            aObj2.className = "down";
            eObj.className = "toggleAll";
        } else {
            tObj.className = "header header_border_opened";
            spaTransition.start({'color': ['#ffffff', '#333333'], 'background-color': ['#666666', '#ffffff']});
            aObj1.className = "up";
            aObj2.className = "up";
            eObj.className = "toggleAll2";
        }
    });
    $('diningToggle').addEvent('click', function(e){
        e = new Event(e); diningSlide.toggle(); /* diningSlide.slideIn(); groupSlide.slideOut(); hotelsSlide.slideOut(); spaSlide.slideOut(); */ e.stop();
        var tObj = document.getElementById("diningToggle");
        var aObj1 = document.getElementById("diningToggle1");
        var aObj2 = document.getElementById("diningToggle2");
        var eObj = document.getElementById("diningToggleExpand");
        if (aObj1.className == "up") {
            tObj.className = "header_selected header_border_closed";
            spaTransition.start({'color': ['#333333', '#ffffff'], 'background-color': ['#ffffff', '#666666']});
            aObj1.className = "down";
            aObj2.className = "down";
            eObj.className = "toggleAll";
        } else {
            tObj.className = "header header_border_opened";
            spaTransition.start({'color': ['#ffffff', '#333333'], 'background-color': ['#666666', '#ffffff']});
            aObj1.className = "up";
            aObj2.className = "up";
            eObj.className = "toggleAll2";
        }
    });
    $('closeGroup').addEvent('click', function(e){
        e = new Event(e); groupSlide.slideOut(); e.stop();
        var tObj = document.getElementById("groupToggle");
        var aObj1 = document.getElementById("groupToggle1");
        var aObj2 = document.getElementById("groupToggle2");
        tObj.className = "header_selected header_border_closed header_top";
        groupTransition.start({'color': ['#333333', '#ffffff'], 'background-color': ['#ffffff', '#666666']});
        tbTransition.start({'color': ['#333333', '#ffffff'], 'background-color': ['#ffffff', '#666666']});
        aObj1.className = "down";
        aObj2.className = "down";
    });
}

function toggle(id, id2) {
    var toggleObj = document.getElementById(id);
    var slideObj = document.getElementById(id2);
    var titleObj = document.getElementById(id + 'Title');
    if (toggleObj.className == "sliderHeader2") {
        toggleObj.className = "sliderHeader";
        slideObj.className = "sliderContent";
        titleObj.className = "sliderHeaderTitle";
    }
    else {
        toggleObj.className = "sliderHeader2";
        slideObj.className = "sliderContent2";
        titleObj.className = "sliderHeaderTitle2";
    }
}
function openQuote(id, id2) {
    var toggleObj = document.getElementById(id);
    var slideObj = document.getElementById(id2);
    var titleObj = document.getElementById(id + 'Title');
    toggleObj.className = "sliderHeader2";
    slideObj.className = "sliderContent2";
    titleObj.className = "sliderHeaderTitle2";
}
function closeQuote(id, id2) {
    var toggleObj = document.getElementById(id);
    var slideObj = document.getElementById(id2);
    var titleObj = document.getElementById(id + 'Title');
    toggleObj.className = "sliderHeader";
    slideObj.className = "sliderContent";
    titleObj.className = "sliderHeaderTitle";
}
function highlight(id) {
    var spanObj = document.getElementById(id + 'Title');
    spanObj.className = "sliderHeaderTitle2";
}
function dehighlight(id) {
    var headerObj = document.getElementById(id);
    if (headerObj.className == "sliderHeader") {
        var spanObj = document.getElementById(id + 'Title');
        spanObj.className = "sliderHeaderTitle";
    }
}
/********************End********************* Press Quotes *********************End********************/

/*******************Begin******************** Hotel Destination - Things to Do and See ********************Begin*******************/
function toggleFind(id, id2) {
	var toggleObj = document.getElementById(id);
	var findObj = document.getElementById(id + 'Span');
	var slideObj = document.getElementById(id2);
	var titleObj = document.getElementById(id + 'Title');
	if (toggleObj.className == "sliderHeader2") {
		findObj.className = "sliderHeaderFind";
		toggleObj.className = "sliderHeader";
		slideObj.className = "sliderContent";
		titleObj.className = "sliderHeaderTitle";
	}
	else {
		findObj.className = "sliderHeaderFind2";
		toggleObj.className = "sliderHeader2";
		slideObj.className = "sliderContent2";
		titleObj.className = "sliderHeaderTitle2";
	}
}
function toggleFindCase(id, id2, closeOpen) {
	var toggleObj = document.getElementById(id);
	var findObj = document.getElementById(id + 'Span');
	var slideObj = document.getElementById(id2);
	var titleObj = document.getElementById(id + 'Title');
	if (closeOpen == 0) {
		findObj.className = "sliderHeaderFind";
		toggleObj.className = "sliderHeader";
		slideObj.className = "sliderContent";
		titleObj.className = "sliderHeaderTitle";
	} else {
		findObj.className = "sliderHeaderFind2";
		toggleObj.className = "sliderHeader2";
		slideObj.className = "sliderContent2";
		titleObj.className = "sliderHeaderTitle2";
	}
}
function toggleFindAll(toggle, slide, num, closeOpen) {
	for (i = 1; i <= num; i++) {
		id = toggle + i;
		id2 = slide + i;
		toggleFindCase(id, id2, closeOpen);
	}
}

/********************End********************* Hotel Destination - Things to Do and See *********************End********************/

/*******************Begin******************** Rooms & Suites ********************Begin*******************/

function toggleRooms(startIndex, endIndex, toggle, idBase) {
	for (i = startIndex; i <= endIndex; i++) {
		toggleRoom(i, toggle, idBase);
	}
}

function toggleRoom(i, toggle, idBase) {
	var roomObj = document.getElementById(idBase + "room" + i);
	var rowDiv = document.getElementById(idBase + "rgr" + i);
	// for toggling "details | booking"
	var detailsDiv = document.getElementById(idBase + "roomDetails" + i);
	if (toggle == 0 || (roomObj.className == "rTW" && toggle != 1)) {
		roomObj.className = "rTW2";
		rowDiv.className = "headerRSType";
		detailsDiv.className = "room_details_hidden";
	} else {
		roomObj.className = "rTW";
		rowDiv.className = "headerRSType";
		detailsDiv.className = "roomDetails";
	}
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
var scrollXYArray = new Array();

var LightboxRS = {

	init: function(options){
		this.options = $extend({
			resizeDuration: 400,
			resizeTransition: false,	// default transition
			initialWidth: 25,
			initialHeight: 25,
			animateCaption: true,
			showCounter: true
		}, options || {});

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightbox/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = new Keyboard({
			eventType: 'keydown'			
		});
		this.eventPosition = this.position.bind(this);

		this.overlay = new Element('div', {'id': 'lbOverlayRS'}).injectInside(document.body);

		this.center = new Element('div', {'id': 'lbCenterRS', 'styles': {'width': this.options.initialWidth, 'height': this.options.initialHeight, 'marginLeft': -(this.options.initialWidth/2), 'display': 'none'}}).injectInside(document.body);
		this.image = new Element('div', {'id': 'lbImageRS'}).injectInside(this.center);
		
		this.bottomContainer = new Element('div', {'id': 'lbBottomContainerRS', 'styles': {'display': 'none'}}).injectInside(document.body);
		this.bottom = new Element('div', {'id': 'lbBottomRS'}).injectInside(this.bottomContainer);
		
		this.captionTitle = new Element('div', {'id': 'lbCaptionTitleRS'}).injectInside(this.bottom);
		this.caption = new Element('div', {'id': 'lbCaptionRS'}).injectInside(this.bottom);
		this.facilities = new Element('div', {'id': 'facilitiesToggle', 'class': 'facilitiesToggle'}).injectInside(this.bottom);
		this.facilitiesContent = new Element('div', {'id': 'facilitiesSlide'}).injectInside(this.bottom);
		this.facilitiesLeft = new Element('div', {'id': 'facilitiesLeft'}).injectInside(this.facilitiesContent);
		this.facilitiesRight = new Element('div', {'id': 'facilitiesRight'}).injectInside(this.facilitiesContent);
		this.navLinks = new Element('div', {'id': 'navLinksRS'}).injectInside(this.bottom);

		this.prevLink = new Element('div', {'id': 'lbPrevLinkRS'}).injectInside(this.navLinks);
		this.number = new Element('div', {'id': 'lbNumberRS'}).injectInside(this.navLinks);
		this.nextLink = this.prevLink.clone().setProperty('id', 'lbNextLinkRS').injectInside(this.navLinks);
		this.prevLink.onclick = this.previous.bind(this);
		this.nextLink.onclick = this.next.bind(this);
		this.prevLink.set("html", '<< Précédent');
		this.nextLink.set("html", 'Suivant >>');

		this.reserveLink = new Element('div', {'id': 'lbReserveLinkRS'}).injectInside(this.navLinks);
		this.reserveLink.set("html", '&middot; Réserver cette chambre');
		
		this.closeLink = new Element('div', {'id': 'lbCloseLinkRS'}).injectInside(this.navLinks);
		this.closeLink.onclick = this.overlay.onclick = this.close.bind(this);
		this.closeLink.set("html", '&middot; Fermer');
		//new Element('div', {'styles': {'clear': 'both'}}).injectInside(this.bottom);

		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
            overlay: new Fx.Tween(this.overlay, {property: 'opacity', duration: 500}).start(0),
            resize: this.center.set('morph', $extend({duration: this.options.resizeDuration, onComplete: nextEffect}, this.options.resizeTransition ? {transition: this.options.resizeTransition} : {})),
            image: this.image.set('tween',  { duration: 500, onComplete: nextEffect }),
            bottom: new Fx.Tween(this.bottom, {property: 'marginTop', duration: 400, onComplete: nextEffect })
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title);

		var j, imageNum, images = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < images.length; j++) if(images[j][0] == el.href) break;
				if (j == images.length){
					images.push([el.href, el.title]);
					if (el.href == link.href) imageNum = j;
				}
			}
		}, this);
		return this.open(images, imageNum);
	},

	show: function(url, title){
		return this.open([[url, title]], 0);
	},
	
	showRS: function(images){
		return this.open(images, 0);
	},
	
	showRSs: function(images, imageNum){
		return this.open(images, imageNum);
	},
	

	open: function(images, imageNum){
		this.images = images;
		this.position();
		this.setup(true);
		this.top = window.getScrollTop();
		scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});
		this.fx.overlay.start('0.4');
		return this.changeImage(imageNum);
	},

	position: function(){
		this.overlay.setStyles({'top': window.getScrollTop(), 'height': window.getHeight()});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		elements.extend(document.getElementsByTagName(window.ie ? 'select' : 'embed'));
		elements.each(function(el){
			if (open) el.lbBackupStyle = el.style.visibility;
			el.style.visibility = open ? 'hidden' : el.lbBackupStyle;
		});
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeImage(this.activeImage-1);
	},

	next: function(){
		return this.changeImage(this.activeImage+1);
	},

	changeImage: function(imageNum){
		if (this.step || (imageNum < 0) || (imageNum >= this.images.length)) return false;
		this.step = 1;
		this.activeImage = imageNum;
		
		this.top = window.getScrollTop();
        scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});

		this.bottomContainer.style.display = this.prevLink.style.display = this.nextLink.style.display = 'none';
		this.fx.image.fade('hide');
		this.center.className = 'lbLoadingRS';

		this.preload = new Image();
		this.preload.onload = this.nextEffect.bind(this);
		this.preload.src = this.images[imageNum][0];
		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			this.center.className = '';
			this.image.style.backgroundImage = 'url('+this.images[this.activeImage][0]+')';
			this.image.style.width = this.bottom.style.width = this.preload.width+'px';
			this.image.style.height = this.preload.height+'px';

			var strCaption = this.images[this.activeImage][1].substring(this.images[this.activeImage][1].search("::")+2);	// make use of tooltip title; has format "title :: caption"
			var strCaptionTitle = this.images[this.activeImage][1].substring(0, this.images[this.activeImage][1].search("::"));
			this.captionTitle.set("html", "<h3>" + strCaptionTitle + "</h3>" || '');
			this.caption.set("html", strCaption || '');
			this.facilities.set("html", "<h3>" + this.images[this.activeImage][2][0] + "</h3>");
			this.facilitiesLeft.set("html", this.images[this.activeImage][2][1]);
			this.facilitiesRight.set("html", this.images[this.activeImage][2][2]);
			this.reserveLink.set("html", "&middot; <a href='" + this.images[this.activeImage][3] + "&lang=3" + "' target='_blank'>Réserver cette chambre</a>");

			this.number.set("html", (!this.options.showCounter || (this.images.length == 1)) ? '' : (this.activeImage+1)+" sur "+this.images.length);

			if (this.activeImage) this.preloadPrev.src = this.images[this.activeImage-1][0];
			if (this.activeImage != (this.images.length - 1)) this.preloadNext.src = this.images[this.activeImage+1][0];
			if (this.center.clientHeight != this.image.offsetHeight){
				this.fx.resize.morph({'height': this.image.offsetHeight});
				break;
			}
			this.step++;
		case 2:
			if (this.center.clientWidth != this.image.offsetWidth){
				this.fx.resize.morph({'width': this.image.offsetWidth, 'marginLeft': -this.image.offsetWidth/2});
				break;
			}
			this.step++;
		case 3:
			this.bottomContainer.setStyles({top: this.top + this.center.clientHeight, height: 0, marginLeft: this.center.style.marginLeft, display: ''});
			this.fx.image.fade('1');
			break;
		case 4:
			if (this.options.animateCaption){
				this.fx.bottom.set(-this.bottom.offsetHeight);
				this.bottomContainer.style.height = '';
				this.fx.bottom.start(0);
				break;
			}
			this.bottomContainer.style.height = '';
		case 5:
			if (this.activeImage) this.prevLink.style.display = '';
			if (this.activeImage != (this.images.length - 1)) this.nextLink.style.display = '';
			this.step = 0;
		}
	},

	close: function(){
		if (this.step < 0) return;
		this.step = -1;
		if (this.preload){
			this.preload.onload = function () {}; //Class.empty;
			this.preload = null;
		}
		//for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
        this.fx.overlay.start('opacity', 0).chain(this.setup.pass(false, this));
		return false;
	}
};
/********************End********************* Rooms & Suites *********************End********************/

/*******************Begin******************** Spa ********************Begin*******************/
function accordionSidebar() {

    var accordion = new Accordion('h3.atStart', 'div.atStart', {
        opacity: false,
        onActive: function(toggler, element){
            toggler.setStyle('color', '#000000');
            toggler.setStyle('background', 'url(images/right_tbl_middle_hdr.gif) no-repeat');
        },
        onBackground: function(toggler, element){
            toggler.setStyle('color', '#AAAAAA');
            //toggler.setStyle('background', '#6399C6');
        }
    }, $('accordion'));
}
/********************End********************* Spa *********************End********************/

/*******************Begin******************** Dining ********************Begin*******************/
var imageTitle = new Array();
var imageContent = new Array();
        
imageTitle[0] = "Design by Tony Chi";
imageTitle[1] = "Chef de Cuisine Noriyuki Sugie";
imageContent[0] = ["images/asiate1.jpg", imageTitle[0]];
imageContent[1] = ["images/asiate2.jpg", imageTitle[1]];
/********************End********************* Dining *********************End********************/

/*******************Begin******************** Toolbox ********************Begin*******************/

/********************End********************* Toolbox *********************End********************/

// check if a slider is open
function isOpen(id) {
    var sliderObject = document.getElementById(id);
    var parentObject = sliderObject.parentNode;
    if (parseInt(parentObject.style.height) > 0)
        return true;
    else
        return false;
}

// id of currently clicked element
var currentId = null;

function changeClass(id, className) {
    var object = document.getElementById(id);
    object.className = className;
}
// don't change class on mouseout if it has already been clicked
function changeClassExcept(idCur, idNew, className) {
    if (idCur != idNew) {
        var object = document.getElementById(idNew);
        object.className = className;
    }
}
// on mouseout revert to previous class
function changeClassPrevious(idCur, idNew, className, className2) {
    var object = document.getElementById(idNew);
    if (idCur != idNew) {
        object.className = className;
    } else {
        object.className = className2;
    }
}
// revert the previously clicked element before changing the currently clicked element
function changeClassAndRevert(id, id2, className, className2) {
    if (id != null) {
        var objPrev = document.getElementById(currentId);
        objPrev.className = className;
    }
    var object = document.getElementById(id2);
    object.className = className2;
    currentId = id2;
}
// change class on mouseout based on the state of a different element
function changeClassCheck(id, id2, className, className2) {
    var object = document.getElementById(id);
    if (object.className == className) {
        var object2 = document.getElementById(id2);
        object2.className = className2;
    }
}

// change classes for a collection of elements
function changeClasses(baseId, num, className) {
    for (i = 1; i <= num; i++) {
        strId = baseId + i;
        changeClass(strId, className);
    }
}

// change classes for a collection of elements except one
function changeClassesExceptOne(baseId, num, className, exceptNum, className2) {
    for (i = 1; i <= num; i++) {
        strId = baseId + i;
        if (i != exceptNum) {
            changeClass(strId, className);
        } else {
            changeClass(strId, className2);
        }
    }
}

/*******************Begin******************** Interactive Map - POI ********************Begin*******************/

var poiSubListId = "";
var poiCatListId = "";

function poiCatOnHover(poi){
	poi.style.fontWeight = "bold";
	poi.style.color = "#000";
}
function poiCatOffHover(poi){
	if (poi.id!=poiCatListId){
		poi.style.fontWeight = "normal";
		poi.style.color = "#666";
	}
	else{
		poi.style.fontWeight = "bold";
		poi.style.color = "#404040";
	}
}
function poiCatClick(poi){
      if (poiCatListId != ""){
            document.getElementById(poiCatListId).style.fontWeight="normal";
            document.getElementById(poiCatListId).style.color="#666";
      }
	poiCatListId = poi.id;
            document.getElementById(poiCatListId).style.fontWeight="bold";
            document.getElementById(poiCatListId).style.color="#404040";
      }

function poiOnHover(poi){
	poi.style.fontWeight = "bold";
	poi.style.color = "#000";
}
function poiOffHover(poi){
	if (poi.id!=poiSubListId){
		poi.style.fontWeight = "normal";
		poi.style.color = "#666";
	}
}
function poiClick(poi){
	poiSubListId = poi.id;
	var listRay = poi.parentNode.parentNode.getElementsByTagName("li");
	for (i=0; i< listRay.length; i++){
		listRay[i].firstChild.style.fontWeight = "normal";
		listRay[i].firstChild.style.color = "#666";
	}
	poi.style.fontWeight = "bold";
	poi.style.color = "#666";
}
function resetPoiSubList(){
	if (poiSubListId != ""){
		document.getElementById(poiSubListId).style.fontWeight='normal';
	}
}

function selectSubCatagory(link){
    // <a> --- <li> --- <ul> --- all <li>'s in the <ul>
    var childrenArray = link.parentNode.parentNode.childNodes;
    for (i = 0; i < childrenArray.length; i++){
        if (childrenArray[i].value != undefined){
            var aArray = childrenArray[i].getElementsByTagName("span");
            aArray[0].className = "";
        }
    }
    link.className = "subSelect";
}
// fill an element with text
function setText(id, text) {    // NEED TO CHANGE FUNCTION NAME SO AS NOT TO CONFLICT WITH CORP GALLERY
    var object = document.getElementById(id);
    object.innerHTML = text;
}
// fill an element with text from another element
function setText2(id, id2) {
    var object = document.getElementById(id);
    var object2= document.getElementById(id2);
    object.innerHTML = object2.innerHTML;
}
// display a hidden element
function revealElement(id) {
    var object = document.getElementById(id);
    object.style.display = "block";
}

function showDirections() {
/*
    var elementsAR = document.getElementsByTagName("div");
    for (i=0; i<elementsAR.length; i++){
        if (elementsAR[i].className == "directions"){
            elementsAR[i].style.display="block";
        }
    }
*/
    document.getElementById("directions").style.display = "block";
}

function setIframePathname(pathname) {
    fl = frames.length
    if (fl > 1) {
        frames[1].location.pathname = pathname;
    } else {
        frames[0].location.pathname = pathname;
    }
    if (pathname == "/boston/location_map.aspx") {
        setMapNavText(2);
    } else {
        setMapNavText(1);
    }
}

function setMapNavText(num) {
    var objLink = document.getElementById("lbOtherLinkExMap");
    if (num == "1") {
        objLink.innerHTML = "<span class=clickHere onclick=setIframePathname('/boston/location_map.aspx');>Click here</span> to view other points of interest";
    } else {
        objLink.innerHTML = "<span class=clickHere onclick=setIframePathname('/boston/interactive_map.aspx');>Click here</span> to search a specific location";
    }
}

function printWindow() {
    if (document.getElementById("hagPopup") != null) {
        frames[1].print();
    } else {
        frames[0].print();
    }
}

/********************End********************* Interactive Map - POI *********************End********************/
/* Currency Converter Popup */
var LightboxExCC = {
	init: function(options){
		this.options = Object.extend({
			resizeDuration: 400,
			resizeTransition: Fx.Transitions.sineInOut,
			initialWidth: 250,
			initialHeight: 250,
			animateCaption: true,
			defaultIframeWidth : 462, 
			defaultIframeHeight: 300
		}, options || {});

		// IE 6 - XML prolog problem
		if(window.ie6 && document.compatMode=="BackCompat"){
			this.options.animateCaption = false;
		}

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightboxExCC/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = new Keyboard({
			eventType: 'keydown'			
		});
		this.eventPosition = this.position.bind(this);

        this.overlay = new Element('div', {'id':'lbOverlayExCC', 'class':'lbOverlayEx'}).injectInside(document.body);
        this.center = new Element('div', {'id':'lbCenterExCC', 'class':'lbCenterEx'}).setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', marginLeft: '-'+(this.options.initialWidth/2)+'px', display: 'none'}).injectInside(document.body);
		this.canvas = new Element('div', {'id':'lbCanvasExCC', 'class':'lbCanvasEx'}).injectInside(this.center);

		this.closeBtnTop = new Element('a', {'id':'closeBtnTopCC', 'href':'#', 'class':'lbCloseBtnTop'}).injectInside(this.canvas);
		this.closeBtnTop.set("html", "Fermer");
		this.closeBtnTop.onclick = this.overlay.onclick = this.close.bind(this);
		
		this.bottomContainer = new Element('div', {'id':'lbBottomContainerPopCC', 'class':'lbBottomContainerPop', 'styles': {'display':'none'}}).injectInside(document.body);
		this.bottom = new Element('div', {'id':'lbBottomPopCC', 'class':'lbBottomPop'}).injectInside(this.bottomContainer);
		
		this.navBottom = new Element('div', {'id':'lbNavBottomPopCC', 'class':'lbNavBottomPop', 'styles': {'width':'468px'}}).injectInside(this.bottom);
		this.navWrapper = new Element('div', {'id':'lbNavWrapperPopCC', 'class':'lbNavWrapperPop', 'styles': {'width':'460px'}}).injectInside(this.navBottom);
		new Element('div', {'class': 'tlc'}).injectInside(this.navWrapper);
		new Element('div', {'class': 'trc'}).injectInside(this.navWrapper);
		new Element('div').injectInside(this.navWrapper);   // empty div added for IE6
		this.subWrapper = new Element('div', {'id':'lbSubWrapperPopCC', 'class':'lbSubWrapperPop', 'styles': {'width':'360px'}}).injectInside(this.navWrapper);
		
		this.closeLink = new Element('div', {'id':'lbCloseLinkPopCC', 'class':'lbCloseLinkPop'}).injectInside(this.navWrapper);
		this.closeLink.onclick = this.overlay.onclick = this.close.bind(this);
		this.closeLink.set("html", "&middot; Fermer");
		
		new Element('div').injectInside(this.navWrapper);   // emtpy div added for IE6
		new Element('div', {'class': 'blc'}).injectInside(this.navWrapper);
		new Element('div', {'class': 'brc'}).injectInside(this.navWrapper);

		new Element('div').setStyle('clear', 'both').injectInside(this.bottom);

		/* Build effects */
		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
            overlay: new Fx.Tween(this.overlay, {property: 'opacity', duration: 500}).start(0),
            resizeCenter: this.center.set('morph', {duration: this.options.resizeDuration, transition: this.options.resizeTransition, onComplete: nextEffect}),
            image: this.canvas.set('tween',  { duration: 500, onComplete: nextEffect })/*,
            bottom: new Fx.Tween(this.bottomContainer, {property: 'height', duration: 400, onComplete: nextEffect })*/
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title, link.rev);

		var j, itemNumber, items = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < items.length; j++) if(items[j][0] == el.href && items[j][2] == el.rev) break;
				if (j == items.length){
					items.push([el.href, el.title, el.rev]);
					if (el.href == link.href && el.rev == link.rev) itemNumber = j;
				}
			}
		}, this);
		return this.open(items, itemNumber);
	},

	show: function(url, title, rev){
		return this.open([[url, title, rev]], 0);
	},

	open: function(items, itemNumber){
		this.items = items;
		this.position();
		this.setup(true);
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.top = window.getScrollTop();
		scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});
		this.fx.overlay.start('0.4');
		return this.changeItem(itemNumber);
	},

	position: function(){
		//IE6 - XML prolog problem.
		var ww = (window.getWidth() == 0) ? window.getScrollWidth()-22 : window.getWidth();
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.overlay.setStyles({top: st+'px', height: wh+'px', width:ww+'px'});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		if (window.ie) elements.extend(document.getElementsByTagName('select'));
		elements.each(function(el){ el.style.visibility = open ? 'hidden' : ''; });
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeItem(this.activeItem-1);
	},

	next: function(){
		return this.changeItem(this.activeItem+1);
	},

	changeItem: function(itemNumber){
		if (this.step || (itemNumber < 0) || (itemNumber >= this.items.length)) return false;
		this.step = 1;
		this.activeItem = itemNumber;
		
		this.top = window.getScrollTop();
        scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});

		//this.bottomContainer.style.display = 'none';
		//this.prevLink.style.display = this.nextLink.style.display = 'none';
		this.fx.image.fade('hide');
		//this.center.className = 'lbLoadingExHag';

		// discard previous content by clicking
		this.removeCurrentItem();
		
		// check item type
		var url = this.items[this.activeItem][0];
		var rev = this.items[this.activeItem][2];
		
		var re_imageURL = /\.(jpe?g|png|gif|bmp)/i;
		if( url.match(re_imageURL) ) {
			this.preload = new Image();	// JavaScript native Object
			this.preload.datatype = 'image';
			this.preload.w = this.matchOrDefault(rev, new RegExp("width=(\\d+%?)", "i"), -1); //-1 if use original size.
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+%?)", "i"), -1);
			this.preload.onload = this.nextEffect.bind(this);
			this.preload.src = url;
		}else{
			var ie7 = (document.all && !window.opera && window.XMLHttpRequest)? true : false;
			this.preload = new Object ();	// JavaScript native Object
			this.preload.datatype = 'iframe';
			this.preload.w =  this.matchOrDefault(rev, new RegExp("width=(\\d+)", "i"), this.options.defaultIframeWidth);
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+)", "i"), this.options.defaultIframeHeight);
			this.preload.h = (ie7)? 352 : this.preload.h;
			
			this.preload.src = url;
			this.nextEffect(); //asynchronous loading
		}

		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			//this.center.className = '';

			// create HTML element
			if( this.preload.datatype == 'image' ) {
				var ws = (this.preload.w == -1) ? this.preload.width.toString() : this.preload.w.toString();
				var hs = (this.preload.h == -1) ? this.preload.height.toString() : this.preload.h.toString();
				this.p_width = ( q = ws.match(/(\d+)%/) ) ? q[1] * this.preload.width * 0.01 : ws;
				this.p_height = ( q = hs.match(/(\d+)%/) ) ? q[1] * this.preload.height * 0.01 : hs;
				new Element('img').setProperties({id: 'lbImageExCC', src:this.preload.src, width:this.p_width, height:this.p_height}).injectInside(this.canvas);
				//this.nextLink.style.right = '';
			}else{
				this.p_width = this.preload.w;
				this.p_height = this.preload.h;
				// Safari would not update iframe content that has static id.
				this.iframeId = "lbFrame_"+new Date().getTime();
				//new Element('iframe').setProperties({id: this.iframeId, width: this.p_width, height: this.p_height, frameBorder:0, scrolling:'no', src:this.preload.src}).injectInside(this.canvas);
				this.iframe = new Element('iframe', {'id':this.iframeId, 'class':'ifsdf', 'src':this.preload.src, 'scrolling':'no', 'frameBorder':'0'}).injectInside(this.canvas);
				//, 'styles':{'width':'597px', 'height':'253px'}
				//this.nextLink.style.right = '25px';
			}
			this.canvas.style.width = this.p_width+'px';
			this.canvas.style.height = this.p_height+'px';

			//this.prevLink.style.height = this.nextLink.style.height = this.p_height+'px';

			//this.caption.set("html", this.items[this.activeItem][1] || '');
			//this.number.set("html",  (this.items.length == 1) ? '' : 'Page ' + (this.activeItem+1) + ' sur ' + this.items.length );

			if (this.activeItem) this.preloadPrev.src = this.items[this.activeItem-1][0];
			if (this.activeItem != (this.items.length - 1)) this.preloadNext.src = this.items[this.activeItem+1][0];
			if (this.center.clientHeight != this.canvas.offsetHeight){
				var oh = (this.p_height == this.canvas.clientHeight) ? this.canvas.offsetHeight : eval(this.p_height);
				this.fx.resizeCenter.morph({'height': oh});
				break;
			}

			this.step++;
		case 2:
			if (this.center.clientWidth != this.canvas.offsetWidth){
				var ow = (this.p_width == this.canvas.clientWidth) ? this.canvas.offsetWidth : eval(this.p_width)+18; // fix for ie
				this.fx.resizeCenter.morph({'width': ow, 'marginLeft': -ow/2});
				break;
			}
			this.step++;
		case 3:
			//this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', height:'0px', marginLeft: this.center.style.marginLeft, width:this.center.style.width, display: ''});
			this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', marginLeft: this.center.style.marginLeft, width:this.center.style.width, display: ''});
			this.fx.image.fade('1');
			break;
		case 4:
			if (this.options.animateCaption){
				// This is not smooth animation in IE 6 with XML prolog.
				// If your site is XHTML strict with XML prolog, disable this option.
				//this.fx.bottom.start(0,this.bottom.offsetHeight+10);
				break;
			}
			//this.bottomContainer.style.height = (this.bottom.offsetHeight+10)+'px';
		case 5:
			if (this.activeItem){
				//this.prevLink.style.display = '';
			}
			if (this.activeItem != (this.items.length - 1)){
				//this.nextLink.style.display = '';
			}
			this.step = 0;
		}
	},

	close: function(){
        if (document.getElementById("moduleToggle1") != null) {
            document.getElementById("moduleToggle1").className = "tan";
            currentId = null;
        }

		if (this.step < 0) return;
		this.step = -1;
		this.removeCurrentItem();	// discard content
		//for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
        this.fx.overlay.start('opacity', 0).chain(this.setup.pass(false, this));
		return false;
	},

	removeCurrentItem: function(){
		if (this.preload){
			if( this.preload.datatype == 'image' ) {
				$('lbImageExCC').dispose();
				this.preload.onload = function () {}; //Class.empty;
			}else{
				$(this.iframeId).dispose();
			}
			this.preload = null;
		}		
	},

	matchOrDefault: function(str, re, val){
		var hasQuery = str.match(re);
		return hasQuery ? hasQuery[1] : val;
	}

};
/*******************Begin******************** Lightbox Popups ********************Begin*******************/

/* Seven Day Forecast popup */
var LightboxExSDF = {
	init: function(options){
		this.options = Object.extend({
			resizeDuration: 400,
			resizeTransition: Fx.Transitions.sineInOut,
			initialWidth: 250,
			initialHeight: 250,
			animateCaption: true,
			defaultIframeWidth : 500, 
			defaultIframeHeight: 300
		}, options || {});

		// IE 6 - XML prolog problem
		if(window.ie6 && document.compatMode=="BackCompat"){
			this.options.animateCaption = false;
		}

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightboxExSDF/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = new Keyboard({
			eventType: 'keydown'			
		});
		this.eventPosition = this.position.bind(this);

        this.overlay = new Element('div', {'id':'lbOverlayExSDF', 'class':'lbOverlayEx'}).injectInside(document.body);
        this.center = new Element('div', {'id':'lbCenterExSDF', 'class':'lbCenterEx'}).setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', marginLeft: '-'+(this.options.initialWidth/2)+'px', display: 'none'}).injectInside(document.body);
		this.canvas = new Element('div', {'id':'lbCanvasExSDF', 'class':'lbCanvasEx'}).injectInside(this.center);

		this.closeBtnTop = new Element('a', {'id':'closeBtnTopSDF', 'href':'#', 'class':'lbCloseBtnTop'}).injectInside(this.canvas);
		this.closeBtnTop.set("html", "Fermer");
		this.closeBtnTop.onclick = this.overlay.onclick = this.close.bind(this);
		
		this.bottomContainer = new Element('div', {'id':'lbBottomContainerPopSDF', 'class':'lbBottomContainerPop', 'styles': {'display':'none'}}).injectInside(document.body);
		this.bottom = new Element('div', {'id':'lbBottomPopSDF', 'class':'lbBottomPop'}).injectInside(this.bottomContainer);
		
		this.navBottom = new Element('div', {'id':'lbNavBottomPopSDF', 'class':'lbNavBottomPop', 'styles': {'width':'597px'}}).injectInside(this.bottom);
		this.navWrapper = new Element('div', {'id':'lbNavWrapperPopSDF', 'class':'lbNavWrapperPop', 'styles': {'width':'589px'}}).injectInside(this.navBottom);
		new Element('div', {'class': 'tlc'}).injectInside(this.navWrapper);
		new Element('div', {'class': 'trc'}).injectInside(this.navWrapper);
		new Element('div').injectInside(this.navWrapper);   // empty div added for IE6
		this.subWrapper = new Element('div', {'id':'lbSubWrapperPopSDF', 'class':'lbSubWrapperPop', 'styles': {'width':'489px'}}).injectInside(this.navWrapper);
		
		this.closeLink = new Element('div', {'id':'lbCloseLinkPopSDF', 'class':'lbCloseLinkPop'}).injectInside(this.navWrapper);
		this.closeLink.onclick = this.overlay.onclick = this.close.bind(this);
		this.closeLink.set("html", "&middot; Fermer")
		
		new Element('div').injectInside(this.navWrapper);   // emtpy div added for IE6
		new Element('div', {'class': 'blc'}).injectInside(this.navWrapper);
		new Element('div', {'class': 'brc'}).injectInside(this.navWrapper);

		new Element('div').setStyle('clear', 'both').injectInside(this.bottom);

		/* Build effects */
		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
            overlay: new Fx.Tween(this.overlay, {property: 'opacity', duration: 500}).start(0),
            resizeCenter: this.center.set('morph', {duration: this.options.resizeDuration, transition: this.options.resizeTransition, onComplete: nextEffect}),
            image: this.canvas.set('tween',  { duration: 500, onComplete: nextEffect })/*,
            bottom: new Fx.Tween(this.bottomContainer, {property: 'height', duration: 400, onComplete: nextEffect })*/
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title, link.rev);

		var j, itemNumber, items = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < items.length; j++) if(items[j][0] == el.href && items[j][2] == el.rev) break;
				if (j == items.length){
					items.push([el.href, el.title, el.rev]);
					if (el.href == link.href && el.rev == link.rev) itemNumber = j;
				}
			}
		}, this);
		return this.open(items, itemNumber);
	},

	show: function(url, title, rev){
		return this.open([[url, title, rev]], 0);
	},

	open: function(items, itemNumber){
		this.items = items;
		this.position();
		this.setup(true);
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.top = window.getScrollTop();
		scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});
		this.fx.overlay.start('0.4');
		return this.changeItem(itemNumber);
	},

	position: function(){
		//IE6 - XML prolog problem.
		var ww = (window.getWidth() == 0) ? window.getScrollWidth()-22 : window.getWidth();
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.overlay.setStyles({top: st+'px', height: wh+'px', width:ww+'px'});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		if (window.ie) elements.extend(document.getElementsByTagName('select'));
		elements.each(function(el){ el.style.visibility = open ? 'hidden' : ''; });
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeItem(this.activeItem-1);
	},

	next: function(){
		return this.changeItem(this.activeItem+1);
	},

	changeItem: function(itemNumber){
		if (this.step || (itemNumber < 0) || (itemNumber >= this.items.length)) return false;
		this.step = 1;
		this.activeItem = itemNumber;
		
		this.top = window.getScrollTop();
        scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});

		//this.bottomContainer.style.display = 'none';
		//this.prevLink.style.display = this.nextLink.style.display = 'none';
		this.fx.image.fade('hide');
		//this.center.className = 'lbLoadingExHag';

		// discard previous content by clicking
		this.removeCurrentItem();
		
		// check item type
		var url = this.items[this.activeItem][0];
		var rev = this.items[this.activeItem][2];
		
		var re_imageURL = /\.(jpe?g|png|gif|bmp)/i;
		if( url.match(re_imageURL) ) {
			this.preload = new Image();	// JavaScript native Object
			this.preload.datatype = 'image';
			this.preload.w = this.matchOrDefault(rev, new RegExp("width=(\\d+%?)", "i"), -1); //-1 if use original size.
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+%?)", "i"), -1);
			this.preload.onload = this.nextEffect.bind(this);
			this.preload.src = url;
		}else{
			this.preload = new Object ();	// JavaScript native Object
			this.preload.datatype = 'iframe';
			this.preload.w =  this.matchOrDefault(rev, new RegExp("width=(\\d+)", "i"), this.options.defaultIframeWidth);
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+)", "i"), this.options.defaultIframeHeight);
			this.preload.src = url;
			this.nextEffect(); //asynchronous loading
		}

		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			//this.center.className = '';

			// create HTML element
			if( this.preload.datatype == 'image' ) {
				var ws = (this.preload.w == -1) ? this.preload.width.toString() : this.preload.w.toString();
				var hs = (this.preload.h == -1) ? this.preload.height.toString() : this.preload.h.toString();
				this.p_width = ( q = ws.match(/(\d+)%/) ) ? q[1] * this.preload.width * 0.01 : ws;
				this.p_height = ( q = hs.match(/(\d+)%/) ) ? q[1] * this.preload.height * 0.01 : hs;
				new Element('img').setProperties({id: 'lbImageExSDF', src:this.preload.src, width:this.p_width, height:this.p_height}).injectInside(this.canvas);
				//this.nextLink.style.right = '';
			}else{
				this.p_width = this.preload.w;
				this.p_height = this.preload.h;
				// Safari would not update iframe content that has static id.
				this.iframeId = "lbFrame_"+new Date().getTime();
				//new Element('iframe').setProperties({id: this.iframeId, width: this.p_width, height: this.p_height, frameBorder:0, scrolling:'no', src:this.preload.src}).injectInside(this.canvas);
				this.iframe = new Element('iframe', {'id':this.iframeId, 'class':'ifsdf', 'src':this.preload.src, 'scrolling':'no', 'frameBorder':'0'}).injectInside(this.canvas);
				//, 'styles':{'width':'597px', 'height':'253px'}
				//this.nextLink.style.right = '25px';
			}
			this.canvas.style.width = this.p_width+'px';
			this.canvas.style.height = this.p_height+'px';
			//this.prevLink.style.height = this.nextLink.style.height = this.p_height+'px';

			//this.caption.set("html", this.items[this.activeItem][1] || '');
			//this.number.set("html",  (this.items.length == 1) ? '' : 'Page ' + (this.activeItem+1) + ' sur ' + this.items.length );

			if (this.activeItem) this.preloadPrev.src = this.items[this.activeItem-1][0];
			if (this.activeItem != (this.items.length - 1)) this.preloadNext.src = this.items[this.activeItem+1][0];
			if (this.center.clientHeight != this.canvas.offsetHeight){
				var oh = (this.p_height == this.canvas.clientHeight) ? this.canvas.offsetHeight : eval(this.p_height);
				this.fx.resizeCenter.morph({'height': oh});
				break;
			}

			this.step++;
		case 2:
			if (this.center.clientWidth != this.canvas.offsetWidth){
				var ow = (this.p_width == this.canvas.clientWidth) ? this.canvas.offsetWidth : eval(this.p_width)+18; // fix for ie
				this.fx.resizeCenter.morph({'width': ow, 'marginLeft': -ow/2});
				break;
			}
			this.step++;
		case 3:
			//this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', height:'0px', marginLeft: this.center.style.marginLeft, width:this.center.style.width, display: ''});
			this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', marginLeft: this.center.style.marginLeft, width:this.center.style.width, display: ''});
			this.fx.image.fade('1');
			break;
		case 4:
			if (this.options.animateCaption){
				// This is not smooth animation in IE 6 with XML prolog.
				// If your site is XHTML strict with XML prolog, disable this option.
				//this.fx.bottom.start(0,this.bottom.offsetHeight+10);
				break;
			}
			//this.bottomContainer.style.height = (this.bottom.offsetHeight+10)+'px';
		case 5:
			if (this.activeItem){
				//this.prevLink.style.display = '';
			}
			if (this.activeItem != (this.items.length - 1)){
				//this.nextLink.style.display = '';
			}
			this.step = 0;
		}
	},

	close: function(){
        if (document.getElementById("moduleToggle1") != null) {
            document.getElementById("moduleToggle1").className = "tan";
            currentId = null;
        }

		if (this.step < 0) return;
		this.step = -1;
		this.removeCurrentItem();	// discard content
		//for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
        this.fx.overlay.start('opacity', 0).chain(this.setup.pass(false, this));
		return false;
	},

	removeCurrentItem: function(){
		if (this.preload){
			if( this.preload.datatype == 'image' ) {
				$('lbImageExSDF').dispose();
				this.preload.onload = function () {}; //Class.empty;
			}else{
				$(this.iframeId).dispose();
			}
			this.preload = null;
		}		
	},

	matchOrDefault: function(str, re, val){
		var hasQuery = str.match(re);
		return hasQuery ? hasQuery[1] : val;
	}

};

/* Hotel at a Glance popup */
var LightboxExHag = {
	init: function(options){
		this.options = Object.extend({
			resizeDuration: 400,
			resizeTransition: Fx.Transitions.sineInOut,
			initialWidth: 250,
			initialHeight: 250,
			animateCaption: true,
			defaultIframeWidth : 500, 
			defaultIframeHeight: 300
		}, options || {});

		// IE 6 - XML prolog problem
		if(window.ie6 && document.compatMode=="BackCompat"){
			this.options.animateCaption = false;
		}

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightboxExHag/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = new Keyboard({
			eventType: 'keydown'			
		});
		this.eventPosition = this.position.bind(this);

		/*	Build float panel
			<div id="lbOverlay"></div>
			<div id="lbCenter">
				<div id="lbCanvas">
					<a id="lbPrevLink"></a>
					<a id="lbNextLink"></a>
					<!-- img or iframe element is inserted here -->
				</div>
			</div>
			<div id="lbBottomContainer">
				<div id="lbBottom">
					<a id="lbCloseLink"></a>
					<div id="lbCaption"></div>
					<div id="lbNumber"></div>
					<div style="clear:both;"></div>
				</div>
			</div>
		*/

		this.overlay = new Element('div').setProperty('id', 'lbOverlayExHag').injectInside(document.body);

		this.center = new Element('div').setProperty('id', 'lbCenterExHag').setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', marginLeft: '-'+(this.options.initialWidth/2)+'px', display: 'none'}).injectInside(document.body);
		this.canvas = new Element('div').setProperty('id', 'lbCanvasExHag').injectInside(this.center);
		
		this.closeBtnTop = new Element('a').setProperties({id: 'closeBtnTop', href: '#'}).injectInside(this.canvas);
		this.closeBtnTop.set("html", "Fermer");
		this.closeBtnTop.onclick = this.overlay.onclick = this.close.bind(this);
		
		this.prevLink = new Element('a').setProperties({id: 'lbPrevLinkExHag', href: '#'}).setStyle('display', 'none').injectInside(this.canvas);
		this.nextLink = this.prevLink.clone().setProperty('id', 'lbNextLinkExHag').injectInside(this.canvas);
		this.prevLink.onclick = this.previous.bind(this);
		this.nextLink.onclick = this.next.bind(this);
		
                                this.bottomContainer = new Element('div').setProperty('id', 'lbBottomContainerExHag').setStyle('display', 'none').injectInside(document.body);
		this.bottom = new Element('div').setProperty('id', 'lbBottomExHag').injectInside(this.bottomContainer);

                                this.printLinkP = new Element('p').setProperty('id', 'lbPrintLinkExHag').injectInside(this.bottom);
                                this.printLink = new Element('a').setProperties({id: '', href: 'javascript:printWindow();'}).injectInside(this.printLinkP);
                                this.printLink.set("html", "&middot; Imprimer cette page");
                                
                                this.eBLinkP = new Element('p').setProperty('id', 'lbeBLinkExHag').injectInside(this.bottom);
		this.eBLink = new Element('a').setProperties({id: '', href: 'images/molas_ebook.pdf', target: '_blank'}).injectInside(this.eBLinkP);
		this.eBLink.set("html", "&middot; Télécharger la brochure électronique");
		
                                this.closeLink = new Element('p').setProperties({id: 'lbCloseLinkExHag', href: '#'}).injectInside(this.bottom);
		this.closeLink.onclick = this.overlay.onclick = this.close.bind(this);
		this.closeLink.set("html", "&middot; Fermer");

		//this.caption = new Element('div').setProperty('id', 'lbCaptionEx').injectInside(this.bottom);
		//this.number = new Element('div').setProperty('id', 'lbNumberEx').injectInside(this.bottom);
		new Element('div').setStyle('clear', 'both').injectInside(this.bottom);

		/* Build effects */
		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
            overlay: new Fx.Tween(this.overlay, {property: 'opacity', duration: 500}).start(0),
            resizeCenter: this.center.set('morph', {duration: this.options.resizeDuration, transition: this.options.resizeTransition, onComplete: nextEffect}),
            image: this.canvas.set('tween',  { duration: 500, onComplete: nextEffect }),
            bottom: new Fx.Tween(this.bottomContainer, {property: 'height', duration: 400, onComplete: nextEffect })
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title, link.rev);

		var j, itemNumber, items = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < items.length; j++) if(items[j][0] == el.href && items[j][2] == el.rev) break;
				if (j == items.length){
					items.push([el.href, el.title, el.rev]);
					if (el.href == link.href && el.rev == link.rev) itemNumber = j;
				}
			}
		}, this);
		return this.open(items, itemNumber);
	},

	show: function(url, title, rev){
		return this.open([[url, title, rev]], 0);
	},

	open: function(items, itemNumber){
		this.items = items;
		this.position();
		this.setup(true);
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.top = window.getScrollTop();
		scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});
		this.fx.overlay.start('0.4');
		return this.changeItem(itemNumber);
	},

	position: function(){
		//IE6 - XML prolog problem.
		var ww = (window.getWidth() == 0) ? window.getScrollWidth()-22 : window.getWidth();
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.overlay.setStyles({top: st+'px', height: wh+'px', width:ww+'px'});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		if (window.ie) elements.extend(document.getElementsByTagName('select'));
		elements.each(function(el){ el.style.visibility = open ? 'hidden' : ''; });
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeItem(this.activeItem-1);
	},

	next: function(){
		return this.changeItem(this.activeItem+1);
	},

	changeItem: function(itemNumber){
		if (this.step || (itemNumber < 0) || (itemNumber >= this.items.length)) return false;
		this.step = 1;
		this.activeItem = itemNumber;
		
		this.top = window.getScrollTop();
        scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});

		this.bottomContainer.style.display = this.prevLink.style.display = this.nextLink.style.display = 'none';
		this.fx.image.fade('hide');
		this.center.className = 'lbLoadingExHag';

		// discard previous content by clicking
		this.removeCurrentItem();
		
		// check item type
		var url = this.items[this.activeItem][0];
		var rev = this.items[this.activeItem][2];
		
		var re_imageURL = /\.(jpe?g|png|gif|bmp)/i;
		if( url.match(re_imageURL) ) {
			this.preload = new Image();	// JavaScript native Object
			this.preload.datatype = 'image';
			this.preload.w = this.matchOrDefault(rev, new RegExp("width=(\\d+%?)", "i"), -1); //-1 if use original size.
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+%?)", "i"), -1);
			this.preload.onload = this.nextEffect.bind(this);
			this.preload.src = url;
		}else{
			this.preload = new Object ();	// JavaScript native Object
			this.preload.datatype = 'iframe';
			this.preload.w =  this.matchOrDefault(rev, new RegExp("width=(\\d+)", "i"), this.options.defaultIframeWidth);
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+)", "i"), this.options.defaultIframeHeight);
			// act right FF! // add height of bottom bar
			var ffVar = parseInt(this.preload.h) + 80;
			this.preload.h = (navigator.userAgent.indexOf("Firefox")!=-1)? ffVar : this.preload.h;

			this.preload.src = url;
			this.nextEffect(); //asynchronous loading
		}

		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			this.center.className = '';

			// create HTML element
			if( this.preload.datatype == 'image' ) {
				var ws = (this.preload.w == -1) ? this.preload.width.toString() : this.preload.w.toString();
				var hs = (this.preload.h == -1) ? this.preload.height.toString() : this.preload.h.toString();
				this.p_width = ( q = ws.match(/(\d+)%/) ) ? q[1] * this.preload.width * 0.01 : ws;
				this.p_height = ( q = hs.match(/(\d+)%/) ) ? q[1] * this.preload.height * 0.01 : hs;
				new Element('img').setProperties({id: 'lbImageExHag', src:this.preload.src, width:this.p_width, height:this.p_height}).injectInside(this.canvas);
				this.nextLink.style.right = '';
			}else{
				this.p_width = this.preload.w;
				this.p_height = this.preload.h;
				// Safari would not update iframe content that has static id.
				this.iframeId = "lbFrame_"+new Date().getTime();
				new Element('iframe').setProperties({id: this.iframeId, width: this.p_width, height: this.p_height, frameBorder:0, scrolling:'no', src:this.preload.src}).injectInside(this.canvas);
				this.nextLink.style.right = '25px';
			}
			this.canvas.style.width = this.p_width+'px';
			this.canvas.style.height = this.prevLink.style.height = this.nextLink.style.height = this.p_height+'px';

			//this.caption.set("html", this.items[this.activeItem][1] || '');
			//this.number.set("html",  (this.items.length == 1) ? '' : 'Page ' + (this.activeItem+1) + ' sur ' + this.items.length );

			if (this.activeItem) this.preloadPrev.src = this.items[this.activeItem-1][0];
			if (this.activeItem != (this.items.length - 1)) this.preloadNext.src = this.items[this.activeItem+1][0];
			if (this.center.clientHeight != this.canvas.offsetHeight){
				var oh = (this.p_height == this.canvas.clientHeight) ? this.canvas.offsetHeight : eval(this.p_height)+18; // fix for ie
				this.fx.resizeCenter.morph({'height': oh});
				break;
			}

			this.step++;
		case 2:
			if (this.center.clientWidth != this.canvas.offsetWidth){
				var ow = (this.p_width == this.canvas.clientWidth) ? this.canvas.offsetWidth : eval(this.p_width)+18; // fix for ie
				this.fx.resizeCenter.morph({'width': ow, 'marginLeft': -ow/2});
				break;
			}
			this.step++;
		case 3:
			this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', height:'0px', marginLeft: this.center.style.marginLeft, width:this.center.style.width, display: ''});
			this.fx.image.fade('1');
			break;
		case 4:
			if (this.options.animateCaption){
				// This is not smooth animation in IE 6 with XML prolog.
				// If your site is XHTML strict with XML prolog, disable this option.
				this.fx.bottom.start(0,this.bottom.offsetHeight+10);
				break;
			}
			this.bottomContainer.style.height = (this.bottom.offsetHeight+10)+'px';
		case 5:
			if (this.activeItem){
				this.prevLink.style.display = '';
			}
			if (this.activeItem != (this.items.length - 1)){
				this.nextLink.style.display = '';
			}
			this.step = 0;
		}
	},

	close: function(){
                            if (document.getElementById("moduleToggle1") != null) {
                                document.getElementById("moduleToggle1").className = "tan";
                                currentId = null;
                            }

		if (this.step < 0) return;
		this.step = -1;
		this.removeCurrentItem();	// discard content
		//for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
        this.fx.overlay.start('opacity', 0).chain(this.setup.pass(false, this));
		return false;
	},

	removeCurrentItem: function(){
		if (this.preload){
			if( this.preload.datatype == 'image' ) {
				$('lbImageExHag').dispose();
				this.preload.onload = function () {}; //Class.empty;
			}else{
				$(this.iframeId).dispose();
			}
			this.preload = null;
		}		
	},

	matchOrDefault: function(str, re, val){
		var hasQuery = str.match(re);
		return hasQuery ? hasQuery[1] : val;
	}

};
/* Interactive and Location Map popups */
var LightboxExMap = {
	init: function(options){
		this.options = Object.extend({
			resizeDuration: 400,
			resizeTransition: Fx.Transitions.sineInOut,
			initialWidth: 250,
			initialHeight: 250,
			animateCaption: true,
			defaultIframeWidth : 500, 
			defaultIframeHeight: 300
		}, options || {});

		// IE 6 - XML prolog problem
		if(window.ie6 && document.compatMode=="BackCompat"){
			this.options.animateCaption = false;
		}

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightboxExMap/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = new Keyboard({
			eventType: 'keydown'			
		});
		this.eventPosition = this.position.bind(this);

		/*	Build float panel
			<div id="lbOverlay"></div>
			<div id="lbCenter">
				<div id="lbCanvas">
					<a id="lbPrevLink"></a>
					<a id="lbNextLink"></a>
					<!-- img or iframe element is inserted here -->
				</div>
			</div>
			<div id="lbBottomContainer">
				<div id="lbBottom">
					<a id="lbCloseLink"></a>
					<div id="lbCaption"></div>
					<div id="lbNumber"></div>
					<div style="clear:both;"></div>
				</div>
			</div>
		*/

		this.overlay = new Element('div').setProperty('id', 'lbOverlayExMap').injectInside(document.body);

		this.center = new Element('div').setProperty('id', 'lbCenterExMap').setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', marginLeft: '-'+(this.options.initialWidth/2)+'px', display: 'none'}).injectInside(document.body);
		this.canvas = new Element('div').setProperty('id', 'lbCanvasExMap').injectInside(this.center);
		
		this.closeBtnTop = new Element('div').setProperty('id', 'closeBtnTopMap').injectInside(this.canvas);
		this.closeBtnTop.set("html", "Fermer");
		this.closeBtnTop.onclick = this.overlay.onclick = this.close.bind(this);
		
		//this.prevLink = new Element('a').setProperties({id: 'lbPrevLinkExMap', href: '#'}).setStyle('display', 'none').injectInside(this.canvas);
		//this.nextLink = this.prevLink.clone().setProperty('id', 'lbNextLinkExMap').injectInside(this.canvas);
		//this.prevLink.onclick = this.previous.bind(this);
		//this.nextLink.onclick = this.next.bind(this);

		this.bottomContainer = new Element('div').setProperty('id', 'lbBottomContainerExMap').setStyle('display', 'none').injectInside(document.body);
		this.bottom = new Element('div').setProperty('id', 'lbBottomExMap').injectInside(this.bottomContainer);
		this.otherLink = new Element('p').setProperty('id', 'lbOtherLinkExMap').injectInside(this.bottom);
                                this.printLink = new Element('p').setProperties({id: 'lbPrintLinkExMap'}).injectInside(this.bottom);
                                this.printLinkA = new Element('a').setProperties({href: 'javascript:printWindow();'}).injectInside(this.printLink);
                                this.printLinkA.set("html", "&middot; Imprimer cette page");
		this.eMailLink = new Element('p').setProperty('id', 'lbeMailLinkExMap').injectInside(this.bottom);
                                this.eMailLinkA = new Element('a').setProperties({href: "#", onclick: "javascript:window.open('/emailToFriend.aspx?s='+location.host+'&p='+location.pathname, 'emailPage', 'top=0,left=0,width=510,height=530,scrollbars=yes,resizable=yes');"}).injectInside(this.eMailLink);
		this.eMailLinkA.set("html", "&middot; Envoyer à un ami");
		this.closeLink = new Element('p').setProperties({id: 'lbCloseLinkExMap'}).injectInside(this.bottom);
		this.closeLink.onclick = this.overlay.onclick = this.close.bind(this);
		this.closeLink.set("html", "&middot; Fermer");
		//this.caption = new Element('div').setProperty('id', 'lbCaptionEx').injectInside(this.bottom);
		//this.number = new Element('div').setProperty('id', 'lbNumberEx').injectInside(this.bottom);
		new Element('div').setStyle('clear', 'both').injectInside(this.bottom);

		/* Build effects */
		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
            overlay: new Fx.Tween(this.overlay, {property: 'opacity', duration: 500}).start(0),
            resizeCenter: this.center.set('morph', {duration: this.options.resizeDuration, transition: this.options.resizeTransition, onComplete: nextEffect}),
            image: this.canvas.set('tween',  { duration: 500, onComplete: nextEffect }),
            bottom: new Fx.Tween(this.bottomContainer, {property: 'height', duration: 400, onComplete: nextEffect })
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title, link.rev);

		var j, itemNumber, items = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < items.length; j++) if(items[j][0] == el.href && items[j][2] == el.rev) break;
				if (j == items.length){
					items.push([el.href, el.title, el.rev]);
					if (el.href == link.href && el.rev == link.rev) itemNumber = j;
				}
			}
		}, this);
		return this.open(items, itemNumber);
	},

	show: function(url, title, rev){
		return this.open([[url, title, rev]], 0);
	},

	open: function(items, itemNumber){
                    if (items[0][0].indexOf("interactive_map.aspx") > -1) {
                        setMapNavText(1);
                    } else {
                        setMapNavText(2);
                    }
		this.items = items;
		this.position();
		this.setup(true);
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.top = window.getScrollTop();
		scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});
		this.fx.overlay.start('0.4');
		return this.changeItem(itemNumber);
	},

	position: function(){
		//IE6 - XML prolog problem.
		var ww = (window.getWidth() == 0) ? window.getScrollWidth()-22 : window.getWidth();
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.overlay.setStyles({top: st+'px', height: wh+'px', width:ww+'px'});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		if (window.ie) elements.extend(document.getElementsByTagName('select'));
		elements.each(function(el){ el.style.visibility = open ? 'hidden' : ''; });
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeItem(this.activeItem-1);
	},

	next: function(){
		return this.changeItem(this.activeItem+1);
	},

	changeItem: function(itemNumber){
		if (this.step || (itemNumber < 0) || (itemNumber >= this.items.length)) return false;
		this.step = 1;
		this.activeItem = itemNumber;
		
		this.top = window.getScrollTop();
        scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});

		this.bottomContainer.style.display = 'none';
                                //this.prevLink.style.display = this.nextLink.style.display =
		this.fx.image.fade('hide');
		this.center.className = 'lbLoadingExMap';

		// discard previous content by clicking
		this.removeCurrentItem();
		
		// check item type
		var url = this.items[this.activeItem][0];
		var rev = this.items[this.activeItem][2];
		
		var re_imageURL = /\.(jpe?g|png|gif|bmp)/i;
		if( url.match(re_imageURL) ) {
			this.preload = new Image();	// JavaScript native Object
			this.preload.datatype = 'image';
			this.preload.w = this.matchOrDefault(rev, new RegExp("width=(\\d+%?)", "i"), -1); //-1 if use original size.
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+%?)", "i"), -1);
			this.preload.onload = this.nextEffect.bind(this);
			this.preload.src = url;
		}else{
			this.preload = new Object ();	// JavaScript native Object
			this.preload.datatype = 'iframe';
			this.preload.w =  this.matchOrDefault(rev, new RegExp("width=(\\d+)", "i"), this.options.defaultIframeWidth);
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+)", "i"), this.options.defaultIframeHeight);
			this.preload.src = url;
			this.nextEffect(); //asynchronous loading
		}

		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			this.center.className = '';

			// create HTML element
			if( this.preload.datatype == 'image' ) {
				var ws = (this.preload.w == -1) ? this.preload.width.toString() : this.preload.w.toString();
				var hs = (this.preload.h == -1) ? this.preload.height.toString() : this.preload.h.toString();
				this.p_width = ( q = ws.match(/(\d+)%/) ) ? q[1] * this.preload.width * 0.01 : ws;
				this.p_height = ( q = hs.match(/(\d+)%/) ) ? q[1] * this.preload.height * 0.01 : hs;
				new Element('img').setProperties({id: 'lbImageExMap', src:this.preload.src, width:this.p_width, height:this.p_height}).injectInside(this.canvas);
				//this.nextLink.style.right = '';
			}else{
				this.p_width = this.preload.w;
				this.p_height = this.preload.h;
				// Safari would not update iframe content that has static id.
				this.iframeId = "lbFrame_"+new Date().getTime();
				new Element('iframe').setProperties({id: this.iframeId, name: 'iframe', width: this.p_width, height: this.p_height, frameBorder:0, scrolling:'yes', src:this.preload.src}).injectInside(this.canvas);
				//this.nextLink.style.right = '25px';
			}
			this.canvas.style.width = this.p_width+'px';
			this.canvas.style.height = this.p_height+'px';
                                                //this.prevLink.style.height = this.nextLink.style.height = 

			//this.caption.set("html", this.items[this.activeItem][1] || '');
			//this.number.set("html",  (this.items.length == 1) ? '' : 'Page ' + (this.activeItem+1) + ' sur ' + this.items.length );

			if (this.activeItem) this.preloadPrev.src = this.items[this.activeItem-1][0];
			if (this.activeItem != (this.items.length - 1)) this.preloadNext.src = this.items[this.activeItem+1][0];
			if (this.center.clientHeight != this.canvas.offsetHeight){
				var oh = (this.p_height == this.canvas.clientHeight) ? this.canvas.offsetHeight : eval(this.p_height)+18; // fix for ie
				this.fx.resizeCenter.morph({'height': oh});
				break;
			}

			this.step++;
		case 2:
			if (this.center.clientWidth != this.canvas.offsetWidth){
				var ow = (this.p_width == this.canvas.clientWidth) ? this.canvas.offsetWidth : eval(this.p_width)+18; // fix for ie
				this.fx.resizeCenter.morph({'width': ow, 'marginLeft': -ow/2});
				break;
			}
			this.step++;
		case 3:
			this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', height:'0px', marginLeft: this.center.style.marginLeft, width:this.center.style.width, display: ''});
			this.fx.image.fade('1');
			break;
		case 4:
			if (this.options.animateCaption){
				// This is not smooth animation in IE 6 with XML prolog.
				// If your site is XHTML strict with XML prolog, disable this option.
				this.fx.bottom.start(0,this.bottom.offsetHeight+10);
				break;
			}
			this.bottomContainer.style.height = (this.bottom.offsetHeight+10)+'px';
		case 5:
			if (this.activeItem){
				//this.prevLink.style.display = '';
			}
			if (this.activeItem != (this.items.length - 1)){
				//this.nextLink.style.display = '';
			}
			this.step = 0;
		}
	},

	close: function(){
                               if (document.getElementById("moduleToggle3") != null) {
                                   document.getElementById("moduleToggle3").className = "tan";
                                   currentId = null;
                               }

		if (this.step < 0) return;
		this.step = -1;
		this.removeCurrentItem();	// discard content
		//for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
        this.fx.overlay.start('opacity', 0).chain(this.setup.pass(false, this));
		return false;
	},

	removeCurrentItem: function(){
		if (this.preload){
			if( this.preload.datatype == 'image' ) {
				$('lbImageExMap').dispose();
				this.preload.onload = function () {}; //Class.empty;
			}else{
				$(this.iframeId).dispose();
			}
			this.preload = null;
		}		
	},

	matchOrDefault: function(str, re, val){
		var hasQuery = str.match(re);
		return hasQuery ? hasQuery[1] : val;
	}

};

/* Image Popups */
var LightboxPop = {

	init: function(options){
		this.options = $extend({
			resizeDuration: 400,
			resizeTransition: false,	// default transition
			initialWidth: 25,
			initialHeight: 25,
			animateCaption: true,
			showCounter: true
		}, options || {});

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightboxPop/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = new Keyboard({
			eventType: 'keydown'			
		});
		this.eventPosition = this.position.bind(this);

		this.overlay = new Element('div', {'id': 'lbOverlayPop'}).injectInside(document.body);

		this.center = new Element('div', {'id': 'lbCenterPop', 'styles': {'width': this.options.initialWidth, 'height': this.options.initialHeight, 'marginLeft': -(this.options.initialWidth/2), 'display': 'none'}}).injectInside(document.body);
		
		this.closeBtnTop = new Element('a').setProperties({id: 'closeBtnTopPopImg', href: '#'}).injectInside(this.center);
		this.closeBtnTop.set("html", "Fermer");
		this.closeBtnTop.onclick = this.overlay.onclick = this.close.bind(this);
		
		this.image = new Element('div', {'id': 'lbImagePop'}).injectInside(this.center);
		
		this.bottomContainer = new Element('div', {'id': 'lbBottomContainerPop', 'styles': {'display': 'none'}}).injectInside(document.body);
		this.bottom = new Element('div', {'id': 'lbBottomPop'}).injectInside(this.bottomContainer);
                                this.caption = new Element('div', {'id': 'lbCaptionPop'}).injectInside(this.bottom);		
                                this.navBottom = new Element('div', {'id': 'lbNavBottomPop'}).injectInside(this.bottom);
		this.navWrapper = new Element('div', {'id': 'lbNavWrapperPop'}).injectInside(this.navBottom);
		new Element('div', {'class': 'tlc'}).injectInside(this.navWrapper);
		new Element('div', {'class': 'trc'}).injectInside(this.navWrapper);
		new Element('div').injectInside(this.navWrapper);   // empty div added for IE6
		this.subWrapper = new Element('div', {'id': 'lbSubWrapperPop'}).injectInside(this.navWrapper);
		this.prevLink = new Element('p', {'id': 'lbPrevLinkPop'}).injectInside(this.subWrapper);
		this.number = new Element('p', {'id': 'lbNumberPop'}).injectInside(this.subWrapper);
		this.nextLink = this.prevLink.clone().setProperty('id', 'lbNextLinkPop').injectInside(this.subWrapper);
		this.prevLink.onclick = this.previous.bind(this);
		this.nextLink.onclick = this.next.bind(this);
                                this.prevLink.set("html", '<< Précédent');
		this.nextLink.set("html", 'Suivant >>');
		
		this.closeLink = new Element('div', {'id': 'lbCloseLinkPop'}).injectInside(this.navWrapper);
		this.closeLink.onclick = this.overlay.onclick = this.close.bind(this);
		this.closeLink.set("html", "&middot; Fermer")
		
		new Element('div').injectInside(this.navWrapper);   // emtpy div added for IE6
		new Element('div', {'class': 'blc'}).injectInside(this.navWrapper);
		new Element('div', {'class': 'brc'}).injectInside(this.navWrapper);
		
		//new Element('div', {'styles': {'clear': 'both'}}).injectInside(this.bottom);

		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
            overlay: new Fx.Tween(this.overlay, {property: 'opacity', duration: 500}).start(0),
            resize: this.center.set('morph', $extend({duration: this.options.resizeDuration, onComplete: nextEffect}, this.options.resizeTransition ? {transition: this.options.resizeTransition} : {})),
            image: this.image.set('tween',  { duration: 500, onComplete: nextEffect }),
            bottom: new Fx.Tween(this.bottom, {property: 'marginTop', duration: 400, onComplete: nextEffect })
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title);

		var j, imageNum, images = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < images.length; j++) if(images[j][0] == el.href) break;
				if (j == images.length){
					images.push([el.href, el.title]);
					if (el.href == link.href) imageNum = j;
				}
			}
		}, this);
		return this.open(images, imageNum);
	},

	show: function(url, title){
		return this.open([[url, title]], 0);
	},

	open: function(images, imageNum){
		this.images = images;
		this.position();
		this.setup(true);
		this.top = window.getScrollTop();
		scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});
		this.fx.overlay.start('0.4');
		return this.changeImage(imageNum);
	},

	position: function(){
		this.overlay.setStyles({'top': window.getScrollTop(), 'height': window.getHeight()});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		elements.extend(document.getElementsByTagName(window.ie ? 'select' : 'embed'));
		elements.each(function(el){
			if (open) el.lbBackupStyle = el.style.visibility;
			el.style.visibility = open ? 'hidden' : el.lbBackupStyle;
		});
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeImage(this.activeImage-1);
	},

	next: function(){
		return this.changeImage(this.activeImage+1);
	},

	changeImage: function(imageNum){
		if (this.step || (imageNum < 0) || (imageNum >= this.images.length)) return false;
		this.step = 1;
		this.activeImage = imageNum;
		
		this.top = window.getScrollTop();
                                scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});

		//this.bottomContainer.style.display = this.prevLink.style.display = this.nextLink.style.display = 'none';
		this.bottomContainer.style.display = 'none';
		this.prevLink.style.visibility = this.nextLink.style.visibility = 'hidden';
		this.fx.image.fade('hide');
		this.center.className = 'lbLoadingPop';

		this.preload = new Image();
		this.preload.onload = this.nextEffect.bind(this);
		this.preload.src = this.images[imageNum][0];
		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			this.center.className = '';
			this.image.style.backgroundImage = 'url('+this.images[this.activeImage][0]+')';
			this.image.style.width = this.bottom.style.width = this.preload.width+'px';
			this.navBottom.style.width = this.preload.width+'px';
			this.navWrapper.style.width = this.preload.width-12+'px';   // -12 to account for border and padding
			this.subWrapper.style.width = this.preload.width-112+'px';
			//this.image.style.height = this.prevLink.style.height = this.nextLink.style.height = this.preload.height+'px';
                                                this.image.style.height = this.preload.height+'px';
			//this.caption.set("html", this.images[this.activeImage][1] || '');
                                                if (this.images[this.activeImage][1] != "") {
			    this.caption.style.visibility = "visible";
			    this.caption.style.display = "block";
			    this.caption.style.width = this.preload.width-10+'px';  // -10 to account for left-padding
			    this.caption.set("html", this.images[this.activeImage][1] || '');
			} else {
			    this.caption.style.visibility = "hidden";
			    this.caption.style.display = "none";
			}
			this.number.set("html", (!this.options.showCounter || (this.images.length == 1)) ? '' : (this.activeImage+1)+' sur '+this.images.length);

			if (this.activeImage) this.preloadPrev.src = this.images[this.activeImage-1][0];
			if (this.activeImage != (this.images.length - 1)) this.preloadNext.src = this.images[this.activeImage+1][0];
			if (this.center.clientHeight != this.image.offsetHeight){
				this.fx.resize.morph({'height': this.image.offsetHeight});
				break;
			}
			this.step++;
		case 2:
			if (this.center.clientWidth != this.image.offsetWidth){
				this.fx.resize.morph({'width': this.image.offsetWidth+18, 'marginLeft': -this.image.offsetWidth/2});    // added 18 pixels to width to account for margin and border around the image
				break;
			}
			this.step++;
		case 3:
			this.bottomContainer.setStyles({top: this.top + this.center.clientHeight, height: 0, marginLeft: this.center.style.marginLeft, display: ''});
			this.fx.image.fade('1');
			break;
		case 4:
			if (this.options.animateCaption){
				this.fx.bottom.set(-this.bottom.offsetHeight);
				this.bottomContainer.style.height = '';
				this.fx.bottom.start(0);
				break;
			}
			this.bottomContainer.style.height = '';
		case 5:
			if (this.activeImage) /*this.prevLink.style.display = '';*/ this.prevLink.style.visibility = 'visible';
			if (this.activeImage != (this.images.length - 1)) /*this.nextLink.style.display = '';*/ this.nextLink.style.visibility = 'visible';
			this.step = 0;
		}
	},

	close: function(){
		if (this.step < 0) return;
		this.step = -1;
		if (this.preload){
			this.preload.onload = function () {}; //Class.empty;
			this.preload = null;
		}
		//for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
        this.fx.overlay.start('opacity', 0).chain(this.setup.pass(false, this));
		return false;
	}
};

/* Gallery Popup */
var MooRevolver = new Class({
	initialize: function(element, options){
		this.setOptions({
			"pad":80,
			"border":0,
			"yRadius":10,
			"arrowLeft":null,
			"arrowRight":null,
			"fxDuration": 500,
			"fxTransition": Fx.Transitions.Sine.easeInOut,
			"fade":false
		}, options);
				
		if($(element)){
		
			if($(this.options.arrowLeft)) {
				$(this.options.arrowLeft).addEvent("click", (function(e){
					new Event(e).stop();
					this.getPrevious();
				}).bind(this));
			}
				
			if($(this.options.arrowRight)) {
				$(this.options.arrowRight).addEvent("click", (function(e){
					new Event(e).stop();
					this.getNext();
				}).bind(this));
			}
			
			this.processing = false;
			this.containerSize = $(element).getSize();
			this.xRadius = (this.containerSize.x / 2) - this.options.pad;
			this.yRadius = this.options.yRadius;
			this.centerX = (this.containerSize.x / 2);
			this.centerY = 35;
						
			this.items = $(element).getChildren();
			this.totalItems = this.items.length;
			
			this.points = [];
			this.positions = [];
			this.sizes = [];
			this.zIndexes = [];
			this.opacities = [];
						
			for(var i = 0; i < this.totalItems; i++){
				this.points.push(i * (360 / this.totalItems));
				var pt = this.getElipticalPoint(this.points[i]);
				
				this.items[i].setStyles({
					"left": pt.x,
					"top": pt.y-10
				});
				
				this.processItem(i, this.points[i]);
			}
			
			this.reposition();
			
		} else {
			return;
		}
	},
	
	getNext: function(){
		if (!this.processing) {
			this.processing = true;
			this.rotate(true);
		}
	},
	
	getPrevious: function(){
		if (!this.processing) {
			this.processing = true;
			this.rotate(false);
		}
	},
	
	rotate: function(forward){
		if(!this.processing) return;

		if(forward){
			this.items.push(this.items.shift());
		} else {
			this.items.unshift(this.items.pop());
		}
		
		var fxArray = [];
		
		for(var i = 0; i < this.totalItems; i++){
			//var myEffects = this.items[i].effects({"duration": this.options.fxDuration, "transition": this.options.fxTransition});
                        this.items[i].fx = new Fx.Morph(this.items[i], {duration:this.options.fxDuration, transition:this.options.fxTransition});
                        var myEffects = this.items[i].fx;
			fxArray.push(myEffects);
			if(this.options.fade) {
				myEffects.start({"opacity": this.opacities[i], "top": this.positions[i].y-10, "left": this.positions[i].x, "width": this.sizes[i].x, "height": this.sizes[i].y});
			} else {
				myEffects.start({"top": this.positions[i].y-10, "left": this.positions[i].x, "width": this.sizes[i].x, "height": this.sizes[i].y});
			}
			this.items[i].setStyle("z-index", this.zIndexes[i]);
		}
		
		var g = new Group(null);
		g.initialize.apply(g, fxArray);
		g.addEvent("onComplete", (function(){ this.processing = false; }).bind(this));
	},
	
	reposition: function() {
		for (var _l = 0; _l < this.totalItems; _l++) {		
			var pt = this.getElipticalPoint(this.points[_l]);
			this.positions.push({x: pt.x - ((this.items[_l].getSize().x + this.options.border) / 2), y: pt.y});
			
			this.items[_l].setStyles({
				"left": this.positions[_l].x,
				"top": this.positions[_l].y-10
			});
		}
	},
	
	getElipticalPoint: function(_d) {
		var rad = _d * (Math.PI / 180);
		var _x = this.centerX + this.xRadius * Math.sin(rad);
		var _y = this.centerY + this.yRadius * Math.cos(rad);
		return {x : _x, y : _y};
	},
	
	processItem: function(_i, deg) {
		var size = 1;      
		
		if (deg >= 0 && deg < 180) {
			size = (180 - deg) / 180;
		} else if (deg >= 180 && deg <= 360) {
			size = (deg - 180) / 180;
		}
		this.scaleItem(_i, size);
		this.items[_i].setStyle("z-index", (size * 100).round());
		this.zIndexes.push((size * 100).round());
	},
	
	scaleItem: function(_i, percentage) {
		if(percentage == 0) percentage = 0.1;
		
		var _x = ((this.items[_i].getSize().x + this.options.border) * percentage);
		var _y = ((this.items[_i].getSize().y + this.options.border) * percentage);
		
		this.sizes.push({x: _x, y: _y});
		this.opacities.push(percentage);
	
		this.items[_i].setStyles({
			"width": _x,
			"height": _y,
			"opacity": this.options.fade ? percentage : 1
		});
	}
});

var LightboxExGallery = {
	init: function(options){
		this.options = Object.extend({
			resizeDuration: 400,
			resizeTransition: Fx.Transitions.sineInOut,
			initialWidth: 250,
			initialHeight: 250,
			animateCaption: true,
			defaultIframeWidth : 500, 
			defaultIframeHeight: 300
		}, options || {});

		// IE 6 - XML prolog problem
		if(window.ie6 && document.compatMode=="BackCompat"){
			this.options.animateCaption = false;
		}

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightboxExGallery/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = new Keyboard({
			eventType: 'keydown'			
		});
		this.eventPosition = this.position.bind(this);

		this.overlay = new Element('div').setProperty('id', 'lbOverlayExGallery').injectInside(document.body);

		this.center = new Element('div').setProperty('id', 'lbCenterExGallery').setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', marginLeft: '-'+(this.options.initialWidth/2)+'px', display: 'none'}).injectInside(document.body);
		
		this.closeBtnTop = new Element('a').setProperties({id: 'closeBtnTopGallery', href: '#'}).injectInside(this.center);
		this.closeBtnTop.set("html", "Fermer");
		this.closeBtnTop.onclick = this.overlay.onclick = this.close.bind(this);
		
		this.canvas = new Element('div').setProperty('id', 'lbCanvasExGallery').injectInside(this.center);
		this.prevLink = new Element('a').setProperties({id: 'lbPrevLinkExGallery', 'href': '#'}).setStyle('display', 'none').injectInside(this.canvas);
		this.nextLink = this.prevLink.clone().setProperty('id', 'lbNextLinkExGallery').injectInside(this.canvas);
		this.prevLink.onclick = this.previous.bind(this);
		this.nextLink.onclick = this.next.bind(this);

		this.bottomContainer = new Element('div').setProperty('id', 'lbBottomContainerExGallery').setStyle('display', 'none').injectInside(document.body);
		this.bottom = new Element('div').setProperty('id', 'lbBottomExGallery').injectInside(this.bottomContainer);
		this.closeLink = new Element('div', {'id': 'lbCloseLinkExGallery'}).injectInside(this.bottom);
                                this.closeLink.onclick = this.overlay.onclick = this.close.bind(this);
                                this.closeLink.set("html", '&middot; Fermer');
		this.caption = new Element('div').setProperty('id', 'lbCaptionExGallery').injectInside(this.bottom);
                                this.caption.set("html", 'Cliquez sur les flèches ou les photos pour faire défiler la galerie');
		this.number = new Element('div').setProperty('id', 'lbNumberExGallery').injectInside(this.bottom);
		//new Element('div').setStyle('clear', 'both').injectInside(this.bottom);

		/* Build effects */
		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
            overlay: new Fx.Tween(this.overlay, {property: 'opacity', duration: 500}).start(0),
            resizeCenter: this.center.set('morph', {duration: this.options.resizeDuration, transition: this.options.resizeTransition, onComplete: nextEffect}),
            image: this.canvas.set('tween',  { duration: 500, onComplete: nextEffect }),
            bottom: new Fx.Tween(this.bottomContainer, {property: 'height', duration: 400, onComplete: nextEffect })
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title, link.rev);

		var j, itemNumber, items = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < items.length; j++) if(items[j][0] == el.href && items[j][2] == el.rev) break;
				if (j == items.length){
					items.push([el.href, el.title, el.rev]);
					if (el.href == link.href && el.rev == link.rev) itemNumber = j;
				}
			}
		}, this);
		return this.open(items, itemNumber);
	},

	show: function(url, title, rev){
		return this.open([[url, title, rev]], 0);
	},

	open: function(items, itemNumber){
		this.items = items;
		this.position();
		this.setup(true);
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.top = window.getScrollTop();
		scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});
		this.fx.overlay.start('0.4');
		return this.changeItem(itemNumber);
	},

	position: function(){
		//IE6 - XML prolog problem.
		var ww = (window.getWidth() == 0) ? window.getScrollWidth()-22 : window.getWidth();
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.overlay.setStyles({top: st+'px', height: wh+'px', width:ww+'px'});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		if (window.ie) elements.extend(document.getElementsByTagName('select'));
		elements.each(function(el){ el.style.visibility = open ? 'hidden' : ''; });
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeItem(this.activeItem-1);
	},

	next: function(){
		return this.changeItem(this.activeItem+1);
	},

	changeItem: function(itemNumber){
		if (this.step || (itemNumber < 0) || (itemNumber >= this.items.length)) return false;
		this.step = 1;
		this.activeItem = itemNumber;
		
		this.top = window.getScrollTop();
        scrollXYArray = getScrollXY();
		this.center.setStyles({top: scrollXYArray[1], display: ''});

		this.bottomContainer.style.display = this.prevLink.style.display = this.nextLink.style.display = 'none';
		this.fx.image.fade('hide');
		this.center.className = 'lbLoadingExGallery';

		// discard previous content by clicking
		this.removeCurrentItem();
		
		// check item type
		var url = this.items[this.activeItem][0];
		var rev = this.items[this.activeItem][2];
		
		var re_imageURL = /\.(jpe?g|png|gif|bmp)/i;
		if( url.match(re_imageURL) ) {
			this.preload = new Image();	// JavaScript native Object
			this.preload.datatype = 'image';
			this.preload.w = this.matchOrDefault(rev, new RegExp("width=(\\d+%?)", "i"), -1); //-1 if use original size.
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+%?)", "i"), -1);
			this.preload.onload = this.nextEffect.bind(this);
			this.preload.src = url;
		}else{
			this.preload = new Object ();	// JavaScript native Object
			this.preload.datatype = 'iframe';
			this.preload.w =  this.matchOrDefault(rev, new RegExp("width=(\\d+)", "i"), this.options.defaultIframeWidth);
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+)", "i"), this.options.defaultIframeHeight);
			this.preload.src = url;
			this.nextEffect(); //asynchronous loading
		}

		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			this.center.className = '';

			// create HTML element
			if( this.preload.datatype == 'image' ) {
				var ws = (this.preload.w == -1) ? this.preload.width.toString() : this.preload.w.toString();
				var hs = (this.preload.h == -1) ? this.preload.height.toString() : this.preload.h.toString();
				this.p_width = ( q = ws.match(/(\d+)%/) ) ? q[1] * this.preload.width * 0.01 : ws;
				this.p_height = ( q = hs.match(/(\d+)%/) ) ? q[1] * this.preload.height * 0.01 : hs;
				new Element('img').setProperties({id: 'lbImage', src:this.preload.src, width:this.p_width, height:this.p_height}).injectInside(this.canvas);
				this.nextLink.style.right = '';
			}else{
				this.p_width = this.preload.w;
				this.p_height = this.preload.h;
				// Safari would not update iframe content that has static id.
				this.iframeId = "lbFrame_"+new Date().getTime();
				new Element('iframe').setProperties({id: this.iframeId, width: this.p_width, height: this.p_height, frameBorder:0, scrolling:'no', src:this.preload.src}).injectInside(this.canvas);
				this.nextLink.style.right = '25px';
			}
			this.canvas.style.width = this.bottom.style.width = this.p_width+'px';
			this.canvas.style.height = this.prevLink.style.height = this.nextLink.style.height = this.p_height+'px';

			//this.caption.set("html", this.items[this.activeItem][1] || '');
			//this.number.set("html",  (this.items.length == 1) ? '' : 'Page ' + (this.activeItem+1) + ' sur ' + this.items.length );

			if (this.activeItem) this.preloadPrev.src = this.items[this.activeItem-1][0];
			if (this.activeItem != (this.items.length - 1)) this.preloadNext.src = this.items[this.activeItem+1][0];
			if (this.center.clientHeight != this.canvas.offsetHeight){
				var oh = (this.p_height == this.canvas.clientHeight) ? this.canvas.offsetHeight : eval(this.p_height)+18; // fix for ie
				this.fx.resizeCenter.morph({'height': oh});
				break;
			}

			this.step++;
		case 2:
			if (this.center.clientWidth != this.canvas.offsetWidth){
				var ow = (this.p_width == this.canvas.clientWidth) ? this.canvas.offsetWidth : eval(this.p_width)+18; // fix for ie
				this.fx.resizeCenter.morph({'width': ow, 'marginLeft': -ow/2});
				break;
			}
			this.step++;
		case 3:
			this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', height:'0px', marginLeft: this.center.style.marginLeft, width:this.center.style.width, display: ''});
			this.fx.image.fade('1');
			break;
		case 4:
			if (this.options.animateCaption){
				// This is not smooth animation in IE 6 with XML prolog.
				// If your site is XHTML strict with XML prolog, disable this option.
				this.fx.bottom.start(0,this.bottom.offsetHeight+10);
				break;
			}
			this.bottomContainer.style.height = (this.bottom.offsetHeight)+'px';
		case 5:
			if (this.activeItem){
				this.prevLink.style.display = '';
			}
			if (this.activeItem != (this.items.length - 1)){
				this.nextLink.style.display = '';
			}
			this.step = 0;
		}
	},

	close: function(){
		if (this.step < 0) return;
		this.step = -1;
		this.removeCurrentItem();	// discard content
		//for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
        this.fx.overlay.start('opacity', 0).chain(this.setup.pass(false, this));
		return false;
	},

	removeCurrentItem: function(){
		if (this.preload){
			if( this.preload.datatype == 'image' ) {
				$('lbImage').dispose();
				this.preload.onload = function () {}; //Class.empty;
			}else{
				$(this.iframeId).dispose();
			}
			this.preload = null;
		}		
	},

	matchOrDefault: function(str, re, val){
		var hasQuery = str.match(re);
		return hasQuery ? hasQuery[1] : val;
	}

};

var LightboxExFlash = {
	init: function(options){
		this.options = Object.extend({
			resizeDuration: 400,
			resizeTransition: Fx.Transitions.sineInOut,
			initialWidth: 250,
			initialHeight: 250,
			animateCaption: true,
			defaultIframeWidth : 500, 
			defaultIframeHeight: 300
		}, options || {});

		// IE 6 - XML prolog problem
		if(window.ie6 && document.compatMode=="BackCompat"){
			this.options.animateCaption = false;
		}

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightboxExFlash/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = new Keyboard({
			eventType: 'keydown'			
		});
		this.eventPosition = this.position.bind(this);

		/*	Build float panel
			<div id="lbOverlay"></div>
			<div id="lbCenter">
				<div id="lbCanvas">
					<a id="lbPrevLink"></a>
					<a id="lbNextLink"></a>
					<!-- img or iframe element is inserted here -->
				</div>
			</div>
			<div id="lbBottomContainer">
				<div id="lbBottom">
					<a id="lbCloseLink"></a>
					<div id="lbCaption"></div>
					<div id="lbNumber"></div>
					<div style="clear:both;"></div>
				</div>
			</div>
		*/

		this.overlay = new Element('div').setProperty('id', 'lbOverlayExFlash').injectInside(document.body);

		this.center = new Element('div').setProperty('id', 'lbCenterExFlash').setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', marginLeft: '-'+(this.options.initialWidth/2)+'px', display: 'none'}).injectInside(document.body);
		this.canvas = new Element('div').setProperty('id', 'lbCanvasExFlash').injectInside(this.center);
		this.prevLink = new Element('a').setProperties({id: 'lbPrevLinkExFlash', href: '#'}).setStyle('display', 'none').injectInside(this.canvas);
		this.nextLink = this.prevLink.clone().setProperty('id', 'lbNextLinkExFlash').injectInside(this.canvas);
		this.prevLink.onclick = this.previous.bind(this);
		this.nextLink.onclick = this.next.bind(this);

		this.bottomContainer = new Element('div').setProperty('id', 'lbBottomContainerExFlash').setStyle('display', 'none').injectInside(document.body);
		this.bottom = new Element('div').setProperty('id', 'lbBottomExFlash').injectInside(this.bottomContainer);
		new Element('a').setProperties({id: 'lbCloseLinkExFlash', href: '#'}).injectInside(this.bottom).onclick = this.overlay.onclick = this.close.bind(this);
		this.caption = new Element('div').setProperty('id', 'lbCaptionExFlash').injectInside(this.bottom);
		this.number = new Element('div').setProperty('id', 'lbNumberExFlash').injectInside(this.bottom);
		new Element('div').setStyle('clear', 'both').injectInside(this.bottom);

		/* Build effects */
		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
            overlay: new Fx.Tween(this.overlay, {property: 'opacity', duration: 500}).start(0),
            resizeCenter: this.center.set('morph', {duration: this.options.resizeDuration, transition: this.options.resizeTransition, onComplete: nextEffect}),
            image: this.canvas.set('tween',  { duration: 500, onComplete: nextEffect }),
            bottom: new Fx.Tween(this.bottomContainer, {property: 'height', duration: 400, onComplete: nextEffect })
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title, link.rev);

		var j, itemNumber, items = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < items.length; j++) if(items[j][0] == el.href && items[j][2] == el.rev) break;
				if (j == items.length){
					items.push([el.href, el.title, el.rev]);
					if (el.href == link.href && el.rev == link.rev) itemNumber = j;
				}
			}
		}, this);
		return this.open(items, itemNumber);
	},

	show: function(url, title, rev){
		return this.open([[url, title, rev]], 0);
	},

	open: function(items, itemNumber){
		this.items = items;
		this.position();
		this.setup(true);
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.top = st + (wh / 15);
		this.center.setStyles({top: this.top+'px', display: ''});
		this.fx.overlay.start(0.8);
		return this.changeItem(itemNumber);
	},

	position: function(){
		//IE6 - XML prolog problem.
		var ww = (window.getWidth() == 0) ? window.getScrollWidth()-22 : window.getWidth();
		var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
		var st = document.body.scrollTop  || document.documentElement.scrollTop;
		this.overlay.setStyles({top: st+'px', height: wh+'px', width:ww+'px'});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		if (window.ie) elements.extend(document.getElementsByTagName('select'));
		elements.each(function(el){ el.style.visibility = open ? 'hidden' : ''; });
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeItem(this.activeItem-1);
	},

	next: function(){
		return this.changeItem(this.activeItem+1);
	},

	changeItem: function(itemNumber){
		if (this.step || (itemNumber < 0) || (itemNumber >= this.items.length)) return false;
		this.step = 1;
		this.activeItem = itemNumber;

		this.bottomContainer.style.display = this.prevLink.style.display = this.nextLink.style.display = 'none';
		this.fx.image.fade('hide');
		this.center.className = 'lbLoadingExFlash';

		// discard previous content by clicking
		this.removeCurrentItem();
		
		// check item type
		var url = this.items[this.activeItem][0];
		var rev = this.items[this.activeItem][2];
		
		var re_imageURL = /\.(jpe?g|png|gif|bmp)/i;
		if( url.match(re_imageURL) ) {
			this.preload = new Image();	// JavaScript native Object
			this.preload.datatype = 'image';
			this.preload.w = this.matchOrDefault(rev, new RegExp("width=(\\d+%?)", "i"), -1); //-1 if use original size.
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+%?)", "i"), -1);
			this.preload.onload = this.nextEffect.bind(this);
			this.preload.src = url;
		}else{
			this.preload = new Object ();	// JavaScript native Object
			this.preload.datatype = 'iframe';
			this.preload.w =  this.matchOrDefault(rev, new RegExp("width=(\\d+)", "i"), this.options.defaultIframeWidth);
			this.preload.h = this.matchOrDefault(rev, new RegExp("height=(\\d+)", "i"), this.options.defaultIframeHeight);
			this.preload.src = url;
			this.nextEffect(); //asynchronous loading
		}

		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			this.center.className = '';

			// create HTML element
			if( this.preload.datatype == 'image' ) {
				var ws = (this.preload.w == -1) ? this.preload.width.toString() : this.preload.w.toString();
				var hs = (this.preload.h == -1) ? this.preload.height.toString() : this.preload.h.toString();
				this.p_width = ( q = ws.match(/(\d+)%/) ) ? q[1] * this.preload.width * 0.01 : ws;
				this.p_height = ( q = hs.match(/(\d+)%/) ) ? q[1] * this.preload.height * 0.01 : hs;
				new Element('img').setProperties({id: 'lbImage', src:this.preload.src, width:this.p_width, height:this.p_height}).injectInside(this.canvas);
				this.nextLink.style.right = '';
			}else{
				this.p_width = this.preload.w;
				this.p_height = this.preload.h;
				// Safari would not update iframe content that has static id.
				this.iframeId = "lbFrame_"+new Date().getTime();
				new Element('iframe').setProperties({id: this.iframeId, width: this.p_width, height: this.p_height, frameBorder:0, scrolling:'yes', src:this.preload.src}).injectInside(this.canvas);
				this.nextLink.style.right = '25px';
			}
			this.canvas.style.width = this.bottom.style.width = this.p_width+'px';
			this.canvas.style.height = this.prevLink.style.height = this.nextLink.style.height = this.p_height+'px';

			this.caption.set("html", this.items[this.activeItem][1] || '');
			this.number.set("html",  (this.items.length == 1) ? '' : 'Page ' + (this.activeItem+1) + ' sur ' + this.items.length );

			if (this.activeItem) this.preloadPrev.src = this.items[this.activeItem-1][0];
			if (this.activeItem != (this.items.length - 1)) this.preloadNext.src = this.items[this.activeItem+1][0];
			if (this.center.clientHeight != this.canvas.offsetHeight){
				var oh = (this.p_height == this.canvas.clientHeight) ? this.canvas.offsetHeight : eval(this.p_height)+18; // fix for ie
				this.fx.resizeCenter.morph({'height': oh});
				break;
			}

			this.step++;
		case 2:
			if (this.center.clientWidth != this.canvas.offsetWidth){
				var ow = (this.p_width == this.canvas.clientWidth) ? this.canvas.offsetWidth : eval(this.p_width)+18; // fix for ie
				this.fx.resizeCenter.morph({'width': ow, 'marginLeft': -ow/2});
				break;
			}
			this.step++;
		case 3:
			this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', height:'0px', marginLeft: this.center.style.marginLeft, width:this.center.style.width, display: ''});
			this.fx.image.fade('1');
			break;
		case 4:
			if (this.options.animateCaption){
				// This is not smooth animation in IE 6 with XML prolog.
				// If your site is XHTML strict with XML prolog, disable this option.
				this.fx.bottom.start(0,this.bottom.offsetHeight+10);
				break;
			}
			this.bottomContainer.style.height = (this.bottom.offsetHeight+10)+'px';
		case 5:
			if (this.activeItem){
				this.prevLink.style.display = '';
			}
			if (this.activeItem != (this.items.length - 1)){
				this.nextLink.style.display = '';
			}
			this.step = 0;
		}
	},

	close: function(){
		if (this.step < 0) return;
		this.step = -1;
		this.removeCurrentItem();	// discard content
		//for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
        this.fx.overlay.start('opacity', 0).chain(this.setup.pass(false, this));
		return false;
	},

	removeCurrentItem: function(){
		if (this.preload){
			if( this.preload.datatype == 'image' ) {
				$('lbImageExFlash').dispose();
				this.preload.onload = function () {}; //Class.empty;
			}else{
				$(this.iframeId).dispose();
			}
			this.preload = null;
		}		
	},

	matchOrDefault: function(str, re, val){
		var hasQuery = str.match(re);
		return hasQuery ? hasQuery[1] : val;
	}

};

/********************End********************* Lightbox Popups *********************End********************/

/*******************Begin******************** AJAX - Currency Converter********************Begin*******************/
// Ajax-related functions

// Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        alert("Please update your browser.");
    }
}

// variable for the XmlHttpRequest object
var service;

// starts the AJAX request
function getData(strSvc) {
    if (service.readyState == 4 || service.readyState == 0) {
        try {
            service.open("Get", strSvc + ".xml", true);
            service.onreadystatechange = handle_XML;
            service.send(null);
        } catch (exception) {
            alert("An exception occurred.");
            // return to default state perhaps
        }
    }
}

// gets the xml response
function handle_XML() {
    if (service.readyState == 4) {
        var xmldoc = service.responseXML;
        var xml_nodes = xmldoc.getElementsByTagName("currency");
        var num_nodes = xml_nodes.length;
        
        // time and date at which data was obtained
        var xml_nodes2 = xmldoc.getElementsByTagName("header");
        var num_nodes2 = xml_nodes2.length;
        
        cc_date(xml_nodes2, num_nodes2);
        cc_populate(xml_nodes, num_nodes);
    }
}

function getResponse(strSvc) {
    if (service.readyState == 4 || service.readyState == 0) {
        try {
            service.open("Get", strSvc, true);
            service.onreadystatechange = handleResponse;
            service.send(null);
        } catch (exception) {
            alert("An exception occurred.");
            // return to default state perhaps
        }
    }
}

function handleResponse() {
    if (service.readyState == 4) {
        var respTxt = service.responseText;

        cc_amount(parseFloat(respTxt));
    }
}

// display the converted amount
function cc_amount(fltAmount) {
    var eleObj1 = document.getElementById("txtAmt");
    value = Math.round(fltAmount*100)/100;
    eleObj1.innerHTML = value + " " + document.forms['ccForm'].c2[document.forms['ccForm'].c2.selectedIndex].innerHTML;
}

// print out date and time of currency converter data acquisition
function cc_date(xml_nodes, num_nodes) {
    var eleObj1 = document.getElementById("ud");
    for (i = 0; i < num_nodes; i++) {
        val1 = xml_nodes[i].getElementsByTagName("hname")[0].firstChild.nodeValue;
        if (val1 == "Current UTC Time") {
            val2 = xml_nodes[i].getElementsByTagName("hvalue")[0].firstChild.nodeValue; // YYYY.MM.DD HH:MM:SS
            yyyy = val2.substring(0, val2.indexOf("."));
            mm = val2.substring(val2.indexOf(".")+1, val2.lastIndexOf("."));
            dd = val2.substring(val2.lastIndexOf(".")+1, val2.indexOf(" "));
            gmtTime = val2.substring(val2.indexOf(" ")+1, val2.length);
            var d = new Date(Date.parse(mm + "/" + dd + "/" + yyyy));
            eleObj1.innerHTML = d.toDateString() + " (" + gmtTime + " GMT)";
            return;
        }
    }
}

// populate currency converter select boxes
function cc_populate(xml_nodes, num_nodes) {
    var eleObj1 = document.getElementById("c1");
    var eleObj2 = document.getElementById("c2");
    var option1, option2;
    var text1, text2;
    for (i = 0; i < num_nodes; i++) {
        val1 = xml_nodes[i].getElementsByTagName("cname")[0].firstChild.nodeValue;
        val2 = xml_nodes[i].getElementsByTagName("csymbol")[0].firstChild.nodeValue;
        
        option1 = document.createElement("option");
        option1.value = val2.toLowerCase();
        text1 = document.createTextNode(val1 + " - " + val2);
        option1.appendChild(text1);
        eleObj1.appendChild(option1);
        
        option2 = document.createElement("option");
        option2.value = val2.toLowerCase();
        text2 = document.createTextNode(val1 + " - " + val2);
        option2.appendChild(text2);
        eleObj2.appendChild(option2);
    }
}
/*******************End******************** AJAX - Currency Converter********************End*******************/

/*******************Begin******************** AJAX - Today's Weather ********************Begin*******************/
// starts the AJAX request
function getWData(strSvc) {
    if (weather != null) {
        if (weather.readyState == 4 || weather.readyState == 0) {
            try {
                weather.open("Get", strSvc, true);
                weather.onreadystatechange = handleWResponse;
                weather.send(null);
            } catch (exception) {
                alert("An exception occurred.");
                // return to default state perhaps
            }
        }
    }
}

// get the response text
function handleWResponse() {
    if (weather.readyState == 4) {
        var respTxt = weather.responseText;

        insertWContent(respTxt);
    }
}

// insert the html fragment on the page
function insertWContent(respTxt) {
    var obj = document.getElementById("tdyWth");
    if (obj != null) {
        obj.innerHTML = respTxt;
    }
}
/********************End********************* AJAX - Today's Weather *********************End********************/
/********************Begin*************** URL Query Opening Table Content ****************Begin********************/
function sliderOpenOnPageLoad(){
    
    if (window.location.search != ""){
        var qString = window.location.search; //query string value
        var strVal;
        var nvPairs = new Array;
        var id;
        var id2;
        var id3;
        var id4;
        
        qString = qString.substring(1); // removes '?' from string
       
        strVal = qString.split('&'); // for muliple query name values

        // goes through and splits the nave and value at the '=' and creates a 2d array based on the pairs.
        // gets the value from each pair and associates it with the 4 elements in the dom that are needed 
        // to open the slider on the page
        for (i=0; i<strVal.length; i++){
            nvPairs[i] = strVal[i].split('=');
        }
		
		var nvLength = nvPairs.length;
		var keyContainer;
		var selectedIndex;
		
		for(i=0; i<nvLength; i++){
			if(nvPairs[i][0] == "id"){
				keyContainer = document.getElementById(nvPairs[i][1]);
				selectedIndex = (keyContainer)? parseInt(keyContainer.innerHTML) : nvPairs[i][1];
			}
		}
		
		if(selectedIndex){
			id = document.getElementById("mainCat" + selectedIndex + "Toggle");
			id2 = document.getElementById("mainCat" + selectedIndex + "Toggle1");
			id3 = document.getElementById("cat" + selectedIndex + "Content");
			id4 = document.getElementById("mc" + selectedIndex + "d");
			
			if (id) {
			 id.className = "header_selectedTTDS header_border_closed header_top";
             id2.className = "upTTDS header_text";
             id3.parentNode.setStyle('height', 'auto');
             id3.parentNode.style.float= "left";
             id3.setStyle('margin', '0px');
             id4.parentNode.style.display = "none";

             id.scrollIntoView()
		                }
			
		}
    } // ends if
}
/********************End*************** URL Query Opening Table Content ****************End********************/
