// JavaScript Document

function openMenu(li_obj,menu_id) {      
      obj = document.getElementById(menu_id);
      
      obj.style.visibility = "visible";
      
      li_obj.style.backgroundColor = "#9a6601";
}

function closeMenu(li_obj,menu_id) {
      obj = document.getElementById(menu_id);
      
      obj.style.visibility = "hidden";
      
      li_obj.style.backgroundColor = "transparent";
}

function changeImg(img_id,url,txt) {
  obj = document.getElementById(img_id);
  obj.src = url;
  
  if (txt != '') {
    objdesc = document.getElementById('photodesc');
    objdesc.innerHTML = txt;
  }
}

function swapYears(array_name,prod_id) {
  //alert(prod_id);
  the_select = document.getElementById('prod_id');
    
  for (i=0; i<the_select.options.length; i++) { //cancellazione delle option
    the_select.options[i] = null;
  }
    
  the_select.options[0] = new Option('---','null');
    
  if (array_name != 'arr_none') {
  
    var the_array = eval(array_name);
    //alert(the_array[0][0]);
    
    for (i=0; i<the_array.length; i++) {
    
      the_select.options[i+1] = new Option(the_array[i][1],the_array[i][0]);
      
      if ( prod_id == the_array[i][0] ) {
        the_select.options[i+1].selected = true;
      }
    }    
  }
}

function formCheck() {
  the_form = document.getElementById('choose-prod');
  the_array = eval('arr_errmsg');

  var msg = "";
  if (the_form.model_id.value == 'none') {
    msg += the_array[1]+"\n";
  }
  
  if ( (the_form.prod_id.value == 'none') || (the_form.prod_id.value == 'null') ) {
    msg += the_array[2]+"\n";
  }
  
  if (msg != '') {
    alert(the_array[0]+"\n"+msg);
    
    return false;
  }
  else {
    return true;
  }
}

function hideSelect() {
  cat_sel = document.getElementById('model_id');
  prod_sel = document.getElementById('prod_id');
  
  cat_sel.style.visibility = "hidden";
  prod_sel.style.visibility = "hidden";
}
function showSelect() {
  cat_sel = document.getElementById('model_id');
  prod_sel = document.getElementById('prod_id');
  
  cat_sel.style.visibility = "visible";
  prod_sel.style.visibility = "visible";
}

