// general.js

// create an instance of the Date object
var now = new Date();
// fix the bug in Navigator 2.0, Macintosh
//fixDate(now);

/*
cookie expires in one year (actually, 365 days)
365 days in a year
24 hours in a day
60 minutes in an hour
60 seconds in a minute
1000 milliseconds in a second
*/

now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);

//para saber si se usa el extend de scroll
var gUseSccrollExtend = false;

//para saber si un boton se apreto
var clickFlag = true;
function waitMessage(icShowDiv, icControlClick, sFunction){	
	if (icControlClick=='Y'){
		if (clickFlag){
		    if (icShowDiv == 'Y'){
				divWait.style.display = "block"			
				setTimeout('document.images["statusanimation"].src = "images/general/statusanimation.gif"', 200); 				
			}			
			clickFlag = false;			
			eval(sFunction);				
			return(false);
		}
		else{
			alert(msgJsAlreadySelected);
			return(false);
		}
	}
	else{
		if (icShowDiv == 'Y'){
			//divWait.style.visibility='visible';
			divWait.style.display = "block"
			setTimeout('document.images["statusanimation"].src = "images/general/statusanimation.gif"', 200); 			
		}		
		eval(sFunction);
		return(false);
	}
}

//se utiliza para resetear un boton que estaba mostrando el waitMessage
//y habia bloqueado el boton cuando no pasa una validación
function resetButton(){
	clickFlag = true;	
	divWait.style.display = "none";
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
	
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
	
function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
	
function MM_swapImage() { //v3.0
  	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  	if ((obj=MM_findObj(args[i]))!=null) { 
  		v=args[i+2];
    	if (obj.style) { 
    		obj=obj.style; 
    		v=(v=='show')?'visible':(v='hide')?'hidden':v; 
    	}
    	obj.visibility=v; 
    }
}

function toggleVisibility(targetId, module, property, imageOpen, imageClose) {
    if (document.getElementById) {
        target = document.getElementById(targetId);
    	if (target.style.visibility == "hidden"){
    		target.style.visibility = "visible";
    		target.style.display='block';
    		if(module=='form'){
	    		MM_swapImage(property,'','images/general/arrowCollapse.gif',1);    		
    		}
    		else if (module=='extend'){
				MM_swapImage(property,'',imageOpen,1);    		
    		}
    		else{
	    		MM_swapImage('searchToggle','',gTheme+'/images/general/searchClose.gif',1);
    		}
    		
    	} else {
    		target.style.visibility = "hidden";
    		target.style.display='none';
    		if(module=='form'){
	    		MM_swapImage(property,'','images/general/arrowExpand.gif',1);    		
    		}
    		else if (module=='extend'){
				MM_swapImage(property,'',imageClose,1);    		
    		}
    		
    		else{
	    		MM_swapImage('searchToggle','',gTheme+'/images/general/searchOpen.gif',1);    		
    		}
    	}
    }
}

function expandCollapseVisibilityAll(baseTargetId, status, baseProperty, cant) {
	for(i=1;i<=cant;i++){
		sNum = '0' + i;
		targetId = baseTargetId + sNum.substr(sNum.length-2,sNum.length);
		property = baseProperty + sNum.substr(sNum.length-2,sNum.length);
		//toggleVisibility(targetId, module, property);
		target = document.getElementById(targetId);				
		if (status=='expand'){
    		target.style.visibility = "hidden";
    		target.style.display='none';
    		MM_swapImage(property,'','images/general/arrowExpand.gif',1);    				
	   	}
	   	else{
			target.style.visibility = "visible";
	    	target.style.display='block';
	   		MM_swapImage(property,'','images/general/arrowCollapse.gif',1);    			   	
	   	}				
	}

	if (status == 'expand'){
   		status = 'collapse';
   	}
   	else{
   		status = 'expand';	   	
   	}		
   	return status;		
}

//TaskBar

	function EnableTask(sID){
		var elTaskBtn;
		var elContextItem;
		elTaskBtn = window.document.all(sID);
			elTaskBtn.disabled = false;
			elTaskBtn.className = elTaskBtn.className.replace(' bdtaskdisabled', '');
	}

	function DisableTask(sID){
		var elTaskBtn;
		var elContextItem;
		elTaskBtn = window.document.all(sID);
		elTaskBtn.disabled = true;
		elTaskBtn.className = elTaskBtn.className.replace(' bdtaskover', '');
		elTaskBtn.className = elTaskBtn.className.replace(' bdtaskpress', '');
		elTaskBtn.className = elTaskBtn.className + ' bdtaskdisabled';
	}


	function task_onMouseOver(){
		var elSource;
		var elMenu;
		var elMenuItem;
		elSource = window.event.srcElement;
		if (elSource.tagName != 'BUTTON')
			elSource = elSource.parentElement;
		elSource.className = elSource.className + ' bdtaskover';
	}
	
	function task_onMouseOut(){
		var elSource;
		var elMenu;
		elSource = window.event.srcElement;
		if (elSource.tagName != 'BUTTON')
			elSource = elSource.parentElement;
		elSource.className = elSource.className.replace(' bdtaskover', '');
		elSource.className = elSource.className.replace(' bdtaskpress', '');
		elSource.parentElement.focus();
	}
	
	function task_onMouseDown(){
		var elSource;
		var elMenu;
		elSource = window.event.srcElement;
		if (elSource.tagName != 'BUTTON')
			elSource = elSource.parentElement;		
		elSource.className = elSource.className & ' bdtaskpress'
	}

	function task_onMouseUp(){
		alert('Up');
		var elSource;
		var elMenu;
		elSource = window.event.srcElement;
		if (elSource.tagName != 'BUTTON')
			elSource = elSource.parentElement;	
		elSource.className  = elSource.className.replace(' bdtaskpress', '');
	}
	

//end TaskBar

//arma un string con los items seleccionados en la lista de la derecha, cuando hay doble lista
	function mantainSelectedItem(arrayObjectSelected,finalString){
		var selected = "";
		for(i=0;i<arrayObjectSelected.options.length;i++){
			selected = selected + arrayObjectSelected[i].value 
			+ ";" + arrayObjectSelected[i].text + "|";
		}
		finalString.value = selected;
	}
	
//valida la seleccion de registros para la edicion, eliminacion, etc... si type=simple permite seleccion unica,
//si type=multiple, permite seleccionar varios registros 	
/*
	function validateChecked(oForm,type){
		var result = 0;
		var selected = false;
		if(oForm.selectedItems != undefined){//si hay registros...
			if(oForm.selectedItems.length != undefined){//hay varios registros
				var pos,cont = 0;
				var selected = false;
				var stringItems = "";
				for(i=0;i<oForm.selectedItems.length;i++){
					if(oForm.selectedItems[i].checked==true){
						cont++;
						pos = i;
						stringItems = stringItems + oForm.selectedItems[i].value + "|";
						selected = true;
					}
				}
				if(type == 'simple'){//si permito seleccion unica (simple) 
					if(cont > 1){//hay mas de un registro seleccionado
						alert(msgJsOneRegistry);
					}else if(cont == 1){
						result = oForm.selectedItems[pos].value;
					}
				}else {//es seleccion multiple (multiple)
					result = stringItems;
				}
			}else {//hay un único registro 
				if(oForm.selectedItems.checked==true){
					result = oForm.selectedItems.value;
					selected = true;
				}
			}
			if(selected == false){
				alert(msgJsMustSelect);
			}
		}else {//no hay ningun registro
			alert(msgJsMustSelect);
		}
		return result;
	}
*/
	//Esta funcion se utiliza para hacer que un tr se destaque
	//dentro de la tabla
	function decoreTable(tableName, action){
	    var table = document.getElementById(tableName);
	    var rows = table.getElementsByTagName("tr");
	    for (i=1; i < rows.length; i++) {
	    	oldClass = rows[i].className;
	        rows[i].onmouseover = function() { this.className='over' };
	        str = 'rows[' + i + '].onmouseout = function() { this.className=\'' + oldClass +  '\';}';
	        eval(str);
			str = 'rows[' + i + '].onclick = function() { ceck = document.getElementById(\'chk' + i + '\'); if(ceck!=null) ceck.checked = !ceck.checked}';
	        eval(str);
	        //el doble clic, por defecto, llama a la funcion edit
	        if (action==undefined){
	        	str = 'rows[' + i + '].ondblclick = function() { ceck = document.getElementById(\'chk' + i + '\'); if(ceck!=null) ceck.checked = true; gotoAction(\'edit\')}';
	        }
	        else{
	        	str = 'rows[' + i + '].ondblclick = function() { ceck = document.getElementById(\'chk' + i + '\'); if(ceck!=null) ceck.checked = true; ' + action + '}';
	        }
	        eval(str);
	        
	        var chk = document.getElementById('chk' + i);
	        if(chk != null) chk.onclick = function(){this.checked = !this.checked;};
	    }
	}

	//Esta funcion la uso para setear en la prop del bean el estado del input type=checkbox de la ventana
	//xq si lo hago directamente con struts, a veces no la setea correctamente
	function setCheckBox(checkName, beanProperty) {
		if(checkName.checked){
			beanProperty.value = 'Y';
		}
		else {
			beanProperty.value = 'N';
		}
	}
	
	//Esta funcion oculta una columna (td) cambiandole el ancho
	//se usa en las barras derecha e izquierda
	function hideColumn(colId){
		column = document.getElementById(colId);
		column.width = 1;
	}  
	
	function parseBoolean(val){
	if(val)
		return(1);
	else
		return(0);
	}
	
	
	//Esta funcion abre un pop up con el path q se le pasa como parametro (file)
	function openPage(file){
		window.open(file,'','toolbar=no, menubar=no, scrollbars=yes, resizable=yes, height=550,width=750');
	}
	
	
	//valido la extension de los archivos, si no es una de las q corresponde, no guarda...
	//recibe el path del archivo ,un array con las extensiones validas y el key del campo q esta validando
	function validateExtension (tField,extArray,fieldName){ 
		file=tField.value;  
		allowSubmit = false; 
		
		if (!file) return; 
			while (file.indexOf("/") != -1) file = file.slice(file.indexOf("/") + 1); 
			ext = file.substring(file.length-4,file.length).toLowerCase(); 
			for (var i = 0; i < extArray.length; i++) { 
				if (extArray[i] == ext) { 
					allowSubmit = true; 
				break; 
			} 
		} 
		if (allowSubmit == false) {  
			tField.value=""; 
			alert(fieldName + "\n" + msgJsFileExtension + " " + (extArray.join(" ")) + "\n" + msgJsSelectNewFile + "."); 
		} 
		return allowSubmit;
	} 

	//selecciona / deselecciona todos los checkbox con nombre field del 
	//formulario oForm
	//En WebUtil hay una funcion llamada getSelectAllHTML(..) que renderea
	//un boton que permite llamar a esta funcion
	function selectAll(oForm, name){			
		check = eval(oForm + '.' + name);
		if(check!=null){				
			if(check.length == undefined){				
				check.click();
			}
			else{
				for(i=0; i<check.length;i++){			
					check[i].click();
				}
			}
		}				
	}

	//valida la seleccion de registros para la edicion, eliminacion, etc... si type=simple permite seleccion unica,
	//si type=multiple, permite seleccionar varios registros 	
	function validateChecked(oForm, type, fieldName){
		var result = 0;
		var selected = false;
		
		if ((typeof(oForm) == 'object')){
			formName = oForm.name;
		}
		else{
			formName = oForm
		}
		
		if (fieldName!= undefined){
			//viene el fieldName
			check = eval('document.' + formName + '.' + fieldName);	
		}
		else{
			//no viene el fieldname, funciona como antes
			check = eval(formName + '.selectedItems');				
		}
		
		if(check != undefined){//si hay registros...
			if(check.length != undefined){//hay varios registros
				var pos,cont = 0;
				var selected = false;
				var stringItems = "";
				for(i=0;i<check.length;i++){
					if(check[i].checked==true){
						cont++;
						pos = i;
						stringItems = stringItems + check[i].value + "|";
						selected = true;
					}
				}
				if(type == 'simple'){//si permito seleccion unica (simple) 
					if(cont > 1){//hay mas de un registro seleccionado
						alert(msgJsOneRegistry);
					}else if(cont == 1){
						result = check[pos].value;
					}
				}else {//es seleccion multiple (multiple)
					result = stringItems;
				}
			}else {//hay un único registro 
				if(check.checked==true){
					result = check.value;
					selected = true;
				}
			}
			if(selected == false){
				alert(msgJsMustSelect);
			}
		}else {//no hay ningun registro
			alert(msgJsMustSelect);
		}
		return result;
	}
	
	//dado un radio o un checkbox, deja seleccionados 
	//aquellos cuyo value sea = al value pasado como parametro
	function markSelected(oForm, fieldName, value){			
		check = eval(oForm + '.' + fieldName);
		if(check!=null){				
			if(check.length == undefined){				
				check.click();
			}
			else{
				for(i=0; i<check.length;i++){			
					if(check[i].value==value){
						check[i].click();
					}
				}
			}
		}				
	}
	
	//Realiza un trim.
	function trim(str){
		return str.replace(/^\s*|\s*$/g,"");
	}

   	//Abre la ventana para comprar relacionados	
   	function openRelatedPopUp(idProduct, idNode, toGoBack){
  		remote = window.open("catalogNavigation.do?action=getRelateds&idNode=" + idNode + "&cdProduct=" + idProduct + "&toGoBack=" + toGoBack,'','toolbar=no, menubar=no, scrollbars=yes, resizable=yes, height=495,width=500');
  		if (remote.opener == null){ 
			remote.opener = window;
		} 
	    remote.opener.name = "opener";
   	}   	
   	
   	//Abre la ventana de detalle de promociones
   	function openPromotionPopUp(cdProduct, toGoBack){
  		window.open("catalogNavigation.do?action=getPromoDetail&cdProduct=" + cdProduct + "&toGoBack=" + toGoBack,'','toolbar=no, menubar=no, scrollbars=yes, resizable=yes, height=495,width=500');
   	}   	
   	
   	function MM_showHideLayersSpecial() { //v6.0
	  var i,p,v,w,obj,args=MM_showHideLayersSpecial.arguments;
	  for (i=0; i<(args.length-2); i+=3) 
	  	if ((obj=MM_findObj(args[i]))!=null) { 
		  	v=args[i+2];
	    		if (obj.style) { 
			    obj=obj.style; 
			    w=v;
			    v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			    w=(w=='show')?'block':(w=='hide')?'none':w; 		    		    
			}
	    		obj.visibility=v; 
	     		obj.display=w;
		}
	}
	
	
	function MM_changeStyleProduct(objName,theProp,theValue) { //v6.0
	var i,p,v,obj,args=MM_changeStyleProduct.arguments;
  	for (i=0; i<(args.length-2); i+=3) 
  		if ((obj=MM_findObj(args[i]))!=null) { 
			theProp = args[i+1];
			theValue = args[i+2];
		  	eval("obj."+theProp+"='"+theValue+"'");	
		}
	}
   	
   	//display scrolling text in status bar
   	var _sstmrID = null;
	var _sstmrON = false;
	var _sspos   = 300;
	
	function _ScrollStatus(msg, delay)
	{
	  if (_sstmrON)
	  {
	    window.clearTimeout(_sstmrID);
	    _sstmrON = false;
	  }
	
	  var statmsg = "";
	
	  if (_sspos >= 0)
	  {
	    for (s = 0; s < _sspos; s++)
	    {
	      statmsg += " ";
	    }
	
	    statmsg += msg;
	  }
	  else
	  {
	    statmsg = msg.substring(-_sspos, msg.length);
	  }
	  window.status = statmsg;
	  _sspos = (-_sspos > msg.length) ? 300 : _sspos - 1;
	  fname = "_ScrollStatus('" + msg + "', " + delay + ")";
	  _sstmrID = window.setTimeout(fname, delay);
	  _sstmrON = true;
	}
	
	//Variables utilizadas por el visualizador de extends scroller.jsp	
	var activeScrollers=new Array()
	var currentScroller=0
	var delay=8000 //delay entre mensajes (tiempo en milisegundos)
	var fwidth=200 //ancho del scroller(width)
	var fheight=150 //alto del scroller(heigth)
	var fadescheme=0 //0 para un fade del color del texto de (blanco a negro), 1 para (nagra a blanco)
	var fadelinks=0  //los links deben tener fade como el texto? 0 no, 1 sí.
	///No need to edit below this line/////////////////	
	var startcolor=(fadescheme==0)? "rgb(255,255,255)" : "rgb(0,0,0)"
	var endcolor=(fadescheme==0)? "rgb(0,0,0)" : "rgb(255,255,255)"
	var ie4=document.all&&!document.getElementById
	var ns4=document.layers
	var DOM2=document.getElementById
	var faderdelay=0
	
	if (DOM2)
		faderdelay=2000
	var begintag=''; //set opening tag, such as font declarations
	var closetag=''
	
	//Fin variables utilizadas por el visualizador de extends scroller.jsp
	
	//estas funciones se usan para modificar las cantidades que se estan comprando
	//o actualizando en el pedido en proceso
	function updateQuantities(form, action, quantity, target){
		//en action viene lo que hay que hacer:
		//action = 'add'
		//action = 'subtract'
		//action = 'replace'
		//action = 'min'
		//action = 'round'
		//En target dice si aplica a todos a a los seleccionados
		//target = 'all'
		//target = 'selected'
		var fields = form.quantities;	
		//var decimalsNumber = form.decimals;	
		//var ids = form.items;
		var chks = form.CBXROOT;
		//var maxIntegerDigits = form.maxIntegerDigits;
		//alert(form.quantities.length);
		//alert(fields[0].value);
		if(fields.length != undefined){//es un arreglo de valores
			for(j=0;j<fields.length;j++){
				if (target=='all'){
					executeAction(form, action, quantity, fields, j);
				}
				else{
					//veo si esta checkeado
					if(chks[j].checked){
						executeAction(form, action, quantity, fields, j);
					}
				}
			}
		}
		else{//es un solo valor
			if (target=='all'){
				executeAction(form, action, quantity, fields);
			}
			else{
				//veo si esta checkeado
				if(chks[j].checked){
					executeAction(form, action, quantity, fields);
				}
			}
		}
	}
	
	function executeAction(form, action, quantity, fields, index){
		//alert(index)
		//alert(fields[index])
		if(fields.length != undefined){//es un arreglo de valores
			var field = fields[index];
			var min = form.min[index].value;
			var round = form.round[index].value;
		}
		else{
			var field = fields;
			var min = form.min.value;
			var round = form.round.value;
		}
		
		var quant = field.value; 
		if (quant == null || quant == 'null' || quant == ''){
			quant = 0;
		}
		quant = quant * 1;		
		
		if (quantity == null || quantity == 'null' || quantity == ''){
			quantity = 0;
		}
		quantity = quantity * 1;				
		
		switch (action){
		case 'add': 
			field.value = quant + quantity
		break;
		case 'addPercent': 
			field.value =parseInt(quant * quantity / 100 + quant)
		break;		
		case 'subtract': 
			if (field.value >= quantity){
				field.value = quant - quantity
			}
		break;
		case 'subtractPercent': 
			field.value = parseInt(quant - quant * quantity / 100)>0?parseInt(quant - quant * quantity / 100):quant;
		break;				
		case 'replace': 
			field.value = quantity
			//alert('replace')
		break;
		case 'min': 
			//alert(min)
			if (min == null || min == 'null' || min == ''){
				min = 0;
			}
			field.value = min
			//alert('min')
		break;		
		case 'round': 
			if (round == null || round == 'null' || round == 0 || round == ''){
				round = 1;
			}		
			round = round * 1;				
			var mod = quant % round;
			//alert(mod)
			if (mod == 0) {
				round = quant;
			} else {
				round = quant + round - mod;
			}
			field.value = round
			//alert('round')
		break;
		default : alert('El action ' + action + ' no está definido.');
		}						
	}
	
	function openUpdatePopUp(){	
		//window.showModalDialog("fe/tord/updatePopUp.jsp","","dialogWidth:250px;dialogHeight:180px");
  		window.open("fe/tord/updatePopUp.jsp",'','toolbar=no, menubar=no, scrollbars=no, resizable=no, height=250,width=250');
   	}
   	
   	function openFunctionPopUp(field,table){
  		window.open("be/repo/functionPopUp.jsp?field="+field+"&table="+table,'','toolbar=no, menubar=no, scrollbars=no, resizable=no, height=100,width=380');
   	}
   	
   	function openSuggestPopUp(field){
  		window.open("be/repo/suggestValuePopUp.jsp?field="+field,'','toolbar=no, menubar=no, scrollbars=no, resizable=no, height=100,width=380');
   	}
   	
   	
   	function returnUpdateFunction(action, quantity, target){		
		updateQuantities(document.order,action,quantity,target);
	}
	
	//fin funciones que se utilizan para modificar cantidades
	
	
	
function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

	
	
	function validateCorrespondency(result, item, enterprise, symbol){
		var firstSplitted = result.split('|');
		//por cada registro seleccionado, espliteo el id de la empresa y armo el string con ids q mando 
		item = "";
		for(i=0;i<firstSplitted.length-1;i++){
			var idSplitted = firstSplitted[i].split(symbol);
			item += idSplitted[0];
			if(idSplitted[1] != enterprise){
				return false;
			}
		}
		return item;
	}
	
	
	function searchContents(field){	
		var dsSearch = document.getElementById(field).value;
		var re = new RegExp("^[a-zA-Z0-9_.,;ñ\\sáéíóúÁÉÍÓÚäëïöüÄËÏÖÜ*]+$");
		//Se agrego este if para que busque sin poner ningun carater solo presionando la flecha.
		if(dsSearch.length==0){
			dsSearch = ' ';
		}
			
		if (dsSearch.match(re)) {
			return true;
		}else{
		  	return false;	
		}
	}	
	
	