

function popup( url , name , width , height ){
  var left = (screen.width > width ) ? (screen.width-width)/2 : 0;
  var top = (screen.height > height ) ? (screen.height-height)/2 : 0;
  var strWindowFeatures  = 'modal=yes,menubar=no,toolbar=no,location=no,resizable=no,scrollbars=yes,status=no,titlebar=no';
  return window.open(url,name,strWindowFeatures+",width="+width+",height="+height+",top="+top+",left="+left);
  }
  
/************************************/

function $save(id){
  if ( $(id) ) $(id).submit();
  return false;
  }

/*--------------------------------------------------------------------------------------------------------------------------------*/

function menu (obj){
  var li = $(obj).getParent();
  var ul = li.getElement('ul');
  ul.toggleClass('hide');
  if ( li.hasClass('active' ) )
    li.removeClass('active')
  else if ( !ul.hasClass('hide') )
    li.addClass('active');
  }

/*--------------------------------------------------------------------------------------------------------------------------------*/

function swich_order_row ( obj ){
  var className = obj.get('name') ;
  if( className ){
    if ( obj.get('value') )
      $$('.'+className).removeClass('hide');
    else
      $$('.'+className).addClass('hide');
    }
  }

/*--------------------------------------------------------------------------------------------------------------------------------*/

function clear_input( input ){
  var input = $(input);
  if ( input ){
    input.addEvent('focus',function(){  if ( input.get('title') == input.get('value') ) input.set('value',''); });
    input.addEvent('blur',function(){ if ( input.get('value') == '' ) input.set('value', input.get('title') ); });
    }
  }

/*--------------------------------------------------------------------------------------------------------------------------------*/

function add_comment(sub){
  var comment_form = $('comment_form');
  new Element('input',{'name':'sub','value':sub,'type':'hidden'}).inject(comment_form);
  comment_form.submit();
  }

/*--------------------------------------------------------------------------------------------------------------------------------*/

function show_comment_form(obj){
  $('comment_form').removeClass('hide');
  obj.setStyle('display','none');
  }

/*--------------------------------------------------------------------------------------------------------------------------------*/

window.addEvent('domready', function() {
  var dodajdokoszyka = $('dodajdokoszyka') ;
  if ( dodajdokoszyka ){
    dodajdokoszyka.addEvent('click',function(e){
      new Event(e).stop();
      $('order_add_form').submit();
      });
    }
});

