
function envoi(typ){
        document.my_form.type_selected.value=typ;
        document.my_form.submit();
}
  

function hide_layer(lay){
if (document.all) {
		if (lay!="") {document.all[lay].style.visibility="hidden";}
	}
	if (document.layers) {
	  	if (lay!="") {document.layers[lay].visibility="hide";}
	}
	if (document.getElementById){
	    document.getElementById(lay).style.visibility="hidden";
	}	
}
function show_layer(lay){
    if (document.all) {
		if (lay!="") {document.all[lay].style.visibility="visible";}
	}
	if (document.layers) {
		if (lay!="") {document.layers[lay].visibility="show";}
	}
	if (document.getElementById){
	    document.getElementById(lay).style.visibility="visible";
	}	
}

function show_vm(i){
	for (looping = 0 ; looping < 6 ; looping++ ){
		if ( looping != i ) {
			document.getElementById('vm'+looping).style.display="none";
		} else {
			document.getElementById('vm'+looping).style.display="block";
			//get the child img;
			//change the src (file_name in an array
		   //alert(arrPhotosVm[looping]);

		}
	}
	if(i < 5){
		a = i + 1;
	} else {
		a = 0;
	}
	 $("fili").set({'src' : 'photos/top_'+arrPhotosVm[a] });
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function open_pop(strurl){
	     var pop_up = window.open(strurl,'zoom','width=1024,height=768,resizable=yes,scrollbars=no,menubar=no,status=no');                        
         pop_up.focus();
}

function load_converted_amount(amount, currency_from){
	//alert($('liste_devises').value);
	var currency_to = $('liste_devises').value;
	$('currency_converion').set('html', '<iframe border="0" style="border-width:0;" scroll="none" width="145" height="22" src="inc/ajx_currency_converter.php?from_currency='+currency_from+'&to_currency='+currency_to+'&prix='+amount+'" ></iframe>');
	
}
var myDetail = new Array();
window.addEvent('domready', function(){
	$$('a.open_model_history').each(function(a){
		a.addEvent('click', function(e){
			e.stop();
			linkId = this.get('id');
			arrProductId = linkId.split("_");
			if ($defined(myDetail[arrProductId[1]])){
				//var myVerticalSlide = new Fx.Slide('history_'+arrProductId[1],{duration : 750, fps: 15});
				var myVerticalSlide = new Fx.Slide('history_'+arrProductId[1]);
				myVerticalSlide.slideIn();
				$(linkId).tween('opacity',0);							
			} else {	
				var request = new Request.HTML({
					url: "ajx_model_history.php?ref_model="+arrProductId[1],
					onComplete: function(strHtml){
						$('history_'+arrProductId[1]).setStyles({
							'background-color':'#eee', 
							'padding':'10px',
							'margin': 'auto',
							'width': '440px',
							'text-align' : 'left'
						});
						//var myVerticalSlide = new Fx.Slide('history_'+arrProductId[1],{duration : 750, fps: 15});
						var myVerticalSlide = new Fx.Slide('history_'+arrProductId[1]);
						myVerticalSlide.hide();						
						$('history_'+arrProductId[1]).adopt(strHtml);
						myVerticalSlide.slideIn();
						myDetail[arrProductId[1]] = "loaded";
						//.chain($(linkId).tween('opacity',0));
						$(linkId).tween('opacity',0);
						
						$$('a.fermer').addEvent('click', function(e){
							e.stop();
							myVerticalSlide.toggle();
							$(linkId).tween('opacity',1);
						});
						
	 				}
	 			}).send();
			}
			return false ;
		});				
	});
	
	$$('a.open_mark_history').each(function(a){
		a.addEvent('click', function(e){
			e.stop();
			linkId = this.get('id');
			arrProductId = linkId.split("_");
			if ($defined(myDetail[arrProductId[1]])){
				//var myVerticalSlide = new Fx.Slide('history_'+arrProductId[1],{duration : 750, fps: 15});
				var myVerticalSlide = new Fx.Slide('history_'+arrProductId[1]);
				myVerticalSlide.slideIn();
				$(linkId).tween('opacity',0);							
			} else {	
				var request = new Request.HTML({
					url: "ajx_mark_history.php?ref_mark="+arrProductId[1],
					onComplete: function(strHtml){
						$('history_'+arrProductId[1]).setStyles({
							'background-color':'#ddd', 
							'padding':'20px', 
							'width': '460px',
							'text-align' : 'left'
						});
						//var myVerticalSlide = new Fx.Slide('history_'+arrProductId[1],{duration : 750, fps: 15});
						var myVerticalSlide = new Fx.Slide('history_'+arrProductId[1]);
						myVerticalSlide.hide();						
						$('history_'+arrProductId[1]).adopt(strHtml);
						myVerticalSlide.slideIn();
						myDetail[arrProductId[1]] = "loaded";
						//.chain($(linkId).tween('opacity',0));
						$(linkId).tween('opacity',0);
						
						$$('a.fermer').addEvent('click', function(e){
							e.stop();
							myVerticalSlide.toggle();
							$(linkId).tween('opacity',1);
						});
						
	 				}
	 			}).send();
			}
			return false ;
		});				
	});	
});

