
var windowSearchOpened = null;
var buttonCaller       = null;

// -----------------------------------------------------------------------------
function openSearchWindowINSSSEP(caller){ 

   buttonCaller = caller;
   searchString = "";
   strCaller    = "";

   if (buttonCaller.pos_prefix != null) {
       strCaller = buttonCaller.pos_prefix
   }

   if (buttonCaller.buscarPor != null) {
    buscarPor    = eval(buttonCaller.buscarPor);
    buscarUsando = eval(buttonCaller.buscarUsando);	
   
    for(i=0; i < buscarPor.length; i++){
      
      // Se agrego soporte para que se puede leer datos de combos      
	  if( document.getElementById(buttonCaller.id_prefix + buscarUsando[i] + strCaller).type == 'select-one' ){
          value = document.getElementById(buttonCaller.id_prefix + buscarUsando[i] + strCaller).options(document.getElementById(buttonCaller.id_prefix + buscarUsando[i] + strCaller).selectedIndex).value;
      }else{		
		  value = document.getElementById(buttonCaller.id_prefix + buscarUsando[i] + strCaller).value;
	  }
   
      if(value != null && value != ""){

         searchString += buscarPor[i] 
         searchString += "=";        
         searchString += value + "&";
      }
    }
   }

   if(searchString){
      searchString = searchString + "buscar=Buscar";	  
   }

   //alert(caller.buscar + searchString);

   windowSearchOpened = open(caller.buscar + searchString,(caller.id_prefix+caller.pos_prefix),'height=500,width=640,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no'); 
}   
    
// -----------------------------------------------------------------------------
function getArraySearchDataINSSSEP(childWindowButtonPressed)
{ 
   var interChangeArray = eval(childWindowButtonPressed.rowdata);   

   windowSearchOpened.close(); 

   var interChangeArrayIndexToGet = eval(buttonCaller.interChangeArrayIndexToGet);
   var strCaller = "";
   
   if (buttonCaller.pos_prefix != null) {
       strCaller = buttonCaller.pos_prefix
   }
   
   if (buttonCaller.hasID != null && buttonCaller.hasID != "") {
      entityID = childWindowButtonPressed.name.split("_")[1];
      document.getElementById(buttonCaller.id_prefix + "ID"  + strCaller).value = entityID;   
   }

   if (buttonCaller.ingresarEn != null) {
       ingresarEn    = eval(buttonCaller.ingresarEn);  
       for(i=0; i < ingresarEn.length; i++)   
	   {
         document.getElementById(buttonCaller.id_prefix + ingresarEn[i] + strCaller).value  = interChangeArray[interChangeArrayIndexToGet[i]];
	   }
   }
   document.getElementById(buttonCaller.id_prefix + "ButtonOpen"  + strCaller).style.display = "none";
   document.getElementById(buttonCaller.id_prefix + "ButtonClean" + strCaller).style.display = "inline";

   buttonCaller.interChangeArray = interChangeArray;
   
   eval(buttonCaller.callBackFunction);
   
   return true;
} 

// -----------------------------------------------------------------------------
function cleanDataINSSSEP(buttonPressed)
{ 
   var strPressed = ""
   if (buttonPressed.pos_prefix != null) {
       strPressed = buttonPressed.pos_prefix;
   }
   
	buttonCaller = buttonPressed;
   
   
   if (buttonCaller.ingresarEn != null) {
       ingresarEn    = eval(buttonCaller.ingresarEn);  
       for(i=0; i < ingresarEn.length; i++){   
          // Se agrego soporte para que se puede leer datos de combos
	  		if( document.getElementById(buttonCaller.id_prefix + ingresarEn[i] + strPressed).type == 'select-one' ){
         		document.getElementById(buttonCaller.id_prefix + ingresarEn[i] + strPressed).value  = "-1";
			}else{
				document.getElementById(buttonCaller.id_prefix + ingresarEn[i] + strPressed).value  = "";
			} 
		}  
   }
   document.getElementById(buttonPressed.id_prefix + "ButtonOpen"  + strPressed).style.display = "inline";
   document.getElementById(buttonPressed.id_prefix + "ButtonClean" + strPressed).style.display = "none";

   eval(buttonPressed.callBackFunctionClean);

   return true;
} 
// -----------------------------------------------------------------------------


