/**
 * scripts
 * macharron@inpix.ca
 * Last edit: 2010-05-25
 */


/**
 * open links with rel='external' in new tabs
 * @author http://www.456bereastreet.com/archive/200610/opening_new_windows_with_javascript_version_12/
 */
var JSTarget={init:function(att,val,warning){if(document.getElementById&&document.createElement&&document.appendChild){var strAtt=((typeof att==='undefined')||(att===null))?'class':att;var strVal=((typeof val==='undefined')||(val===null))?'non-html':val;var strWarning=((typeof warning==='undefined')||(warning===null))?' (opens in a new window)':warning;var oWarning;var arrLinks=document.getElementsByTagName('a');var oLink;var oRegExp=new RegExp("(^|\\s)"+strVal+"(\\s|$)");for(var i=0;i<arrLinks.length;i++){oLink=arrLinks[i];if((strAtt=='class')&&(oRegExp.test(oLink.className))||(oRegExp.test(oLink.getAttribute(strAtt)))){oWarning=document.createElement("em");oWarning.appendChild(document.createTextNode(strWarning));oLink.appendChild(oWarning);oLink.onclick=JSTarget.openWin;}oWarning=null;}}},openWin:function(e){var event=(!e)?window.event:e;if(event.shiftKey||event.altKey||event.ctrlKey||event.metaKey){return true;}else{var oWin=window.open(this.getAttribute('href'),'_blank');if(oWin){if(oWin.focus){oWin.focus();}return false;}oWin=null;return true;}},addEvent:function(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false);}else if(obj.attachEvent){obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event);};obj.attachEvent("on"+type,obj[type+fn]);}}};JSTarget.addEvent(window,'load',function(){JSTarget.init("rel","external","");});

/**************************************

 **************************************/

/* ########################################################### */
/* !vars */

var isIe = false;
var isOp = false;
var isSaf = false;

/**
 * if browser is IE
 */
if ($.browser.msie) {
    isIe = true;
}
/**
 * if browser is Opera
 */
if ($.browser.opera) {
    isOp = true;
}
/**
 * if browser is Safari
 */
if ($.browser.safari) {
    isSaf = true;
}

/**
 * put elements at the same height
 * @param group: jquery selector of the elements to equalize
 */
var equalHeight = {
    init: function(group) {
        tallest = 0;
        group.each(function() {
            thisHeight = jQuery(this).height();
            if (thisHeight > tallest) {
                tallest = thisHeight;
            }
        });
        group.height(tallest);
    }
};


/**
 * remove and put back default values in field
 * @param targ: jquery selector of the chosen field
 */
var inputLabel = {
	/**
	 * add events on field and set default value;
	 */
	init: function(targ){
		var val1 = '';
		
		$(targ).each(function(){
			$(targ).focus(function(){
				if(val1 == ''){val1 = $(this).val();}
				inputLabel.clear(targ, val1);
			})
			.blur(function(){
				inputLabel.blur(targ, val1);
			})
			.addClass("label-in");
		});
	},
	/**
	 * clear the field of default value
	 */
	clear: function(targ, startValue){
		
		if($(targ).val() !== startValue){
			$(targ).val();
		}else{
			$(targ).val("").removeClass("label-in");
		}
	},
	/**
	 * put the default value back
	 */
	blur: function(targ, startValue){
		
		if($(targ).val() !== ""){
			$(targ).val();
		}else{
			$(targ).val(startValue).addClass("label-in");
		}
	}
};

/**
 * loader to insert just before ajax calls
 */
var loader = '<p class="loader center"><img src="lib/img/ajax-loader.gif" alt="" /></p>';


/**
 * change the selected month on the Reservation footer block
 */
var monthChooser = {
	/**
	 * initialize all the vars and add click action on next, previous and month button
	 */
	init: function(){

		this.auj = new Date();
		this.currMonth = this.auj.getMonth();
		this.currYear = parseInt(this.auj.getFullYear(), 10);
		this.theYear = this.currYear;
		this.theMonth = this.currMonth;
		this.currMonthAbbr = function(){return this.getMonthName(this.theMonth, 'fr', true);};
		this.url = $('.month-chooser .month a').attr('href');

		$('.month-chooser .month a').text(this.currMonthAbbr() + '. ' + this.currYear);
		$('.month-chooser .prev, .month-chooser .next').click(this.change);
	},
	/**
	* return the month as text
	* @param numb: the month index
	* @param lang: the language of return of the month
	* @param type: if true return abbr only else return the full name
	*/
	getMonthName: function(numb, lang, type){

		switch(lang){
			default:
			case 'fr':
				if(type === true){
					return mt.months[0][1][numb];
				}else{
					return mt.months[0][0][numb];
				}
				break;

			case 'en':
				if(type === true){
					return mt.months[1][1][numb];
				}else{
					return mt.months[1][0][numb];
				}
				break;
		}		
	},
	/**
	 * array containing all the months in text
	 */
	months: [
		fr = [
			full = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
			abbr = ['Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun', 'Jui', 'Août', 'Sept', 'Oct', 'Nov', 'Déc']
		],
		en = [
			full = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
			abbr = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']
		]
	],
	/**
	 * change the current selected month in the box
	 */
	change: function(){

		if($(this).hasClass('prev')){
			if($(this).closest('li').hasClass('disabled')){
				return false;
			}
			mt.theMonth -= 1;
		}else{
			mt.theMonth += 1;
		}

		if(mt.theMonth > 11){
			mt.theMonth = 0;
			mt.theYear += 1;
		}
		if(mt.theMonth < 0){
			mt.theMonth = 11;
			mt.theYear -= 1;
		}

		if( (mt.theMonth > mt.currMonth && mt.theYear == mt.currYear) || mt.theYear > mt.currYear){
			$(this).closest('ul').find('li:eq(0)').removeClass('disabled');
		}else{
			$(this).closest('ul').find('li:eq(0)').addClass('disabled');
		}

		var newUrl = mt.url + '#y=' + mt.theYear + '&m=' + parseInt(mt.theMonth +1, 10);
		$('.month-chooser .month a').text(mt.currMonthAbbr() + '. ' + mt.theYear).attr('href', newUrl );

		return false;
	}
};
var mt = monthChooser;


/**
 * show or hide videoplayer on homepage
 */
var video = {
	/**
	 * add the click action on the wacth the video again
	 */
    init: function() {
        $('#bloc-play-pub a').click(this.change);
    },
	/**
	 * change the video for the textbox or vice-versa
	 */
	change: function(){
		if($('#video-player:hidden')[0]){
			$('#video-player').hide();
			$('#acc-main').fadeOut(100, function(){
				$('#video-player').fadeIn(100);
			});
		}else{
			$('#acc-main').hide();
			$('#video-player').fadeOut(100, function(){
				$('#acc-main').fadeIn(100);
			});
			
		}
		
		return false;
	}
};


/**
 * popup creator
 * @param _url: url to call in ajax
 * @param _id: action link id
 * @param _popId: id of popup
 * @param _url: url to get and load in popup
 * @param _title: popup titlebar text
 * @param _width: popup width
 */

var popup = {
    init: function(_id, _popId, _url, _title, _width) {
		this.popId = '#'+_popId;
		var popHtml = '<div id="'+_popId+'"></div>';
		$('body').append(popHtml);
			
		$('#'+_id).click(function(){

			$(popup.popId).load(_url, function(){

			$(popup.popId).dialog({
					modal: true,
					autoOpen: false,
					title: _title,
					draggable: false,
					width: _width
				}).hide();

				$('.bt-cancel', this).click(function(){
					$(popup.popId).dialog('close');
					return false;
				});

				$(popup.popId).dialog('open');
			});

			return false;
		});

    }
};


/**
 * galerie photo with colorbox
 * @param _url: url to get more pictures
 */
var galerie = {
	/**
	 * start colorbox and add action on loadmore image link
	 */
    init: function(_url) {

		this.reload();
		this.url = _url;		
    },
	/**
	 * the first load of the galerie
	 */
	load: function(){
		$('#bloc-galerie ul').append(loader);

		var nbPictures = $('#bloc-galerie ul li').length;
		var selCategory =  $('.ls-tags .selected a').attr('id');
		selCategory = selCategory.split('-')[1];

		$.get(
			galerie.url,
			{nbPic: nbPictures, selCat: selCategory},
			function(data){
				$('#bloc-galerie ul .loader').remove();
				$('#bloc-galerie ul').append(data);
				galerie.reload();
			}
		);

		return false;

	},
	/**
	 * the call made in ajax to load more images
	 */
	reload: function(){
		if($('body').hasClass('fr')){
			prevText = 'précédente';
			nextText = 'suivante';
			currText = '{current} de {total}';
		}else{
			prevText = 'previous';
			nextText = 'next';
			currText = '{current} of {total}';
		}

		$('#bloc-galerie ul a').attr('rel', 'box').colorbox({
			current: currText,
			previous: prevText,
			next: nextText,
			loop: false,
			maxWidth: '100%'
		});
	}
};


/**
 * animate the images in the station page
 */
var stations = {
	/**
	 * add the action on the images thumb
	 */
    init: function() {
        $('#ls-store a').click(this.change);
    },
	/**
	 * swicth the active aimge and animate the slider
	 */
	change: function(){

		if($(this).closest('li').hasClass('selected')){
			return false;
		}


		var ul = '#ls-store-z ul';

		var pixels = parseInt($('#ls-store-z').width(), 10);
		var index = $('#ls-store li').index($(this).closest('li'));
		var currIndex = $('#ls-store li').index($('#ls-store li.selected'));

		var xtra;
		if(currIndex < index){
			xtra = 20;
		}else{
			xtra = -20;
		}

		var mouv = -(pixels*index)-xtra;


		$(ul).stop(true, false).animate({
			marginLeft: mouv
		}, 500, function(){
			$(ul).animate({
				marginLeft: parseInt($(ul).css('marginLeft'), 10) + xtra
			}, 100);
		});

		$(this).closest('ul').find('li.selected').removeClass('selected');
		$(this).closest('li').addClass('selected');

		return false;
	}
};

/**
 * Fonction to create a datepicker
 * @param _id: jquery selector of element to transform into a datepicker
 * @param _range: number of year to extend the datepicker
 */
var datePick = {
	setted: false,
	init: function(_id, _range){

		this.validate();

		var auj = new Date();
		var currYear = parseInt(auj.getFullYear(), 10);

		var rangeStart = currYear;
		var rangeEnd = currYear + _range;

		$(_id).parent().find('.i-sel select').attr('disabled', 'disabled');

		var _select = function(dateText, inst){

			dateText = dateText.replace(/-/g, '/');

			var theDate = new Date(dateText);
			var dayNum = theDate.getDay();


			var id = '#'+inst.id;
			$(id).next().val(dateText);
			$(id).parent().find('.i-sel select').attr('disabled', '');
			$(id).parent().find('.i-sel select option').attr('disabled', '');
			
			switch(dayNum){
				case 0:
				case 1:
				case 2:
				case 3:
				default:
					$(id).parent().find('.i-sel select .type2, .i-sel select .type3').attr('disabled', 'disabled');
					break;
				
				case 4:
				case 5:
					$(id).parent().find('.i-sel select .type3').attr('disabled', 'disabled');
					break;
				
				case 6:
					$(id).parent().find('.i-sel select .type2').attr('disabled', 'disabled');
					break;
			}
		}
		if($('body').hasClass('en')){
			jQuery(_id).datepicker({
				nextText: 'Next',
				prevText: 'Previous',
				dateFormat: 'yy-mm-dd',
				showButtonPanel: false,
				currentText: "Today",
				closeText: 'Close',
				changeYear: true,
				changeMonth: true,
				yearRange: rangeStart+':'+rangeEnd,
				showAnim: 'slideDown',
				onSelect: function(dateText, inst){
					_select(dateText, inst);
				}
			});
		}else{
			jQuery(_id).datepicker({
				monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
				dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
				dayNamesMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'], // more than 2 letters break the display
				monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun','Jui','Aoû','Sep','Oct','Nov','Déc'],
				nextText: 'Suivant',
				prevText: 'Précédent',
				dateFormat: 'yy-mm-dd',
				showButtonPanel: false,
				currentText: "Aujourd'hui",
				closeText: 'Fermer',
				changeYear: true,
				changeMonth: true,
				yearRange: rangeStart+':'+rangeEnd,
				showAnim: 'slideDown',
				onSelect: function(dateText, inst){
					_select(dateText, inst)
				}
			});
		}

		/**
		 * preselection of calendar date or station depending on url param passed
		 */
		(function(){
			var url = window.location.hash;

			if(url){
				var temp = url.replace('#', '').split('&');
				var temp2 = [];

				// for station preselection only
				if(temp.length == 1){
					$('#field-station select option:eq('+ temp[0] +')').attr("selected", "selected");
					return false;
				}


				for(x=0;x<temp.length;x++){
					temp2.push(temp[x].split('=')[1]);
				}

				if(datePick.setted === false){ // first calendar date
					var laDate = new Date(temp2[0] + '/' + temp2[1] + '/01' );
					jQuery(_id).datepicker("setDate", laDate );

					datePick.setted = true;

				}else{ // second calendar date
					var laDate = new Date(temp2[0] + '/' + temp2[1] + '/14' );
					jQuery(_id).datepicker("setDate", laDate );
				}
			}

		})();

	},
	validate: function(){

		$("#pg-res form:eq(0)").validate({
			rules: {
				"i-first-date":{
					required: true
				},
				"i-first-hour":{
					selects: '0'
				},
				"i-second-date":{
					required: true
				},
				"i-second-hour":{
					selects: '0'
				},
				"i-nom": {
					required: true
				},
				"i-station": {
					selects: '0'
				},
				"i-nb": {
					selects: '0'
				},
				"i-tel": {
					defaults: true
				},
				"i-mail": {
					required: true,
					email: true
				}
			},
			messages: {
				"i-first-date":{
					required: function(){
						if($('body').hasClass('fr')){
							return 'Veuillez choisir une date.';
						}else{
							return 'Please select a date.';
						}
					}
				},
				"i-first-hour":{
					selects:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez choisir une heure.';
						}else{
							return 'Please select an hour.';
						}
					}
				},
				"i-second-date":{
					required:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez choisir une date supplémentaire.';
						}else{
							return 'Please select a second date.';
						}
					}
				},
				"i-second-hour":{
					selects:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez choisir une heure supplémentaire.';
						}else{
							return 'Please select a second hour.';
						}
					}
				},
				"i-nom": {
					required:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez entrer votre nom.';
						}else{
							return 'Please enter your name.';
						}
					}
				},
				"i-station": {
					selects:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez choisir une station.';
						}else{
							return 'Please select a store.';
						}
					}
				},
				"i-nb": {
					selects:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez choisir un type de séance.';
						}else{
							return 'Please select a date.';
						}
					}
				},
				"i-tel": {
					defaults:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez entrer votre téléphone.';
						}else{
							return 'Please enter a phone number.';
						}
					}
				},
				"i-mail": {
					required:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez entrer votre courriel.';
						}else{
							return 'Please enter an email.';
						}
					},
					email:  function(){
						if($('body').hasClass('fr')){
							return 'Veuillez entrer un courriel valide.';
						}else{
							return 'Please enter a valid email.';
						}
					}
				}
			}
		});
		return false;
	}
};

/**
 * Fonction to enable or disabled the livraison form
 
var livraison = {
	init: function(){
		if(!$('#check-liv input:checked')[0]){
			this.set();
		}
		$('#check-liv input').change(this.change);
	},
	change: function(){
		if($('#check-liv input:checked')[0]){
			$('#frm-liv input, #frm-liv textarea').attr('disabled', '').removeClass('disabled');
		}else{
			livraison.set();
		}
	},
	set: function(){
		$('#frm-liv input, #frm-liv textarea').attr('disabled', 'disabled').addClass('disabled');
	}
};
*/

/**
* Fonction to change steps in virtual album screen
*/
var virtuel = {
	init: function(){
		$('#nav-virtuel a').click(this.change);
		this.inter = setInterval("virtuel.change()", 8000);
	},
	change: function(){

		var imgs = '#img-virtuel ul';
		var dist = parseInt($('#img-virtuel').width(), 10);
		var bt = $(this);

		if(!bt.closest('#nav-virtuel')[0]){
			if($('#nav-virtuel .selected').next()[0]){
				bt = $('#nav-virtuel .selected').next().find('a');
			}else{
				bt = $('#nav-virtuel li:eq(0)').find('a');
			}
		}else{
			clearInterval(virtuel.inter);
		}



		bt.closest('ul').find('li').removeClass('selected');
		bt.closest('li').addClass('selected');
		var ind = $('#nav-virtuel li').index(bt.parent());

		var move = dist*ind;

		$(imgs).fadeOut(500, function(){
			$(imgs).animate({
				marginLeft: 0 - move + 'px'
			}, 1, function(){
				$(imgs).fadeIn(500);
			});
		});
		

		return false;
	}
};

/**
 * Fonction to relaunch after an ajax refresh
 */
var ajax = {
    init: function() {
        JSTarget.init("rel", "external", "");
		Cufon.refresh();
    }
};


/**
 * Fonctions to call on DOM ready
 */

$(document).ready(function () {
   

    if ($('#pg-exp #bloc-play-pub')[0]) {
        $('#pg-exp #bloc-play-pub a').colorbox({
            maxWidth: '100%',
            scrolling: false
        });
    }


	if($('.month-chooser')[0]){
		monthChooser.init();
	}

if (isIe === true && $.browser.version < 7) {
    $('#bloc-deco').pngFix();
    $('#pastille').pngFix();
}
if ($('#nav-virtuel')[0]) {
    virtuel.init();
}


	if($('#video-player')[0]){
		video.init();
		
		if($.cookie('video') !== 'false'){
			video.change();
			$.cookie('video', false, {expires: 30});
		}else{
			$('#video-player').html('');
		}


if ((!navigator.userAgent.match(/iPhone/i)) && (!navigator.userAgent.match(/iPod/i)) && (!navigator.userAgent.match(/iPad/i))) {

    flowplayer(
				"video-player",
				"lib/video/flowplayer-3.2.4.swf",
				{
				    "wmode": 'transparent',
	
				    "canvas": {
				        "backgroundColor": '#ffffff'
				    },
	
				    "plugins": {
				        "controls": {
				            "borderRadius": '0px',
				            "sliderGradient": 'none',
				            "bufferGradient": 'none',
				            "volumeSliderColor": '#000000',
				            "timeBgColor": '#555555',
				            "progressGradient": 'medium',
				            "tooltipColor": '#999999',
				            "backgroundGradient": [1, 1, 1, 1, 1],
				            "buttonOverColor": '#9c9c9c',
				            "tooltipTextColor": '#ffffff',
				            "backgroundColor": '#ffffff',
				            "volumeSliderGradient": 'none',
				            "buttonColor": '#6e6e6e',
				            "timeColor": '#ffffff',
				            "sliderColor": '#000000',
				            "durationColor": '#ffffff',
				            "progressColor": '#bf1015',
				            "bufferColor": '#b3bdb6',
				            "height": 24,
				            "opacity": 1.0,
	
				            // tooltips configuration
				            "tooltips": {
	
				                // enable english tooltips on all buttons
				                "buttons": true,
	
				                // customized texts for buttons
				                "play": 'Jouer',
				                "pause": 'Pause',
				                "fullscreen": 'Plein écran',
				                "fullscreenExit": 'Sortir du mode plein écran',
				                "mute": 'Mettre en sourdine',
				                "unmute": 'Mettre le son'
				            }
				        },
				        // the RTMP plugin
				        "rtmp": {
				            "url": 'lib/video/flowplayer.rtmp-3.2.3.swf',
				            // netConnectionUrl has our CloudFront domain name + 'cfx/st'
				            "netConnectionUrl": 'rtmp://s1hqwaug9eu495.cloudfront.net/cfx/st'
				        }
				    },
				    "clip": {
				        "autoPlay": true,
				        "autoBuffering": true,
				        "url": "mp4:cheezz/pub.mp4",
				        "provider": "rtmp",
				        "onBeforeFinish": function () {
				            this.getPlugin('play').css('opacity', 0);
				        },
				        "onFinish": video.change
				    },
				    "play": {
				        "replayLabel": 'Rejouer'
				    }
				}).ipad();
	
	} else {
	
	    if (!navigator.userAgent.match(/iPad/i)) {
	
	        flowplayer(
						"video-player",
						"lib/video/flowplayer-3.2.4.swf",
					{
					    "wmode": 'transparent',
	
					    "canvas": {
					        "backgroundColor": '#ffffff'
					    },
	
					    "clip": {
					        "autoPlay": true,
					        "autoBuffering": true,
					        "url": "lib/video/pub-iphone.mp4",
					        "onFinish": video.change
					    },
					    "play": {
					        "replayLabel": 'Rejouer'
					    }
					}).ipad();
	
	    } else {
	
	        flowplayer(
						"video-player",
						"lib/video/flowplayer-3.2.4.swf",
					{
					    "wmode": 'transparent',
	
					    "canvas": {
					        "backgroundColor": '#ffffff'
					    },
	
					    "clip": {
					        "autoPlay": true,
					        "autoBuffering": true,
					        "url": "lib/video/pub-ipad.mp4",
					        "onFinish": video.change
					    },
					    "play": {
					        "replayLabel": 'Rejouer'
					    }
					}).ipad();
	
	    }
	
	
	}
}

if($('#content .content-bloc #video-player-standalone')[0]){
		if((!navigator.userAgent.match(/iPhone/i)) && (!navigator.userAgent.match(/iPod/i)) && (!navigator.userAgent.match(/iPad/i))) {
			flowplayer(
				"video-player-standalone",
				"lib//video/flowplayer-3.2.4.swf",
			{
				"wmode": 'transparent',

				"canvas": {
					"backgroundColor":'#ffffff'
				},

				"plugins":  {
					"controls": {
						"borderRadius"			: '0px',
						"sliderGradient"		: 'none',
						"bufferGradient"		: 'none',
						"volumeSliderColor"		: '#000000',
						"timeBgColor"			: '#555555',
						"progressGradient"		: 'medium',
						"tooltipColor"			: '#999999',
						"backgroundGradient"	: [1,1,1,1,1],
						"buttonOverColor"		: '#9c9c9c',
						"tooltipTextColor"		: '#ffffff',
						"backgroundColor"		: '#ffffff',
						"volumeSliderGradient"	: 'none',
						"buttonColor"			: '#6e6e6e',
						"timeColor"				: '#ffffff',
						"sliderColor"			: '#000000',
						"durationColor"			: '#ffffff',
						"progressColor"			: '#bf1015',
						"bufferColor"			: '#b3bdb6',
						"height"				: 24,
						"opacity"				: 1.0,

						// tooltips configuration
						"tooltips": {

							// enable english tooltips on all buttons
							"buttons": true,

							// customized texts for buttons
							"play"				: 'Jouer',
							"pause"				: 'Pause',
							"fullscreen"		: 'Plein écran',
							"fullscreenExit"	: 'Sortir du mode plein écran',
							"mute"				: 'Mettre en sourdine',
							"unmute"			: 'Mettre le son'
						}
					},
					 // the RTMP plugin
					"rtmp": {
						"url": 'lib//video/flowplayer.rtmp-3.2.3.swf',
						// netConnectionUrl has our CloudFront domain name + 'cfx/st'
						"netConnectionUrl": 'rtmp://s1hqwaug9eu495.cloudfront.net/cfx/st'
					}
				},
				"clip": {
					"autoPlay"		: true,
					"autoBuffering"	: true,
					"url"			: "mp4:cheezz/manon.mp4",
					"provider"		: "rtmp"
				},
				"play": {
					"replayLabel": 'Rejouer'
				}
			}).ipad();
		}else{
			if(!navigator.userAgent.match(/iPad/i)) {
				flowplayer(
					"video-player-standalone",
					"lib//video/flowplayer-3.2.4.swf",
				{
					"wmode": 'transparent',

					"canvas": {
						"backgroundColor":'#ffffff'
					},

					"clip": {
						"autoPlay"		: true,
						"autoBuffering"	: true,
						"url"			: "lib//video/manon-iphone.mp4"
					},
					"play": {
						"replayLabel": 'Rejouer'
					}
				}).ipad();
			}else{
				flowplayer(
					"video-player-standalone",
					"lib//video/flowplayer-3.2.4.swf",
				{
					"wmode": 'transparent',

					"canvas": {
						"backgroundColor":'#ffffff'
					},

					"clip": {
						"autoPlay"		: true,
						"autoBuffering"	: true,
						"url"			: "lib//video/manon-ipad.mp4"
					},
					"play": {
						"replayLabel": 'Rejouer'
					}
				}).ipad();
			}

		}
	}


Cufon.replace("h2, h3, h4, #ls-steps li", {});
Cufon.replace(".CmsStandardListe_SL2 .CmsStandardListe_Cms h1", {});
Cufon.replace(".CmsStandardListe_SL2 .CmsStandardListe_Cms p .SubTitle", {});
Cufon.replace(".CmsStandardListe_SL2 .CmsStandardListe_Liste_Item h1", {});
Cufon.replace(".CmsStandardListe_SL3 .CmsStandardListe_Cms h1", {});
Cufon.replace(".CmsStandardListe_SL3 .CmsStandardListe_Cms p .SubTitle", {});
Cufon.replace(".CmsStandardListe_SL3 .CmsStandardListe_Liste_Item h1", {});
Cufon.replace(".CmsStandardListe_SL4 .CmsStandardListe_Cms h1", {});
Cufon.replace(".CmsStandardListe_SL4 .CmsStandardListe_Cms p .SubTitle", {});
Cufon.replace(".CmsStandardListe_SL4 .CmsStandardListe_Liste_Item h1", {});
Cufon.replace(".CmsStandardListe_SL5 .CmsStandardListe_Cms h1", {});
Cufon.replace(".CmsStandardListe_SL5 .CmsStandardListe_Cms p .SubTitle", {});
Cufon.replace(".CmsStandardListe_SL5 .CmsStandardListe_Liste_Item h1", {});
Cufon.replace(".CmsStandardListe_SL6 .CmsStandardListe_Cms h1", {});
Cufon.replace(".CmsStandardListe_SL6 .CmsStandardListe_Cms p .SubTitle", {});
Cufon.replace(".CmsStandardListe_SL6 .CmsStandardListe_Liste_Item h1", {});

Cufon.replace(".CmsStandardListe_SL7 .CmsStandardListe_Cms h1", {});
Cufon.replace(".CmsStandardListe_SL7 .CmsStandardListe_Cms p .SubTitle", {});
Cufon.replace(".CmsStandardListe_SL7 .CmsStandardListe_Liste_Item h1", {});

	Cufon.now();


	if($('.fr #link-newsletter')[0]){
	    popup.init('link-newsletter', 'pop-news', 'infolettre.html', 'Abonnez-vous à notre infolettre', 380);
	}

	if($('#link-conn')[0]){
	    popup.init('link-conn', 'pop-conn', 'connexion_client.aspx', 'La section client de Cheezz', 380);
	}

	if ($('#link-conn2')[0]) {
	    popup.init('link-conn2', 'pop-conn', 'connexion_client.aspx', 'La section client de Cheezz', 380);
	}

	if ($('#pg-joi form')[0]) {
	    joindre.init();
	}

	if ($('#pg-exp #bloc-play-pub')[0]) {
	    $('#pg-exp #bloc-play-pub a').colorbox({
	        maxWidth: '100%',
	        scrolling: false
	    });
	}



	if($('#bloc-galerie')[0]){
		galerie.init('galerie-xtra.html');
	}

	if($('#ls-store-z')[0]){
		stations.init();
	}

	if($('#dateFirstC')[0]){
		datePick.init('#dateFirstC', 5);
	}

	if($('#dateSecondC')[0]){
		datePick.init('#dateSecondC', 5);
	}

	if($('body#pg-res form')[0]){
		$('body#pg-res form input.df').each(function(){
			id = $(this).attr('id');
			inputLabel.init('#'+id);
		});
	}
/**
if($('#frm-liv')[0] && $('#check-liv')[0]){
livraison.init();
}
*/
/**
* fonction pour montrer ou cacher le champ autre dans la page carte cadeau
*/
	function cadeau(){
		if($('#other-card')[0]){
			$('#other-card').hide();
			$('#content form .i-check input:radio').change(function(){

				if($(this).val() == 0){
					$('#other-card').slideDown(200);
				}else{
					$('#other-card').slideUp(200);
				}
			})
		}
	}
	cadeau();


	if(typeof($.validator) == 'function'){

		/**
		 * check if the select has the default value
		 */
		$.validator.addMethod("selects", function(value, element, param) {
			return this.optional(element) || value !== param;
		});

		/**
		 * check if the default value is still in the field
		 */
		$.validator.addMethod("defaults", function(value, element) {
			return this.optional(element) || !$(element).hasClass('label-in');
		});
	}

});

$(window).load(function() {
	(function(){
		if(typeof(google) == 'object'){
			var latlng = new google.maps.LatLng(45.53521281284293, -73.59535217285156);
			var options = {
				zoom: 11,
				center: latlng,
				mapTypeId: google.maps.MapTypeId.TERRAIN,
				mapTypeControlOptions: {
					style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
				},
				navigationControlOptions: {
					style: google.maps.NavigationControlStyle.SMALL
				},
				scrollwheel: false
			};

			var map = new google.maps.Map(document.getElementById('gmap'), options);

			var marker = new google.maps.Marker({
				position: new google.maps.LatLng(45.49389390617287, -73.48052948713303),
				map: map,
				title: 'Cheezz Greenfield Park',
				clickable: false,
				icon: 'lib/img/marker.png'
			});

			var marker2 = new google.maps.Marker({
				position: new google.maps.LatLng(45.57020976529143, -73.72383266687393),
				map: map,
				title: 'Cheezz Laval',
				clickable: false,
				icon: 'lib/img/marker.png'
			});
		}

	})();

});
