hs.graphicsDir = '/rsplug/highslide/graphics/';
hs.showCredits = false;
hs.outlineType = 'rounded-white';
hs.dimmingOpacity = 0.75;
hs.fadeInOut = true;
hs.align = 'center';
//hs.marginBottom = 0;
hs.allowMultipleInstances = false;
hs.captionEval = 'this.a.title';
hs.numberPosition = 'caption';
hs.transitions = ['expand', 'crossfade'];
hs.zIndexCounter = 100000;
hs.wrapperClassName = 'draggable-header';
hs.preserveContent = false;
var hs_wrapperClassName = hs.wrapperClassName;

var slideshowGroups = {};

hs.onSetClickEvent = function (sender, e){
	var type = hs.isUnobtrusiveAnchor(e.element);
	if (type){
		if (type == 'image'){
			e.element.onclick = function (){
				var likeLB = this.className.match(/\blikeLB\b/);
				if (this.rev && likeLB){
					if (!slideshowGroups[this.rev]){
						slideshowGroups[this.rev] = true;
						hs.addSlideshow({
							slideshowGroup: this.rev,	
							useControls: false,
							//interval: 5000,
							repeat: true
						});

						hs.registerOverlay({
							className: 'hs_overlay_previous',
							html: '<a href="#" onclick="return hs.previous(this);" title="'+hs.lang.previousText+'">'+hs.lang.previousText+'</a>',
							position: 'top left',
							useOnHtml: true,
							fade: 2 
						});
						hs.registerOverlay({
							className: 'hs_overlay_next',
							html: '<a href="#" onclick="return hs.next(this);" title="'+hs.lang.nextText+'">'+hs.lang.nextText+'</a>',
							position: 'top right',
							useOnHtml: true,
							fade: 2 
						});
						hs.registerOverlay({
							className: 'hs_overlay_close',
							html: '<div class="closebutton" onclick="return hs.close(this)" title="'+hs.lang.closeText+'"></div>',
							position: 'top right',
							useOnHtml: true,
							fade: 2 
						});
						
						// PRELOAD des précédent/suivant
						var img = new Image();
						img.src = hs.graphicsDir + 'previousBtn_hover.png';
						var img = new Image();
						img.src = hs.graphicsDir + 'nextBtn_hover.png';
					}
					return hs.expand(this, { slideshowGroup: this.rev, captionOverlay: {className: 'hs_caption_overlay'}, wrapperClassName: 'hs_image hs_likeLB '+hs_wrapperClassName });
				} 
				else if (this.rev && !likeLB){
					if (!slideshowGroups[this.rev]){
						slideshowGroups[this.rev] = true;
						hs.addSlideshow({
							slideshowGroup: this.rev,	
							//interval: 5000,
							repeat: false,
							useControls: true,
							fixedControls: 'fit',
							overlayOptions: {
								opacity: '0.6',
								position: 'bottom center',
								offsetX: '0',
								offsetY: '0',
								hideOnMouseOut: true
							},
							thumbstrip: {
								mode: 'vertical',
								position: 'rightpanel',
								relativeTo: 'image'
							}
						});
					}
					return hs.expand(this, { slideshowGroup: this.rev, wrapperClassName: 'hs_image '+hs_wrapperClassName });
				} 
				else {
					return hs.expand(this, { wrapperClassName: 'hs_image '+hs_wrapperClassName });
				}
			}
		}
		else {
			e.element.onclick = function (){
				var params = {};
				params.wrapperClassName = 'hs_html '+hs_wrapperClassName;
				if (this.rev){
					eval('params = '+this.rev+';');
				}
				if (typeof(params) != 'object'){
					params = {};
				}
				params.numberPosition = null;
				params.objectType = type;
				params.captionText = null;
				params.captionEval = null;
				params.headingText = this.title;
				return hs.htmlExpand(this, params);
			};
		}
		// return false to prevent the onclick being set once again
		return false;
	}
};

hs.Expander.prototype.onInit = function(sender){
	if (this.custom && undefined !== this.custom.onDimmerClick && null !== this.custom.onDimmerClick && typeof(this.custom.onDimmerClick) == 'function'){
		hs.onDimmerClick = this.custom.onDimmerClick;
	} else {
		hs.onDimmerClick = function(){ return true; };
	}
	
	var allowedEvents = ['onAfterClose', 'onAfterExpand', 'onAfterGetCaption', 'onAfterGetContent', 'onAfterGetHeading', 'onBeforeClose', 'onBeforeExpand', 
	                     'onBeforeGetCaption', 'onBeforeGetContent', 'onBeforeGetHeading', 'onBlur', 'onCreateFullExpand', 'onCreateOverlay', 'onDoFullExpand', 
	                     'onDrag', 'onDrop', 'onFocus', 'onHideLoading', 'onImageClick', 'onInit', 'onMouseOut', 'onMouseOver', 'onShowLoading'];
	if (this.custom){
		for (var i=0; i<allowedEvents.length; i++){
			var k = allowedEvents[i];
			if (this.custom[k] && typeof(this.custom[k]) == 'function'){
				this[k] = this.custom[k];
			}
		}
	}
};

hs.Expander.prototype.onAfterExpand = function(sender){
	if (sender.iframe){
		sender.iframe.setAttribute('allowTransparency', 'true');
	}
};

function startHSGroup(url, slideshowGroup, link){
	if (null !== link){
		return hs.expand(link, { src: url, slideshowGroup: slideshowGroup, wrapperClassName: 'hs_image '+hs_wrapperClassName })
	} else {
		return hs.expand(null, { src: url, slideshowGroup: slideshowGroup, wrapperClassName: 'hs_image '+hs_wrapperClassName })
	}
};

function startHSFrame(title, url, width, height, modal, loader, custom, params){
	var params = params || {};
	params.src = url;
	if (null !== width){
		params.width = parseInt(width);
	}
	if (null !== height){
		params.height = parseInt(height);
	}
	params.numberPosition = null;
	if (!params.objectType){
		params.objectType = 'iframe';
	}
	params.captionText = null;
	params.captionEval = null;
	params.headingText = title;
	if (true === modal){
		params.wrapperClassName = 'modal-box';
	}
	if (false === loader){
		params.objectLoadTime = 'after';
	}
	var custom = custom || {};
	return hs.htmlExpand(null, params, custom);
};

if (typeof(add_cpt_v2) != 'function'){
	function add_cpt_v2(plus) {

		var nbactuel = (arguments[1] ? parseInt(arguments[1]) : null );
		var action = (arguments[2] ? arguments[2] : null );
		
		if(action == "moins") {
			if(nbactuel)
				plus = nbactuel*-1;
			else 
				plus = -1;		
		}
		if(action == "plus") {
			plus = parseInt(plus);		
			if(plus > 1) {
				// plus = plus;
			} else {
				plus = 1;
			}
		}
		if(action == "personnalisation") {
			plus = parseInt(plus);			
			if(plus > 1) {
				// plus = plus;
			} else {
				plus = 1;
			}
			
		}
		if(document.getElementById('compteur_panier')) {

				compteuractuel = document.getElementById('compteur_panier').innerHTML;
				nouveaucompteur = parseInt(compteuractuel) + parseInt(plus);
				if(nouveaucompteur < 0) nouveaucompteur = 0;	
				document.getElementById('compteur_panier').innerHTML = parseInt(nouveaucompteur);
				
		}
	}
}

/*
// Add the slideshow controller
hs.addSlideshow({
	slideshowGroup: ['images', 'images2'],	
	//interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: '0.6',
		position: 'bottom center',
		offsetX: '0',
		offsetY: '0',
		hideOnMouseOut: true
	},
	thumbstrip: {
		mode: 'vertical',
		position: 'rightpanel',
		relativeTo: 'image'
	}
});
*/

// French language strings
hs.lang = {
	cssDirection: 'ltr',
	loadingText: 'Chargement...',
	loadingTitle: 'Cliquer pour annuler',
	focusTitle: 'Cliquer pour amener au premier plan',
	fullExpandTitle: 'Afficher à la taille réelle',
	creditsText: 'Propulsé par <i>Highslide JS</i>',
	creditsTitle: 'Site Web de Highslide JS',
	previousText: 'Précédente',
	nextText: 'Suivante',
	moveText: 'Déplacer',
	closeText: 'Fermer',
	closeTitle: 'Fermer (esc ou Échappement)',
	resizeTitle: 'Redimensionner',
	playText: 'Lancer',
	playTitle: 'Lancer le diaporama (barre d\'espace)',
	pauseText: 'Pause',
	pauseTitle: 'Suspendre le diaporama (barre d\'espace)',
	previousTitle: 'Précédente (flèche gauche)',
	nextTitle: 'Suivante (flèche droite)',
	moveTitle: 'Déplacer',
	fullExpandText: 'Taille réelle',
	number: 'Image %1 sur %2',
	restoreTitle: 'Cliquer pour fermer l\'image, cliquer et faire glisser pour déplacer, utiliser les touches flèches droite et gauche pour suivant et précédent.'
};


