var effect = 1;
var time = 10000;

var current_image = 0;
var next_image = 1;
var image = new Array();


var Accordion = Class.create();

Accordion.prototype = {
	initialize: function(id, tag, name) {
		this.id = id;
		this.headerTag = tag.toUpperCase();
		this.instance = name;
		this.headingClassName = (arguments[3] || "panel");
		this.contentClassName = (arguments[4] || "panelBody");
		this.panels = new Array();

		var tags = $(id).getElementsByTagName('*');		
		for ( var i = 0; i < tags.length; i++) {
			switch(tags.item(i).tagName) {
				case this.headerTag:
					tags.item(i).style.cursor = "pointer";
					tags.item(i).onclick = this._returnEvalCode(this.instance);
					break;

				default:
					if (tags.item(i).className == this.headingClassName) {
						tags[i]._index = this._returnIndex(this.panels.length);
						this.panels[this.panels.length] = tags.item(i);
						//the line above is same meaning as "this.panels.push(tags.item(i));"
						
						if (this.panels.length == 1) {
							tags.item(i).id = "visible";
						}
					}

					if (tags.item(i).className == this.contentClassName) {
						tags.item(i).style.display = "none";
					}
					break;

			}
		}
		this.length = this.panels.length;
		this.show(0, true);
	},

	show: function(index, force) {
		if ( (index >= this.length) || (index < 0) ) {
			//alert("index out of range");
			return;
		}

		if ( $('visible') == this.panels[index] ){
			if (force) {
				//alert("force to show the visible element.");
				for(var i = 0; i < this.length; i++) {
					if(this._body(this.panels[i]).style.display != "none") {
						new Effect.SlideUp(this._body(this.panels[i]));
					}
				}
				new Effect.SlideDown(this._body(this.panels[index]));
				return;
			}
			
			//alert("it's already shown now.");
			return;
		}

		//alert("show another element.");
		new Effect.Parallel(
			[
				new Effect.SlideUp( this._body($('visible')) ),
				new Effect.SlideDown( this._body(this.panels[index]) )
			], {
				duration: 0.2
			}
		);
	
		$('visible').id = "";
		this.panels[index].id = "visible";
		return;
	},

	_body: function(e) {
		var tags = e.getElementsByTagName('*');
		for( var i=0; i<tags.length; i++) {
			if (tags.item(i).className == this.contentClassName) {
				return tags.item(i);
			}
		}
	},

	_returnIndex: function(i) {
		return function() {
			return i;
		}
	},

	_returnEvalCode: function(s) {
		return function(){
			eval(s + ".show(" + this.parentNode._index() + ");");
		}
	}
};


function imprimer() {
window.print();
}

function galerie() {
	self.setTimeout("nextimage()",time);	
}
function nextimage() {
	if(effect == 1) { new Effect.Fade(image[current_image]); new Effect.Appear(image[next_image]); }
	if(effect == 2) { new Effect.BlindUp(image[current_image]); new Effect.BlindDown(image[next_image]); }
	
	if(next_image == (image.length-1)) {
		current_image = next_image;
		next_image = 0;
	} else {
		current_image = next_image;
		next_image++;
	}
	galerie();
}


function carsuiv(e) {
	
	Event.stop(e);
	if(Element.getStyle('items','left')==limite_carousel+'px') {Element.setStyle('car_next',{display:'none'})}
	if(Element.getStyle('car_previous','display')=='none')
		{Element.setStyle('car_previous',{display:'block'})}
	new Effect.Move('items', { x: -495, y: 0 });

	
}
function carprec(e) {
	Event.stop(e);
	if(Element.getStyle('items','left')!='2px') {
		if(Element.getStyle('car_next','display')=='none')
		{Element.setStyle('car_next',{display:'block'})}
	new Effect.Move('items', { x: 495, y: 0 });
	
	if(Element.getStyle('items','left')=='-493px') {Element.setStyle('car_previous',{display:'none'})}
	}
}

function changehistory1() {
	//on voudra passer celui ci en highlight
	$('history1').setStyle({
    	opacity : '0.99'
});
	//on voudra aussi passer tous les autres en lowlight
	$('history4').setStyle({
    	opacity : '0.7'
});	$('history2').setStyle({
    	opacity : '0.7'
});	$('history3').setStyle({
    	opacity : '0.7'
});
	
	var titre="Lâg History and Evolution";
	var video="<object id=\"player_video\" name=\"player_video1\" type=\"application/x-shockwave-flash\" data=\"lecteur_videos_variable.swf\" width=\"542\" height=\"444\"><param name=\"movie\" value=\"lecteur_videos_variable.swf\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value=\"nomvideo=1-history-evolution\" /><param name=\"quality\" value=\"high\" /><param name=\"pluginspage\" value=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" /><p>Flash required</p></object>";
	var paragraphe="Hi everybody! Let me briefly introduce myself: I am Michel Lâg-Chavarria, founder and master luthier of Lâg Guitars. Aside from my family and my studies, I've always dedicated my whole life to music and the arts in general, with a special addiction for guitars, but also for photography, poetry, and nature.<br />In 1978, after 8-years of experience as a guitar-player and singer in several French pop and rock bands, I started on the crazy (but so exciting) project to create and produce high-end guitars in Toulouse, in the South-West of France, a city well-known for its famous artists and its really active music scene!<br />I first started an efficient and reliable repair shop dedicated to all stringed instruments. This shop brought a lot of knowledge and experience, as well as many different and interesting customers through our Custom Shop models! Then, thanks to many musician friends who had built a great image for Lâg guitars on stage and in studio, we introduced our first creations to guitar dealers and players; in France first, then all around Europe, with a lot of success.<br />Lâg Haute Couture workshop is now located in Bédarieux, a wonderful area in the South-East of France, not far from the Mediterranean Sea, set among vineyards and olive trees… On a philosophical point of view, our global strategy, with the help of talented designers and expert technicians, has always been to avoid stereotypes, exorbitantly priced and over-used guitar designs, and to bring some refinement and style to the guitar world.<br />In 2002, I met Gérard Garnier, President of Algam group, France's largest musical instrument distributor. This meeting was a major step in the creative and international evolution of the brand. Now we all know that quality requires imagination, time, and hard work. After more than 25 years of experience and passion, Lâg is finally in America – thanks to our partnership with Korg USA.";
	
	$('titrehistoire').innerHTML=titre;
	$('parahistoire').innerHTML=paragraphe;
	$('videohistoire').innerHTML=video;
}

function changehistory2() {
	//on voudra passer celui ci en highlight
	$('history2').setStyle({
    	opacity : '0.99'
});
	//on voudra aussi passer tous les autres en lowlight
	$('history1').setStyle({
    	opacity : '0.7'
});	$('history4').setStyle({
    	opacity : '0.7'
});	$('history3').setStyle({
    	opacity : '0.7'
});
	var titre="Lâg Acoustic Guitar Philosophy";
	var video="<object id=\"player_video\" name=\"player_video1\" type=\"application/x-shockwave-flash\" data=\"lecteur_videos_variable.swf\" width=\"542\" height=\"444\"><param name=\"movie\" value=\"lecteur_videos_variable.swf\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value=\"nomvideo=2-lag-acoustic-guitar-philosophy\" /><param name=\"quality\" value=\"high\" /><param name=\"pluginspage\" value=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" /><p>Flash required</p></object>";
	var paragraphe="The name Tramontane comes from a beloved wind that blows through the mountains in the South of France, known for chasing away clouds and bad weather, and bringing back deep blue skies and bright smiles to our face. The Tramontane range represents five years of creative and technical work. Our main concern was to come up with something really new and different.<br />First, is the sound. The key features include beautiful, natural, highly selected and combined woods as well as the huge care taken in the cutting process, precision of assembly methods, drying processes, humidity control and stabilization. Nothing is taken for granted. These carefully crafted designs, sophisticated and harmonious finishes, and new combinations of materials reveal our passion for beauty in a market where, up to now, aesthetics didn't always figure.<br />The Tramontane headstock is the most recognizable sign of a Lâg guitar. It is the beacon – the unique jewel – that everybody will recognize from a distance, with its elegantly sculpted two-step top, made of solid noble woods such as rosewood or ebony and embellished by a real maple Lâg logo inlay. With Lâg, you enter a universe comprised of genuine and refined wood compositions. From the bindings to the rosette marquetry – including the Occitan cross symbol from our area of France – perfectly matching the material and curves of the fingerboard, the bridge and the heel plate; all this is globally enhanced by generously profiled body shapes.<br />When it comes to electronics, we also pay the greatest attention to offer the best-sounding, the most innovative, and yet user-friendly pre-amps and equalizers available to musicians in the guitar market. We do this with our unique STUDIOLÂG analog systems with sound presets. Combining the know-how of creating French-made high-end \"custom shop\" guitars with that of mass-production, the Lâg team is now shaking up the guitar market with the Tramontane series – custom shop quality and tone available to everyone.";
	
	$('titrehistoire').innerHTML=titre;
	$('parahistoire').innerHTML=paragraphe;
	$('videohistoire').innerHTML=video;
}

function changehistory3() {
	//on voudra passer celui ci en highlight
	$('history3').setStyle({
    	opacity : '0.99'
});
	//on voudra aussi passer tous les autres en lowlight
	$('history1').setStyle({
    	opacity : '0.7'
});	$('history2').setStyle({
    	opacity : '0.7'
});	$('history4').setStyle({
    	opacity : '0.7'
});
	var titre="Lâg Woods";
	var video="<object id=\"player_video\" name=\"player_video1\" type=\"application/x-shockwave-flash\" data=\"lecteur_videos_variable.swf\" width=\"542\" height=\"444\"><param name=\"movie\" value=\"lecteur_videos_variable.swf\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value=\"nomvideo=5-lag-woods\" /><param name=\"quality\" value=\"high\" /><param name=\"pluginspage\" value=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" /><p>Flash required</p></object>";
	var paragraphe="Tramontane guitars are unique and highly responsive due to the careful selection and combinations of woods. We use Sitka Spruce, Red Cedar, Mahogany and Rosewood.<br />The best Sitka Spruce has a very narrow and tight grain, which brings a very precise, sharp and dynamic sound. Of course, its character changes a lot when paired with Mahogany or with Rosewood, but in each situation, the most important feature remains clarity of tone and beauty of sound. <br />Red Cedar has many gorgeous features. First, it immediately gives a guitar a warm, deep sound with a perfect balance between bass and mids, without losing any precision in the high tones. Then, it becomes \"aged\" and in perfect harmony with the back & sides very quickly, which is a big advantage. Red Cedar, combined with Mahogany or with Rosewood, always brings this unique natural warm color, both in sound and visual aspects.<br />For the necks, Mahogany is the best wood to offer the perfect sound transmission to the body. It brings an additional natural resonance which is very important; sustain and depth – and a real acoustic feeling – comes from it. Regarding the back and sides, Mahogany is the best wood for warmth and lovely low-mid tones. This gives our guitars a kind of natural and deep snarl, and a perfect feeling that the guitar body is in resonance with your own body, which is an extremely organic playing experience.<br />For fingerboards, we select our Rosewoods for their consistency, their perfect dryness and stability, and for their dark and straight beauty. The most beautiful and figured pieces are selected for back & sides. Rosewood brings something very unique among all the other woods: highest precision, best dynamics, depth, power, and sustain without losing any mid-warmth. This is a very high-end material – exotic, noble and wonderful!<br />Besides the wood, the braces of the guitars are a major subject. They really help the sound to breathe and to move in the right way, giving the insurance of stability and the best resonance at the same time. At LÂG, we use the straightest, most consistent and most stable braces on all our guitars.";
	
	
	$('titrehistoire').innerHTML=titre;
	$('parahistoire').innerHTML=paragraphe;
	$('videohistoire').innerHTML=video;
}

function changehistory4() {
	//on voudra passer celui ci en highlight
	$('history4').setStyle({
    	opacity : '0.99'
});
	//on voudra aussi passer tous les autres en lowlight
	$('history1').setStyle({
    	opacity : '0.7'
});	$('history2').setStyle({
    	opacity : '0.7'
});	$('history3').setStyle({
    	opacity : '0.7'
});
	
	var video="<object id=\"player_video\" name=\"player_video1\" type=\"application/x-shockwave-flash\" data=\"lecteur_videos_variable.swf\" width=\"542\" height=\"444\"><param name=\"movie\" value=\"lecteur_videos_variable.swf\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value=\"nomvideo=6-conclusion-consumer\" /><param name=\"quality\" value=\"high\" /><param name=\"pluginspage\" value=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" /><p>Flash required</p></object>";
	var paragraphe='Thank you for taking time to learn about LÂG acoustic guitars and the Tramontane range of instruments. We hope you try a Tramontane guitar at a dealer near you and that you find the perfect model for your own style. We appreciate how important your music is to you, and we’ve put much care into creating instruments you’ll enjoy, no matter what your budget. We wish you many years of enjoyment with your own LÂG guitar.';
	
	
	$('titrehistoire').innerHTML='Thanks!';
	$('parahistoire').innerHTML=paragraphe;
	$('videohistoire').innerHTML=video;
}

function hoverbuy() {
	this.src="private/interface/wtb2.png";
	Event.observe('buy', 'mouseout', exithoverbuy, false);
}
function exithoverbuy() {
	this.src="private/interface/wtb.png";
	Event.observe('buy', 'mouseover', hoverbuy, false);
}
function hoverchose() {
	this.src="private/interface/"+this.alt+"2.png";
	Event.observe(this, 'mouseout', exithoverchose, false);
}
function exithoverchose(e) {
	this.src="private/interface/"+this.alt+".png";
	Event.observe(this, 'mouseover', hoverchose, false);
}

function initcordeon() {
	cordeon = document.getElementsByClassName("panelBody");
		for(i=0; i < cordeon.length; i++) {
			cordeon[i].toggle();
			//var elementicone = cordeon[i].previousSibling;
			//elementicone.setStyle({'cursor':'pointer'});
			Event.observe(cordeon[i].previousSibling, 'click', togglecordeon);
		}
	globalement = document.getElementsByClassName("showsousgroupes");
		for(i=0; i < globalement.length; i++) {
			globalement[i].setStyle({'cursor':'pointer'});
			Event.observe(globalement[i], 'click', showsousgroupes);
		}
}

function showsousgroupes() {
	if(this.alt=="cas1")
	{this.src="private/interface/fleche_h3_sud.png";
	this.alt='cas2';
	cordeon = this.parentNode.nextSibling.getElementsByClassName("panelBody");
		for(i=0; i < cordeon.length; i++) {		
			//on regarde d'abord si on a besoin de faire l'effet
			if(cordeon[i].previousSibling.firstChild.alt=='cas1')
			new Effect.SlideDown(cordeon[i],{duration:0.1});
			//il faut d'abord changer l'image et le alt du h4
			cordeon[i].previousSibling.firstChild.src="private/interface/fleche_sud.png";
			cordeon[i].previousSibling.firstChild.alt='cas2';			
		}
	}
	else {
	this.src="private/interface/fleche_h3_est.png";
	this.alt='cas1';
	cordeon = this.parentNode.nextSibling.getElementsByClassName("panelBody");
		for(i=0; i < cordeon.length; i++) {		
			//on regarde d'abord si on a besoin de faire l'effet
			if(cordeon[i].previousSibling.firstChild.alt=='cas2')
			new Effect.SlideUp(cordeon[i],{duration:0.1});
			//il faut d'abord changer l'image et le alt du h4
			cordeon[i].previousSibling.firstChild.src="private/interface/fleche_est.png";
			cordeon[i].previousSibling.firstChild.alt='cas1';		
		}
	}	
}

function togglecordeon(e) {
	if(this.firstChild.alt=="cas1")
	{this.firstChild.src="private/interface/fleche_sud.png";
	this.firstChild.alt='cas2';
	new Effect.SlideDown(this.nextSibling,{duration:0.1})}
	else {
	this.firstChild.src="private/interface/fleche_est.png";
	this.firstChild.alt='cas1';
	new Effect.SlideUp(this.nextSibling,{duration:0.1})}
}

function toggleparahistoire() {
	new Effect.toggle('parahistoire','slide',{duration:0.1});
}

function toglistartists() {
	new Effect.toggle('selecteurartistes','blind',{duration:0.4});	
}

function gestionevents() {
	if(document.getElementById("car_next")){Event.observe('car_next', 'click', carsuiv, false);}
	if(document.getElementById("car_next")){Event.observe('car_previous', 'click', carprec, false);}

	var modulo = (document.getElementsByClassName('item').length%5)*2;
	switch (modulo)
		{
		case 2: var pivot=document.getElementsByClassName('item').length+4;break;
		case 4: var pivot=document.getElementsByClassName('item').length+3;break;
		case 6: var pivot=document.getElementsByClassName('item').length+2;break;
		case 8: var pivot=document.getElementsByClassName('item').length+1;break;
		case 0: var pivot=document.getElementsByClassName('item').length;break;
		}	
	limite_carousel = (-(pivot - 10)*99)+2;
	if(document.getElementsByClassName('item').length>5) {Element.setStyle('car_next',{display:'block'})}

	if(document.getElementsByClassName("image")) {
		image = document.getElementsByClassName("image");
		for(i=1; i < image.length; i++) {
			image[i].style.display = "none";
		}
	}
	
	if(image.length > 1) galerie();

	if($('printbutton')){Event.observe('printbutton','click',imprimer);}

	//juste ici, si ya un espace Carroussel vide, on le vire.
	if(document.getElementById("Carousel2")){if(document.getElementById("items").innerHTML==''){$('Carousel2').setStyle({'display':'none'});}}

	if(document.getElementById("history1")){Event.observe('history1', 'click', changehistory1, false);$('history1').setStyle({
    	opacity : '0.99'
});}
	if(document.getElementById("history2")){Event.observe('history2', 'click', changehistory2, false);}
	if(document.getElementById("history3")){Event.observe('history3', 'click', changehistory3, false);}
	if(document.getElementById("history4")){Event.observe('history4', 'click', changehistory4, false);}
	
	if(document.getElementById("buy")){Event.observe('buy', 'mouseover', hoverbuy, false);}
	
	if(document.getElementById("youtube")){Event.observe('youtube', 'mouseover', hoverchose, false);}
	if(document.getElementById("myspace")){Event.observe('myspace', 'mouseover', hoverchose, false);}
	if(document.getElementById("facebook")){Event.observe('facebook', 'mouseover', hoverchose, false);}
	if(document.getElementById("twitter")){Event.observe('twitter', 'mouseover', hoverchose, false);}
	if(document.getElementById("buttonartist")){
			new Effect.toggle('selecteurartistes','blind',{duration:0.3});	
			Event.observe('buttonartist', 'mouseover', toglistartists, false);
			}
	if(document.getElementById("accordion")){initcordeon();}
	if(document.getElementById("parahistoire")){toggleparahistoire();Event.observe('showpara', 'click', toggleparahistoire, false);}
}

var limite_carousel;
Event.observe(window, 'load', gestionevents, false);

