var monthsByYear = new Array();
var monthsVAluesByYear = new Array();
function addMonth(_year, _month, _value)
{
  if (monthsByYear[""+_year]==null) 
  {
    monthsByYear[""+_year] = new Array();
    monthsVAluesByYear[""+_year] = new Array();
  }
   monthsByYear[""+_year][monthsByYear[""+_year].length] = _month;
   monthsVAluesByYear[""+_year][monthsVAluesByYear[""+_year].length] = _value;
}
function fillMonths(selection)
{
  var select = document.getElementById('date.year');
  var _year = ""+select.options[select.selectedIndex].value;
  select = document.getElementById('date');
  select.options.length = 2;
  for (var i=0; i<monthsByYear[_year].length; i++)
  {
    select.options[select.options.length] = new Option(monthsByYear[_year][i], monthsVAluesByYear[_year][i]);
    if (selection && selection==monthsVAluesByYear[_year][i]) select.selectedIndex = i+2;
  }
}
function doSearch(src)
{
  if ('date.year'==src.id)
  {
    fillMonths();
    document.getElementById('date').selectedIndex = 1;
  }
  else
  {
    if (src.options)
    {
      if (src.options[src.selectedIndex].value!=-2)
        getObj("saleForm").submit();
      else return false;
    }
    else getObj("saleForm").submit();
  }
}

function getObj(objName)
{
  if (document.getElementById(objName)) return document.getElementById(objName);
  else return document.getElementsByName(objName)[0];
}



function showMovie(srcElement, divId, moviePath, movieWidth, movieHeight) 
{
  if ($(divId).style.display!="none") sendEvent('stop');
  $(divId).style.top=(document.documentElement.scrollTop)+"px";
  $(divId).show();
  var playerWidth = movieWidth==0 ? "320" : movieWidth+"px";
  var playerHeight = movieHeight==0 ? "320" : movieHeight+"px";
  var so = new SWFObject('/_reserved/flvplayer.swf', 'mpl', playerWidth, playerHeight, '8');
  so.addParam("allowfullscreen","true");
  so.addVariable("file", moviePath);
  so.addVariable("enablejs","true");
  so.addVariable("javascriptid","mpl");
  so.addVariable("autostart","true");
  so.write('player');
}

function hideMovie(divId)
{
  sendEvent('stop');
  $(divId).hide();
} 



// these functions are caught by the Javascriptiew object of the player.
function sendEvent(typ,prm) { thisMovie("mpl").sendEvent(typ,prm); };

// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) 
{
 if(navigator.appName.indexOf("Microsoft") != -1) 
 {
    return window[movieName];
  } 
  else { return document[movieName]; }
}

var _moviePath;
var _movieWidth;
var _movieHeight;

function startMovie(divId)
{
  showMovie(this, divId, _moviePath, _movieWidth, _movieHeight);
}

function showDetail(url)
{
  showWin(url, 580, 700);
}

function showAdj(url)
{
  showWin(url, 580, 700);
}
function showWin(url, width, height)
{
  the_X = screen.width-490;
  the_Y = 20;
  win = window.open(url,'detailshower','screenX='+the_X+',screenY='+the_Y+'toolbar=yes,scrollbars=yes,location=no,directories=no,status=0,menubar=yes,resizable=yes,width='+width+',height='+height+',alwaysRaised=no,z-lock=yes');
  win.focus();
}

function showCata(url)
{
  the_X = 20;
  the_Y = 20;
  win = window.open(url,'catalog','screenX='+the_X+',screenY='+the_Y+'toolbar=yes,scrollbars=yes,location=no,directories=no,status=0,menubar=yes,resizable=yes,alwaysRaised=no,z-lock=yes');
  win.focus();
}

