// Title      : B�squeda General
// Description: Funciones para la b�squeda general
// Version    : 1.0 

function searchLink(objFor){

   var strIdioma = "es";
   if(objFor.Keyword.value == ''){
  	  if(objFor.idioma.value == 'I'){
	    alert("Please enter a word");
	  }
	  if(objFor.idioma.value == 'E'){
	     alert("Debe ingresar una palabra");
	  }
	  objFor.Keyword.focus();
	  return false;
    }else{
	  revisaTexto2( objFor , objFor.Keyword );
  	  if (objFor.idioma.value == 'E') strIdioma = "es";
      if (objFor.idioma.value == 'I') strIdioma = "en";
  	  objFor.action = "http://links.bnamericas.com/"+strIdioma+"/links/results/"+objFor.Keyword.value;
	  objFor.submit();
     }
    
}

function searchNews(objFor){ 
    //    if (objFor.sKeyword2.value =="")
    /*
 	objFor.sKeyword.value = document.buscar.sKeyword2[0].value

    if(objFor.sKeyword.value == ''){
	if(objFor.idioma.value == 'I'){
	    alert("Please enter a word");
	}
	if(objFor.idioma.value == 'E'){
	    alert("Debe ingresar una palabra");
	}
	objFor.sKeyword.focus();
	return false;
    }else{
	revisaTexto2( objFor , objFor.sKeyword );
	objFor.submit();
    }
}
    */
    //    if (document.buscar.sKeyword2[0].value != "")
    //	objFor.Keyword.value = document.buscar.sKeyword2[0].value

    if(objFor.Keyword.value == ''){

	if(objFor.idioma.value == 'I'){
	    alert("Please enter a word");
	}
	if(objFor.idioma.value == 'E'){
	    alert("Debe ingresar una palabra");
	}
	objFor.Keyword.focus();
	return false;
    }else{
	revisaTexto2( objFor , objFor.Keyword );
        //objFor.tScope.value = build_chkb_selection('document.form1', 'chkscope',5);
        //if(objFor.tScope.value=='N')
        //   objFor.nRegsXPagina.value = 20;
	objFor.submit();
        return true;
    }
}

	function build_chkb_selection(sel, Nombre, NumCheckboxes)
	{ 
		StrResult = ""; 
		for (id_chkbox = 1 ; id_chkbox <= NumCheckboxes ; id_chkbox++) 
		{
                   if(document.getElementById(Nombre+id_chkbox))
                   {
                   
			isChecked = eval(sel+"."+Nombre+id_chkbox+".checked");  
			if (isChecked)
			{ 
				if (StrResult == "")
					StrResult = eval(sel+"."+Nombre+id_chkbox+".value"); 
				else
					StrResult = StrResult + ":" + eval(sel+"."+Nombre+id_chkbox+".value"); 
			}
                    }
		}
		return StrResult;
	}  
        
function revisaTexto2( objFor, objNombre )
{	
    miString = objNombre.value;
	
	result='';
    
    for(i=0;i <=miString.length;i++)
	{
            if(miString.charAt(i) =='\''){
                    result = result + '\'\'';
            } else{
                    result = result +  miString.charAt(i);
            }
    }
    objFor.txtSearch.value = result;
    return true;
}


