vgpreview = {
  imgId: "side",
  inputId: "color",
  figId: "fig",
  fontId: "font",
  
  stockId: "color",
  
  coloruri: function(color, side) {
    return "/img/colors/" + color + "_" + side + ".png";
  },
  
  preview: function(a, b) {
    var aimg = document.getElementById('a' + this.imgId);
    var bimg = document.getElementById('b' + this.imgId);
    aimg.src = this.coloruri(a, 'a');
    bimg.src = this.coloruri(b, 'b');
  },
  
  getcolor: function(id) {
  	return document.getElementById(id).value;
  },
  
  setcolor: function(id, color) {
	    document.getElementById(id).value = color;
	    document.getElementById('_' + id).value = color;
  },
  
  refresh: function() {
    this.preview(this.getcolor('a' + this.inputId), this.getcolor('b' + this.inputId));
  },
  
  refreshStock: function() {
    var col = document.getElementById(this.stockId).value;
    var n = col.indexOf("-");
    // Egyedi színek beállítása
    this.setcolor('a' + this.inputId, col.substr(0, n));
    this.setcolor('b' + this.inputId, col.substr(n + 1));
    // Hímzés kikapcsolása
    document.getElementById(this.fontId).checked = true;
    document.getElementById('a' + this.figId).selectedIndex = 0;
    document.getElementById('b' + this.figId).selectedIndex = 0;
    this.refresh();
  },
  
  switchToUnique: function() {
    document.getElementById("stock").style.display = "none";
    document.getElementById("unique").style.display = "block";
  },
  
  switchToStock: function() {
    document.getElementById("stock").style.display = "block";
    document.getElementById("unique").style.display = "none";
    this.refreshStock();
  },
  
  setcolors: function(cola, colb) {
	vgpreview.switchToUnique();
    this.setcolor('a' + this.inputId, cola);
    this.setcolor('b' + this.inputId, colb);
    this.refresh();
  }
}


