
String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");}    

function changePrice(price,usdm,eurm) {

  if (isNaN(parseFloat(price))) {pricerub=0;}
  else {pricerub=parseFloat(price);}
  if (pricerub==0) {
     Wid(usdm,'');
     Wid(eurm,'');
  }
  else {
     Wid(usdm,'~ $'+((pricerub/usd).toFixed(2)));
     Wid(eurm,' &euro;'+((pricerub/eur).toFixed(2)));
  }
 
}   


function onoff(numrec,act) {
  if (numrec>0) 
  {
     SwapNav('n'+numrec,'hide');
     getDataHTTP('GET','onoff.php?act='+act+'&nr='+numrec,'','o'+numrec);
     if (act=='on') WStyle('n'+numrec,'background','#ddc');
     else WStyle('n'+numrec,'background','#bbc');
     SwapNav('n'+numrec,'show');
  }   
}

function filter() {
  if (filt==1) 
  {
     document.objlist.fname.value=""; 
     document.objlist.fmodel.value="";
     document.objlist.fbu.value="-1";
     document.objlist.fnote.value="";
     document.objlist.fprice1.value="";
     document.objlist.fprice2.value="";
     SwapNav('filter','hide');
     SwapNav('filter2','hide');
     filt=0;
  }
  else {
     SwapNav('filter','show');
     SwapNav('filter2','show');
     filt=1;
  }   
}


function check(x) {
  if (x) return '1';
  else return '0';
}

function sort(srt,napr) {
  document.objlist.nsort.value=srt+''+napr;
  getresult(document.objlist.p.value);
}


function getresult(p) {
  var arr = [['ajax','2'],['p',p], 
            ['ffilt',filt],
            ['nsort',document.objlist.nsort.value],
            ['dt1',cFrom.date],
            ['dt2',cTo.date],
            ['fname',document.objlist.fname.value], 
            ['fbu',document.objlist.fbu.value], 
            ['fmodel',document.objlist.fmodel.value], 
            ['fnote',document.objlist.fnote.value], 
            ['fprice1',document.objlist.fprice1.value],
            ['fprice2',document.objlist.fprice2.value]];

  SwapNav('result','hide');
  getDataHTTP('POST','result.php',arr,'result');
  SwapNav('result','show');
}


