/**$(id)
 * @param id - id elementu dokumentu
 * @return document.getElementById(id)
 */
function $(id) {
     return document.getElementById(id);
}

/**delfrombin(idInbin,msg)
 * usuwa element z kosza
 * @param idInbin
 * @param msg  
 * @param which okresla czy maly(0) czy duzy(1) koszyk 
 */ 
function delfrombin(idInbin,msg,which){
  if (confirm(msg)){
    if(which==0){
      var zapytanie = "./modules/mod_shopbin/main/ajaxpage.php?action=delfrombinsmall&idinbin="+idInbin;
    }else{
      var zapytanie = "./modules/mod_shopbin/main/ajaxpage.php?action=delfrombin&idinbin="+idInbin;
    }
     //alert(zapytanie);
     advAJAX.get({ 
          url : zapytanie,
          onLoading : function(obj) {
          },
          onSuccess : function(obj) {
            switch (obj.responseText){
              case 'no': 
                alert("Error");
                break;
              default:
                if(which==0){
                  $('smallshopbintable').innerHTML=obj.responseText;
                }else{
                  $('bigshopbintable').innerHTML=obj.responseText;
                  document.getElementById("rejestracja").style.display = "none";
                }  
            }
     },
     onError : function(obj) {
        alert("Error..");
        }
     });	
  }
  else{
  	return false;
  }
}


/**makeprojectadd()
 * dodaje i odejmuje koszt wykonania projektu jesli zaznaczone/odznaczone
 */ 
function makeprojectadd(){
  if($('makeproject').checked){
    $('makeprojectcostshow').innerHTML=$('makeprojectcost').value+' &euro;';
    $('costproject').value=$('makeprojectcost').value;
    $('sumaall').value=format(+$('sumaall').value + +$('makeprojectcost').value,2);
    $('sumaallshow').innerHTML=$('sumaall').value+' &euro;';
  }else{
    $('makeprojectcostshow').innerHTML='0.00 &euro;';
    $('costproject').value='0.00';
    $('sumaall').value=format(+$('sumaall').value - +$('makeprojectcost').value,2);
    $('sumaallshow').innerHTML=$('sumaall').value+' &euro;';
  }
}

/**format(liczba, lmpp)
 * formatuje liczbe
 * @param liczba
 * @param lmpp liczba miejsc po przecinku
 * @return liczba   
 */ 
function format(liczba, lmpp) {
  ile = ""+Math.round(liczba*Math.pow(10,lmpp))/Math.pow(10,lmpp);
  if (ile.indexOf(".")<0) ile+=".0";
  while ((ile.length-ile.indexOf(".")-1)<lmpp) ile = ile+"0";
  return ile;
}



/**pokazrejestracje()
 * decyduje co wyswietlic, czy frm osobowy czy okno logowania
 */ 
function pokazrejestracje(){
  if($('accountalready').checked){
    document.getElementById('rejestracja').style.display = 'none';  
    document.getElementById('logowanie').style.display = 'block';
  }else{
    document.getElementById('logowanie').style.display = 'none';
    document.getElementById('rejestracja').style.display = 'block';  
  }
}


/**ukryjall()
 * ukrywa wyswietlone elementy rejestracyjne
 */ 
function ukryjall(){
  if($('accountalready').checked){
    $('accountalready').value=1;//alert('1');
  }else{
    $('accountalready').value=0;//alert('0');
  }
    document.getElementById('rejestracja').style.display = 'none';  
    document.getElementById('logowanie').style.display = 'none';
}
