function trimString(fullS) {
 if (fullS!=null) { 
   while (fullS.substring(0,1)==" ") {
         fullS = fullS.substring(1,fullS.length)
   }
   while (fullS.substring(fullS.length-1,fullS.length)==" ") {
         fullS = fullS.substring(0,fullS.length-1)
   }
   return fullS
  } 
}
function addtobox(lSrc,lTarget){
     if (lSrc.value!=-1){
     // if (lSrc.options.selectedIndex!=-1 && lSrc.value!=-1) {
      var mtext=trimString(lSrc.options[lSrc.options.selectedIndex].text)
      var mvalue
      var mindex
	  mvalue = trimString(lSrc.options[lSrc.options.selectedIndex].value) 
      var option0 = new Option(mtext, mvalue)
	  
      if (lTarget.options.length>0 && lTarget.options[lTarget.options.length-1].value=="-1") {
	    mindex=lTarget.options.length-1
	    var option1 = lTarget.options[mindex]
		lTarget.options[mindex]=option0
		lTarget.options[mindex+1]= new Option("                                                           ", "-1")
		} 
      else {
	   mindex=lTarget.options.length
       lTarget.options[mindex]=option0
	  }   
      lTarget.options.selectedIndex=mindex	    	  
      lSrc.value = -1; 
	 }
	 //   }
}
function removeSelected(lFrom){//remove from selectbox 
   if (lFrom.options.selectedIndex>=0 && lFrom.options[lFrom.options.selectedIndex].value!="-1"){
      lFrom.options[lFrom.options.selectedIndex]=null
   }
}
function fillList(list, formName) {
 for (var i=0; i<formName.options.length; i++) {
	  ids = formName.options[i].value;
      if (ids!= "" && ids!="-1") 
	   {
		list = list + ids + ",";
	   }	 
 }
 list = list.substring(0,list.length-1);
return list;
}
function submitClose(){ // compose list
	var selList = "";
	res = fillList(selList, document.listfrm.selTypes);
	document.submform.type5s.value = res;
	return true;
}

function showDescr(product){
	// open("/products/description.php4?product="+product,'win','width=700,height=500,screenX=0,screenY=0,resizable=0,scrollbars=1');
	// open("http://www.rdm.com.ua/products/description.php4?product="+product,'win','width=700,height=500,screenX=0,screenY=0,resizable=0,scrollbars=1,menubar=1');
	open("/products/description.php4?product="+product,'win','width=700,height=500,screenX=0,screenY=0,resizable=0,scrollbars=1,menubar=1');
}
