function getSize(id){ 
  
  var url = 'size.php?id='+id;
	  var pars = 'id=' + id;
	  
	  var myAjax = new Ajax.Request(
	  url, 
	  {
		  method: 'POST', 
		  parameters: pars, 
		  onComplete: showResponse
	  });
	   
			   
}
function showResponse(originalRequest){
if(originalRequest.responseText!=''){
$('div').innerHTML =originalRequest.responseText;
return true;
  }
  else{
  $('div').innerHTML ='';
  }
}
function getdescription(id){ 
  
  var url = 'description.php?id='+id;
	  var pars = 'id=' + id;
	  
	  var myAjax = new Ajax.Request(
	  url, 
	  {
		  method: 'POST', 
		  parameters: pars, 
		  onComplete: showResponse2
	  });
	   
			   
}
function showResponse2(originalRequest){
if(originalRequest.responseText!=''){
$('sizedescription').innerHTML =originalRequest.responseText;
return true;
  }
  else{
  $('sizedescription').innerHTML ='';
  }
}


function vidersize(){
$('size').innerHTML='';
$('ssp').innerHTML='';
$('l').innerHTML='';
$('basket').innerHTML='';
$('basketfirst').innerHTML='';
$('sizetext').value='';
$('refmat').value='';
$('leathertext').value='';
$('sptext').value='';
$('lt').style.display='none';
if($('ltfirst')!=null)$('ltfirst').innerHTML='';
if($('spfirst')!=null)$('spfirst').innerHTML='';
$('sp').style.display='none';
$('materialtext').value='';
$('refdescription').innerHTML='';
}
function vidersize2(){
	$('refn').innerHTML='';
$('size').innerHTML='';
$('ssp').innerHTML='';
$('l').innerHTML='';
$('basket').innerHTML='';
$('basketfirst').innerHTML='';
$('sizetext').value='';
$('refmat').value='';
$('leathertext').value='';
$('sptext').value='';
$('lt').style.display='none';
$('sp').style.display='none';
if($('ltfirst')!=null)$('ltfirst').innerHTML='';
if($('spfirst')!=null)$('spfirst').innerHTML='';
$('materialtext').value='';
$('refdescription').innerHTML='';
}

function showme2(obj){
var text= obj.options[obj.selectedIndex].text;
var ref= obj.options[obj.selectedIndex].value;
//alert(ref);
var mytool_array=ref.split(":",5);
// mytool_array[0] the number 
//mytool_array[1] the ref 
//mytool_array[2] the description of the ref 
//mytool_array[3] the description of the size 
ref=mytool_array[1];
reference=mytool_array[2];
description = mytool_array[3];
sizetitre=mytool_array[4];
//alert(mytool_array[5]);
//////// fill the hidden values for the basket
$('refmat').value=ref;
$('materialtext').value=text;
$('sizetext').value=sizetitre;
/// these values are a hidden fields in the file size.php 	
var photo=$('photo'+mytool_array[0]).value;
var lt=$('l'+mytool_array[0]).value;
var sp=$('sp'+mytool_array[0]).value;
/////

if(text!='Select material')
{


///// set the span id material of the name of the material
///// fill the span id material2 
if(ref!='')$('refn').innerHTML=' Ref: '+ref;
$('refdescription').innerHTML=reference;
$('size').innerHTML=' | '+sizetitre;
//fill the photo and if the photo of the material dosen't exist we fill it by the photo of the product 
if(photo!='')$('imagemat').innerHTML='<img src="uploads/sizes/'+photo+'" >';
else {photoprod=$('photo').value;
$('imagemat').innerHTML='<img src="uploads/products/'+photoprod+'" >';}

//////////// display the add to baskett div//////////////////////////////
var html='<div><a href="#" onclick="document.form.submit();"><img src="images/bskt.gif" alt="add to basket" border="0" /></a></div>';
$('basket').innerHTML=html;
$('basketfirst').innerHTML='';
////////
// if the name of material is Stainless steel bright the div id material  is blank

// if the field leather id cheked for this material we display the div of leather
if(lt=="yes"){$('lt').style.display = 'block';
$('leatherbox').checked =false;
if($('ltfirst')!=null)$('ltfirst').innerHTML='';

}
if(lt=="no" || lt==''){$('lt').style.display = 'none';
$('leatherbox').checked =false;
//$('ltfirst').innerHTML='';
}
//if($('ltfirst').innerHTML!='')$('leatherbox2').checked =false;

$('l').innerHTML='';
$('leathertext').value='';

// if the field sp is cheked for this material we display the div of silver plated
if(sp=="yes"){
$('sp').style.display = 'block';
$('spbox').checked =false;
if($('spfirst')!=null)$('spfirst').innerHTML='';
}
if(sp=="no" || sp==''){$('sp').style.display = 'none';
$('spbox').checked =false;
//$('spfirst').innerHTML='';
}
//if($('spfirst').innerHTML!='')$('spbox2').checked =false;

$('ssp').innerHTML='';
$('sptext').value='';
}
else 
{
var photo=$('photo').value;
$('imagemat').innerHTML='<img src="uploads/products/'+photo+'" >';
vidersize();
}

}

function showme22(obj){
var text= obj.options[obj.selectedIndex].text;
var ref= obj.options[obj.selectedIndex].value;
//alert(ref);
var mytool_array=ref.split(":",5);
// mytool_array[0] the number 
//mytool_array[1] the ref 
//mytool_array[2] the description of the ref 
//mytool_array[3] the description of the size 
ref=mytool_array[1];
reference=mytool_array[2];
description = mytool_array[3];
sizetitre=mytool_array[4];
//alert(mytool_array[5]);
//////// fill the hidden values for the basket
$('refmat').value=ref;
$('materialtext').value=text;
$('size').value=sizetitre;
/// these values are a hidden fields in the file size.php 	
var photo=$('photo'+mytool_array[0]).value;
var lt=$('l'+mytool_array[0]).value;
var sp=$('sp'+mytool_array[0]).value;
/////

if(text!='Select material')
{

///// fill the span id material2 
if(ref!='')$('refn').innerHTML=' Ref: '+ref ;
$('refdescription').innerHTML=reference;
$('size').innerHTML=' | '+sizetitre;
//$('size').innerHTML=' | '+$('size').innerHTML;
//fill the photo and if the photo of the material dosen't exist we fill it by the photo of the product 
if(photo!='')$('imagemat').innerHTML='<img src="uploads/sizes/'+photo+'" >';
else {photoprod=$('photo').value;
$('imagemat').innerHTML='<img src="uploads/products/'+photoprod+'" >';}


// if the field leather id cheked for this material we display the div of leather
if(lt=="yes"){$('lt').style.display = 'block';
$('leatherbox').checked =false;
if($('ltfirst')!=null)$('ltfirst').innerHTML='';
}
if(lt=="no" || lt==''){$('lt').style.display = 'none';
$('leatherbox').checked =false;
if($('ltfirst')!=null)$('ltfirst').innerHTML='';
}
if( $('ltfirst')!=null && $('ltfirst').innerHTML!='')$('leatherbox2').checked =false;
$('l').innerHTML='';
$('leathertext').value='';

// if the field sp is cheked for this material we display the div of silver plated
if(sp=="yes"){
$('sp').style.display = 'block';
$('spbox').checked =false;
if($('spfirst')!=null)$('spfirst').innerHTML='';
}
if(sp=="no" || sp==''){$('sp').style.display = 'none';
$('spbox').checked =false;
if($('spfirst')!=null)$('spfirst').innerHTML='';
}
if($('spfirst').innerHTML!='')$('spbox2').checked =false;
$('ssp').innerHTML='';
$('sptext').value='';

//////////// display the add to baskett div//////////////////////////////
var html='<div><a href="#" onclick="document.form.submit();"><img src="images/bskt.gif" alt="add to basket" border="0" /></a></div>';
$('basket').innerHTML=html;
$('basketfirst').innerHTML='';
////////


}
else 
{
var photo=$('photo').value;
$('imagemat').innerHTML='<img src="uploads/products/'+photo+'" >';
vidersize();
}



}






function showleather(textleather){
if($('leatherbox').checked==true){
$('l').innerHTML="L";
$('refmat').value=$('refmat').value+$('l').innerHTML;
$('leathertext').value="Leather";}
else { var refl=$('refmat').value
var mytool_array=refl.split("L");
$('refmat').value=mytool_array[0];
$('l').innerHTML='';
$('leathertext').value='';
}
}
function showleather2(textleather){
if($('leatherbox2').checked==true){
$('l').innerHTML="L";
$('refmat').value=$('refmat').value+$('l').innerHTML;
$('leathertext').value="Leather";}
else { var refl=$('refmat').value
var mytool_array=refl.split("L");
$('refmat').value=mytool_array[0];
$('l').innerHTML='';
$('leathertext').value='';
}
}

function showsp(){
if($('spbox').checked==true ){
$('ssp').innerHTML="SP";
$('refmat').value=$('refmat').value+$('ssp').innerHTML;
$('sptext').value='Silver Plated';
}
else  { 
var refl=$('refmat').value
var mytool_array=refl.split("SP");
$('refmat').value=mytool_array[0];
$('ssp').innerHTML='';
$('sptext').value='';
$('refmat').value=$('refn').innerHTML;
}
}

function showsp2(){
if($('spbox2').checked==true ){
$('ssp').innerHTML="SP";
$('refmat').value=$('refmat').value+$('ssp').innerHTML;
$('sptext').value='Silver Plated';
}
else  { 
var refl=$('refmat').value
var mytool_array=refl.split("SP");
$('refmat').value=mytool_array[0];
$('ssp').innerHTML='';
$('sptext').value='';
}
}
function showsubcat(idn,totatl){
	var id="sub"+idn;
if($(id).style.display=="none"){
$(id).style.display="block";
for(i=1;i<=totatl;i=i+1){ var nomd="sub"+i;
//alert(nomd);
if(i!=idn) $(nomd).style.display="none";
}
}
else if($(id).style.display=="block")$(id).style.display="none";
}

  /////////////// cette fonction est ajouté a cause d'un probleme dans les selected index dans firefox apres faire un back/////////
function resetselect(){
$('sizes').selectedIndex=0;
$('materialselect').selectedIndex=0;
}