/* comparatif */

var vgraph = {
	vpool : [],	vdroplist : [],vombre : [], vombrebas : [], vombretop: [], vombreHeight: null, timeoutvar : [], langt : [], impool: [], txt: [],
	mouseOverState : 0,

	set : function(){
		if (document.getElementById("vgraph")==undefined)  return;//break

		var graphdiv = document.getElementById("vgraph").getElementsByTagName("DIV");
		for(var i=0;i<graphdiv.length;i++){
			if (graphdiv[i].className =="car") vgraph.vpool[vgraph.vpool.length] = graphdiv[i];
			if (graphdiv[i].className =="droplist") vgraph.vdroplist[vgraph.vdroplist.length] = graphdiv[i];
			if (graphdiv[i].className =="ombre1") vgraph.vombretop[vgraph.vombretop.length] = graphdiv[i];
			if (graphdiv[i].className =="ombre2") vgraph.vombre[vgraph.vombre.length] = graphdiv[i];
			if (graphdiv[i].className =="ombre3") vgraph.vombrebas[vgraph.vombrebas.length] = graphdiv[i];
			if (graphdiv[i].className =="txt") vgraph.txt[vgraph.txt.length] = graphdiv[i];
		}
		if (vgraph.vpool.length<1) return;//break
		this.vombreHeight = vgraph.vombre[0].offsetHeight;

		if(isIE) {// IE
			for(var i=0;i<graphdiv.length;i++){
				if (graphdiv[i].className =="image") vgraph.impool[vgraph.impool.length] = graphdiv[i];
				if (graphdiv[i].className.indexOf("langette")>=0) vgraph.langt[vgraph.langt.length] = graphdiv[i];
			}

			for (var i=0;i<vgraph.impool.length;i++){
				vgraph.impool[i].saveVarI = i;
				vgraph.vdroplist[i].saveVarI = i;
				vgraph.impool[i].onmouseover = vgraph.vdroplist[i].onmouseover = function(){
					vgraph.mouseover(this.saveVarI);
					vgraph.mouseOverState = 1;
				}
			}
			for (var i=0;i<vgraph.langt.length;i++){
				vgraph.langt[i].saveVarI = i;
				vgraph.langt[i].onmouseover = function(){
					vgraph.mouseover(this.saveVarI);
					vgraph.mouseOverState = 1;
				}
			}

		} else {
			for (var i=0;i<vgraph.vpool.length;i++){
				vgraph.vpool[i].saveVarI = i;
				vgraph.vpool[i].onmouseover = function(){
					vgraph.mouseover(this.saveVarI);
					vgraph.mouseOverState = 1;
				}
			}
		}
		for (var i=0;i<vgraph.vombre.length;i++){
			vgraph.vombretop[i].saveVarI = i;
			vgraph.vombrebas[i].saveVarI = i;
			vgraph.vombre[i].saveVarI = i;
			vgraph.vombre[i].onmouseout = vgraph.vombrebas[i].onmouseout = vgraph.vombretop[i].onmouseout = function(){
				vgraph.timeoutvar[this.saveVarI] = setTimeout("vgraph.close("+this.saveVarI+")", 100);
				vgraph.mouseOverState  =0;
			}
		}

	},
	mouseover : function(n){
		this.reset(n);
		vgraph.vpool[n].style.zIndex = 21;
		clearTimeout(vgraph.timeoutvar[n]);
		vgraph.timeoutvar[n] = setTimeout("vgraph.droplist("+n+")", 20);
	},
	droplist : function(n){
		if (vgraph.vdroplist[n].style.display!='block') {
			vgraph.vdroplist[n].style.display = 'block';
			vgraph.vombre[n].style.height = (parseFloat(vgraph.vpool[n].offsetHeight)-22)+"px";

			if(isIE) {// IE
//				vgraph.vpool[n].style.height= vgraph.vombre[n].style.height;
				vgraph.ieReposition(n, vgraph.txt[n].offsetHeight);
			}
		}
	},
	reset : function(n){
		for (var i=0;i<vgraph.vpool.length;i++){
			vgraph.vpool[i].style.zIndex = 20;
			if (n!=i) {
				vgraph.vombre[i].style.height = this.vombreHeight+"px";
				vgraph.vdroplist[i].style.display = 'none';

				if(isIE) {// IE
//					vgraph.vpool[i].style.height= this.vombreHeight+"px";
					vgraph.ieReposition(i, 0);
				}
			}
		}
	},
	close : function(n){
		if (this.mouseOverState == 0) {
			vgraph.vombre[n].style.height = this.vombreHeight+"px";
			vgraph.vdroplist[n].style.display = 'none';
			if(isIE) {// IE
//				vgraph.vpool[n].style.height= this.vombreHeight+"px";
				vgraph.ieReposition(n, 0);
			}
		}
	},
	ieReposition : function(n,h){
		vgraph.vombrebas[n].style.position = "absolute";
//		vgraph.vombrebas[n].style.bottom = "-12px";
		vgraph.vombrebas[n].style.top = (h+93)+"px";
	}
}

var compartable = {
	tabgroup : [],tablink : [],tabarrow : [],
	set : function(){
		if (document.getElementById("comparetable")==undefined)  return;
		var tabldiv = document.getElementById("comparetable").getElementsByTagName("DIV");
		for(var i=0;i<tabldiv.length;i++){
			if (tabldiv[i].className.search("tabgroup")>=0) compartable.tabgroup[compartable.tabgroup.length] = tabldiv[i];
			if (tabldiv[i].className == "handcursor") compartable.tablink[compartable.tablink.length] = tabldiv[i];
		}
		var tablspan = document.getElementById("comparetable").getElementsByTagName("IMG");
		for(var i=0;i<tablspan.length;i++){
			if (tablspan[i].className == "arrow") compartable.tabarrow[compartable.tabarrow.length] = tablspan[i];
		}
		for (var i=0;i<compartable.tablink.length;i++){
			compartable.tablink[i].saveVarI = i;
			compartable.tablink[i].onclick = function(){
				compartable.clicAction(this.saveVarI);
			}
		}
		if(compartable.tablink.length>0) compartable.clicAction(0);// open first default
	},
	clicAction : function(n){
		if (compartable.tabgroup[n].className.search('hide')>=0) {
			compartable.tabgroup[n].className = compartable.tabgroup[n].className.replace('hide', '');
			compartable.tabarrow[n].src="_img/comparatif/arrow_on.gif";
		} else {
			compartable.tabgroup[n].className += ' hide';
			compartable.tabarrow[n].src="_img/comparatif/arrow_off.gif";
		}
	}
}

//||// //-|| //))
var dropselect = {
	aPool : [], selectPool : [], dropselectdiv : [], selectDIV : [], selectSPAN : [], selectA : [], docForm : null,
	set : function(oForm, selectIDs){
		if (document.getElementById("dropselect")==undefined)  return;//break
		this.docForm = oForm;

		this.dropselectdiv = selectIDs;
		for(var i=0;i<this.dropselectdiv.length;i++){
			this.selectPool[i]= document.getElementById(this.dropselectdiv[i]);
			this.selectDIV[i]	= document.getElementById(this.dropselectdiv[i]).getElementsByTagName("DIV");//1 seule div
			this.selectSPAN[i]= document.getElementById(this.dropselectdiv[i]).getElementsByTagName("SPAN");//1 seul span
			this.selectA[i]	= document.getElementById(this.dropselectdiv[i]).getElementsByTagName("A");//+ieurs a
		}

		for (var i=0;i<this.selectDIV.length;i++){
			this.selectDIV[i][0].saveVarI = i;
			this.selectSPAN[i][0].saveVarI = i;
			this.selectDIV[i][0].onclick = this.selectSPAN[i][0].onclick = function(){
				dropselect.deploy(this.saveVarI);
			}
		}

		for(var i=0;i<this.selectA.length;i++){
			for(var j=0;j<this.selectA[i].length;j++){
				this.selectA[i][j].saveVarI = i;
				this.selectA[i][j].saveVarj = j;
				this.selectA[i][j].onclick = function(){
					dropselect.selectVal(this.saveVarI, this.saveVarj);
					return false;
				}
			}
		}
	},
	deploy : function(n){
		if (parseFloat(this.selectPool[n].style.height)>14) {
			this.reset();
		} else {
			this.selectDIV[n][0].innerHTML = '<img src="_img/comparatif/dropdown1.gif" border="0" width="16" height="14" alt="">';
			this.selectPool[n].style.height = ((this.selectA[n].length*14)+14)+"px";//+14 car span non compte
		}
	},
	reset : function(){
		for(var i=0;i<this.dropselectdiv.length;i++){
			this.selectDIV[i][0].innerHTML = '<img src="_img/comparatif/dropdown0.gif" border="0" width="16" height="14" alt="">';
			this.selectPool[i].style.height = "14px";
		}
	},
	selectVal : function(n, m){
		this.reset();
		this.docForm.elements[n].value = this.selectA[n][m].className;
		this.selectSPAN[n][0].innerHTML = this.selectA[n][m].innerHTML;
	}
}

var compareForm = {
	docForm : null,
	set : function(){
		this.docForm = document.changevalues;
		this.docForm.onsubmit = "";
		this.docForm.onsubmit = function () {
			if(compareForm.compareTest()==false) {
				$('stopcompare').show();
				return false;
			}
		}
	},
	compareTest : function (){
		if (this.docForm.postVal1.value==this.docForm.postVal2.value) return false;
		return true;
	}

}