function canviaFons(color){
  elem=document.getElementById('vinil');
  elem.style.backgroundColor='#'+color;
  return false;
}
function canviaImatge(color){
  elem=document.getElementById('vinil');
  codi=color.split("_");
  
  if(document.fvinil.vposicio.value=="invertido"){
    img="files/imatges/vinils/color"+color+"_i.png";
  } else {
    img="files/imatges/vinils/color"+color+".png";
  }  
    
  
  var cont='';
  cont+='<div style="width:370px;height:333px;float:left;';
  cont+='background-color:transparent;';
  cont+='background-position:center center;';
  cont+='background-repeat: no-repeat;';
  cont+='_background-image: none;';
  cont+='filter: none;';
  cont+='_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+img+', sizingMethod=\'scale\');">';
  cont+='<div style="_display:none;overflow:hidden;"><img src="'+img+'" alt="" style="width:370px;"></div></div>'
  
  elem.innerHTML=cont;
  document.fvinil.vcolor.value=color;
  return false;
}

function flipImatge(tipus){

  elem=document.getElementById('vinil');
  codi=color= document.getElementById('vcolor').value;
  codi = codi.split('_');  
  
  if(tipus=='o'){
    document.getElementById('boriginal').checked=true;
    document.getElementById('binvertit').checked=false;
    document.fvinil.vposicio.value="original";
    img="files/imatges/vinils/color"+color+".png";
  } else if(tipus=='i'){
    document.getElementById('boriginal').checked=false;
    document.getElementById('binvertit').checked=true;
    document.fvinil.vposicio.value="invertido";
    img="files/imatges/vinils/color"+color+"_i.png";
  }
  
   
  var cont='';
  cont+='<div style="width:370px;height:333px;float:left;';
  cont+='background-color:transparent;';
  cont+='background-position:center center;';
  cont+='background-repeat: no-repeat;';
  cont+='_background-image: none;';
  cont+='filter: none;';
  cont+='_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+img+', sizingMethod=\'scale\');">';
  cont+='<div style="_display:none;overflow:hidden;"><img src="'+img+'" alt="" style="width:370px;"></div></div>'
  
  elem.innerHTML=cont;
  document.fvinil.vcolor.value=color;
  return false;
}



function mes(){
q=document.getElementById('quantitat');
valor=q.innerHTML;
valor++;
q.innerHTML=valor;
document.fvinil.vquant.value=valor;
return false;
}

function menys(){
q=document.getElementById('quantitat');
valor=q.innerHTML;
if(valor>1){
  valor--;
  q.innerHTML=valor;
  document.fvinil.vquant.value=valor;
} else {
  
}
return false;
}

function carregaImatges(){  
  for(i in imatges){
    llista_imatges[i] = new Image();
    llista_imatges[i].src = imatges[i];
  }
}
function marcaAcabat(tipus){
  if(tipus=='m'){
    document.getElementById('bmate').checked=true;
    document.getElementById('bbrillant').checked=false;
    document.fvinil.vacabat.value="mate";
  } else if(tipus=='b'){
    document.getElementById('bmate').checked=false;
    document.getElementById('bbrillant').checked=true;
    document.fvinil.vacabat.value="brillante";
  }
}

function marcaMida(id){
  var act = document.fvinil.vmida.value;
  if(act!=''){
    document.getElementById('mida'+act).checked=false;
  }
  
  if(act!=id){
    document.getElementById('mida'+id).checked=true;
    document.fvinil.vmida.value=id;
  } else {
    document.fvinil.vmida.value='';
  }
  
}

function comprar(){
if(document.fvinil.vmida.value==''){
  alert('Ha de seleccionar una medida para proseguir \n con el pedido.'); 
  return false;
}
document.fvinil.submit();
}