function show(e){
 if(document.getElementById)
  if(document.getElementById(e))
   document.getElementById(e).style.display='';
}
function hide(e){
 if(document.getElementById)
  if(document.getElementById(e))
   document.getElementById(e).style.display='none';
}
function showHide(e){
 if(document.getElementById)
  if(document.getElementById(e)){
   e=document.getElementById(e).style;
   with(e)display=(display=='none'?'':'none');
  }
}
function getCookie(c){
 var splited,a,i;
 if(!c)return null;
 splited=document.cookie.split(';');
 if(!splited)return null;
 for(i=0;i<splited.length;i++){
  a=splited[i].split('=');
  if(a[0].substring(0,1)==' ')a[0]=a[0].substring(1,a[0].length);
  if(a[0]==c)return(a[1]);
 }
 return null;
}
function setCookie(name,value){  
 var argv,argc,expires,path,domain,secure;
 argv=setCookie.arguments;  
 argc=setCookie.arguments.length;  
 expires=(argc>2)?argv[2]:null;  
 path=(argc>3)?argv[3]:null;  
 domain=(argc>4)?argv[4]:null;  
 secure=(argc>5)?argv[5]:false;  
 document.cookie=name+"="+escape(value) + 
 ((expires==null)?"":("; expires="+expires.toGMTString()))+
 ((path==null)?"":("; path="+path))+ 
 ((domain==null)?"":("; domain="+domain))+   
 ((secure==true)? "; secure" :"");
}
function deleteCookie(name){  
 var exp=new Date();  
 exp.setTime(exp.getTime()-1);  
 var cval=getCookie(name);  
 document.cookie=name+"="+cval+"; expires="+exp.toGMTString();
}
function window_open(url,name,width,height){
 var w=window.open(url,name,'left=16, top='+(window.screen.height>600?104:16)+', width='+width+', height='+height+', toolbar=no, menubar=no, directories=no, location=yes, scrollbars=yes, resizable=yes, status=no');
 if(w.opener==null)w.opener=self;
 w.focus();
 return!(w);
}
function window_open2(url,name){
 return window_open(url,name,512,256);
}
function withCheckboxes(prefix,op){
 if(!document.getElementById)return false;
 for(i=0;true;i++){
  e=document.getElementById(prefix+i);
  if(e)
   switch(op){
   case 0:e.checked=false; break;
   case 1:e.checked=true; break;
   case-1:e.checked=!e.checked;
   } 
	else return;
 } 
}
function fillPieces(n){
 if(!document.getElementById)return false;
 for(i=0;true;i++){
  e=document.getElementById('qty_'+i);
  if(e)
   if(n && !document.getElementById('obsolete_'+i).value)e.value=document.getElementById('pcs_'+i).value;
   else e.value='';  
  else return;   
 }
}
function externalLinks(){
 if(!document.getElementsByTagName)return;
 var i,a,anchors=document.getElementsByTagName("a");
 for(i=0;i<anchors.length;i++){
  a=anchors[i];
  if(a.getAttribute("href") && a.getAttribute("rel")=="external")a.target="_blank";
 }
}
function editQty(e,n){
 if(document.getElementById)
  if(document.getElementById(e))
   with(document.getElementById(e)){
    value=value-0+n;
    if(value<=0)value='';
   }  
}
function checkTextAreas(){
 for(i=0;i<textareas.length;i+=2){
  id=textareas[i]; max=name=textareas[i+1];;
  if(elm=document.getElementById(id))elm=elm.value; else continue;
  if(elm.length>max)document.getElementById(id).value=elm.substr(0,max);
  if(t=document.getElementById(id+'length'))t.innerHTML=max-elm.length;
 } 
 setTimeout("checkTextAreas()",1000);
}