var par1 = '';
var par2 = '';
var par3 = '';
var par4 = '';
var p    = 0;

function wines(section, h, s) {
  h = $H(h);
  
  if(section == 'types') par1 = h.toQueryString();
  else if(section == 'years') par2 = h.toQueryString();
  else if(section == 'countries') par3 = h.toQueryString();
  else if(section == 'regions') par4 = h.toQueryString();
  
  if($('s' + section)) {
    $('s' + section).remove();
  }
  new Insertion.Top($('c' + section), new Element('span', { 'id': 's' + section }).update(s + ' <img alt="' + selected + '" src="images/haken.png" /><br />'));
  
  switcher(section);
}
function unhide(section) {
  if(section == 'types') par1 = '';
  else if(section == 'years') par2 = '';
  else if(section == 'countries') par3 = '';
  else if(section == 'regions') par4 = '';
  
  switcher(section);
}
function switcher(section) {
  new Ajax.Updater('wines', 'actionh.php', {method: 'post', postBody: par1 + '&' + par2 + '&' + par3 + '&' + par4});
  
  if(section != 'types') new Ajax.Updater('types', 'actionh.php', {method: 'post', postBody: 'action=update&column=types&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});
  if(section != 'years') new Ajax.Updater('years', 'actionh.php', {method: 'post', postBody: 'action=update&column=years&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});
  if(section != 'countries') new Ajax.Updater('countries', 'actionh.php', {method: 'post', postBody: 'action=update&column=countries&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});
  if(section != 'regions') new Ajax.Updater('regions', 'actionh.php', {method: 'post', postBody: 'action=update&column=regions&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});
  
  $(section).toggle();
  $('c' + section).toggle();
}
function goPage(p) {
  new Ajax.Updater('wines', 'actionh.php', {method: 'post', postBody: $('searchByVino').serialize() + '&p=' + p + '&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});
}
new Ajax.Updater('types', 'actionh.php', {method: 'post', postBody: 'action=update&column=types&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});
new Ajax.Updater('years', 'actionh.php', {method: 'post', postBody: 'action=update&column=years&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});
new Ajax.Updater('countries', 'actionh.php', {method: 'post', postBody: 'action=update&column=countries&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});
new Ajax.Updater('regions', 'actionh.php', {method: 'post', postBody: 'action=update&column=regions&' + par1 + '&' + par2 + '&' + par3 + '&' + par4});