/* 

fishnet js
(c) by sergey korowkin, Ateve Moscow 2006

http://korowkin.ru/
http://ateve.com/

*/

var dumb = function() { }

function GotSelector(s)
 {
  s = s.responseText;
  s = s.split("\x0D\x0A");

  if (s.length == 0) return;
  if (!(target = $(s[0]))) return;

  target.length = 0;

  for (k = 1; k < s.length - 1; k++)
   {
    y = s[k].split("\<\.\>");

    o = new Option();
    o.text = y[1];
    o.value = y[0];
    target.options[target.length] = o;
   }

  if (target.onchange) target.onchange();
 }

function Selector(src, dest, kind)
 {
  target = $(dest);

  o = new Option();  
  o.text = '...';
  o.value = '0';

  target.length = 0;
  target.options[target.length] = o;

  new Ajax.Request(baseurl + 'selector.html',
                   {method: 'get',
                    parameters: 'src=' + escape(src) + 
                                '&dest=' + escape(dest) + 
                                '&kind=' + escape(kind) + 
                                '&value=' + escape($(src).value) + 
                                '&' + Math.random(),
                    onComplete: GotSelector});
 }

function Price(priceID)
 {
  if (p = $('price' + priceID))
   p.style.display = p.style.display == 'none' ? 'block' : 'none';

  return false;
 }

function PriceFoto(priceID, width, height)
 {
  width = width + 50;
  height = height + 80;

  if (height > 700)
   height = 700;

  var left = Math.round((document.body.clientWidth - width) / 2);
  var top = Math.round((document.body.clientHeight - height) / 2);

  var win = window.open('/pricefoto.html?priceID=' + priceID,
                        'fishfoto', 
                        'toolbar=no,' +
                        'scrollbars=yes,' +
                        'status=no,' +
                        'height=' + height + ',' +
                        'width=' + width + ',' + 
                        'top=' + top + ',' +
                        'left=' + left);

  win.focus();

  return false;
 }

function ReloadBasket()
 {
  new Ajax.Updater('basketcase',
                   '/pricelist/basket/basketcase.html?fishbasketuid=' + SID,
                   {asynchronous:true, onSuccess: dumb });
 }
 
 function ReloadNewBasket()
 {
  new Ajax.Updater('basketcase',
                   '/pricelist/basket/newbasketcase.html?fishbasketuid=' + SID + '&r=' + Math.random(),
                   {asynchronous:true, onSuccess: dumb });
 }

function AddToBasket(priceID)
 {
  new Ajax.Updater('basket' + priceID,
                   '/pricelist/basket/add.html?priceID=' + priceID + '&fishbasketuid=' + SID,
                   {asynchronous:true, onSuccess: ReloadBasket });

  return false;
 }

function AddToNewBasket(priceID)
 {
  new Ajax.Updater('basket' + priceID,
                   '/pricelist/basket/add.html?priceID=' + priceID + '&fishbasketuid=' + SID + '&r=' + Math.random(),
                   {asynchronous:true, onSuccess: ReloadNewBasket });

  return false;
 }
 
function openClose(id)
 {
  
  var obj = "";
  var sph3 = document.getElementById('sph3');
  // Check browser compatibility
  if(document.getElementById)
  obj = document.getElementById(id).style;
  else if(document.all)
  obj = document.all[id];
  else if(document.layers)
  obj = document.layers[id];
  else
  return 1;
  
  // Do the magic :)
  if(obj.display == ""){
    obj.display = "none";
    if (sph3)
      sph3.innerHTML = textopen;
  }else if(obj.display != "none"){
    obj.display = "none";
    if (sph3)
     sph3.innerHTML = textopen;
  }else{
    if (sph3)
     sph3.innerHTML = textclose;

    obj.display = "block";
  }
 }
