
/** versione per submit **/
function setActionSearch2(form, sender) {
   var url = String(location.pathname)      
   var i = 0
   form.action = url  
   fNumber = 0
   var posId = new String()
   
   while (form.elements[i]) {
     obj = form.elements[i]
     
     if ((obj.type == 'checkbox') && (obj.checked)) {       
     
       if (obj.name=='posid') {
             posId += (posId == '' ? 'posid=$' + obj.value : '$' + obj.value)       
       } // function
     
       if (fNumber==0) {
         form.action += '?useflags=1'  
       }        
       obj.disabled = true
       form.posid.value = posId
       form.action += '&' + obj.name + '=1'              
       fNumber++
     } // if     
     
     
     
     i++
   } // while   
   form.submit()
   //sender.disabled = true
} // function


/** versione location URL */
function setActionSearch(form, url) {
   var search = new String()  
   var i = 0
   fNumber = 0
   var posId = new String()

   while (form.elements[i]) {
     obj = form.elements[i]
     
   
     
     if ((!obj.attributes['nopass']) && (!obj.disabled)) {

     switch (obj.type)	{
       /** select **/
       case 'select-one': 
         search +=  obj.name + '=' + obj.options[obj.selectedIndex].value + '&'
         break;
       /** checkbox **/
       case 'checkbox'  :       
         
         if (obj.checked) {                        
             if (obj.name=='posid') {                             
                posId += (posId == '' ? 'posid=$' + obj.value : '$' + obj.value)                                
             } else {         
               search +=  obj.name + '=' + obj.value + '&' 
               fNumber ++	           
	         } // else
	         // obj.disabled = true
         } // if         
         break;
        
       /** hidden, potenzialmente text **/
       case 'hidden' :
	     search +=  (obj.value ? obj.name + '=' + obj.value + '&': '') 
	     break;
     } // switch
     } 
     i++
   } // while   


   if (fNumber>0)   search += '&useflags=1' 
   if (posId != '') search += '&' + posId + '$'
   
   
      
   if (url) {     
   
      if (url.indexOf('?') == -1) {
           search = '?' + search               
           location = url + search
      } else {
           search = '&' + search               
           location = url + search
      }
   

   } else  {
     search = '?' + search
     location.search =  search
   } // else  

} // function


function getParams(myForm) {  
    var i = 0
    while (myForm.elements[i]) {  
      var obj = myForm.elements[i]
      if (obj.type == 'checkbox') {  
        if (obj.name == 'posid') {
          
          var posids = new String(myForm.elements['posidget'].value)
          obj.checked = (posids.indexOf('$' + obj.value + '$') > -1)
        } else {
          obj.checked = (String(location).indexOf(obj.name +'=1') > -1);
        } // if
      } // if
      i++
    } // while        
    
    
    
    
}//end


 function loadImage(img, imgUrl){
	if (imgUrl!=null)
		img.src = imgUrl;
 }//end




 function cleanImgTags(tag, rto) {    
  var i = 0
  var imgs = document.images
  while (imgs[i]) {
    var img = imgs[i]
    if (img.src.indexOf(tag) > -1) {            
      img.src = img.src.replace(tag, rto)      
    } // if
    i++
  } // while 
 } // function



 function searchByRegion(rID) { 
 
 
    var url = location.pathname.toLowerCase().replace('map.html', 'search/index.html')
        
    if (location.search) {
      url += location.search + '&regionID=' + rID;
    } else {
      url += '?regionId=' + rID
    } // else
    
    location = url
    
    
 } // function










function usedFlags(myForm) {

  var ret = false
  var  i = 0 
  while (myForm.elements[i]) {
     var obj = myForm.elements[i]
     if ( (obj.type=='checkbox') && (obj.name!='posid') ) {       
       if (obj.checked) {
          ret = true
       }
     }  
     i++     
  } // while
   
 return ret
}
