  function setSearch(idSearchForm) {
    var aux="";
    var parametros="";
    // Text box
    $("#"+idSearchForm+" input[type='text']").each(function () {
      aux=this.value;
      if( aux!="" && aux!="undefined" ) parametros+="&"+this.id+"="+aux;
    });
    // Check box
    $("#"+idSearchForm+" input[type='checkbox']").each(function () {
      aux=this.value;
      if( this.checked ) parametros+="&"+this.id+"="+aux;
    });
    // Radio button
    $("#"+idSearchForm+" input[type='radio']").each(function () {
      aux=this.value;
      if( this.checked ) parametros+="&"+this.id+"="+aux;
    });
    // Select list
    $("#"+idSearchForm+" select").each(function () {
      aux=$("#"+this.id).selectedValues();
      // NONONO MIRAR ESTO if(aux.length>1) for(var i=0;i<aux.length;i++) parametros+="&"+this.id+"="+aux[i];
      if( aux.length>0 && ( aux!="NaN" && aux!="" && aux!="undefined" ) ) parametros+="&"+this.id+"="+aux;
    });
    
    return parametros;
  }
  
  
	function cambiar(linea) {
		if(linea.className=="linea_off") linea.className="linea_on";
		else linea.className="linea_off";
	}
	function togel(submenuses,cuantos) {
		for(i=0;i<cuantos;i++) {
			$("#"+submenuses+(i+1)).toggle();
		}		
	}
	function esconder() {
		var tipo=$("#flecha").attr('src');

		if(tipo.indexOf("flechaCerrar.jpg")>0) {
			$("#flecha").attr('src',initParam.site_comun+"/img/flechaAbrir.jpg");
			$("#content").css("width",(initParam.wdwWidth-90)+"px");
			$("#menuDerecha").hide();
		}
		else {
			$("#flecha").attr('src',initParam.site_comun+"/img/flechaCerrar.jpg");
			$("#content").css("width",(initParam.wdwWidth-205)+"px");
			$("#menuDerecha").show();
		}
	}
	function replaceAll(original,cambiar,por) {
			while( ("xx"+original).indexOf(cambiar)>0 ) {
	  			original=original.replace(cambiar,por);
			}
		return original;
	}
function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)

/* EJEMPLOS */
  // loadjscssfile("myscript.js", "js") //dynamically load and add this .js file
  // loadjscssfile("javascript.php", "js") //dynamically load "javascript.php" as a JavaScript file
  // loadjscssfile("mystyle.css", "css") ////dynamically load and add this .css file
}

// Esta funci&#243;n sobra
function recogeDatos(url,parametros,callback) {
  //var datos="";
  $.get(url,parametros,function (data) { eval(callback+"('"+data+"')"); });
  //return datos;
}

function loadSelect(url,parametros,selecId,name) {
  $("#"+selecId).removeOption(/./);
 
  if(name!=null) {
    var inicial={"":"- Select "+name+" -"};
    $("#"+selecId).addOption(inicial,false);
  }
    
  $("#"+selecId).ajaxAddOption(url,parametros, false);
}
function serializar(matriz) {
  var aux="-1";
  for(var i=0;i<matriz.length;i++) aux+=","+matriz[i];

  return aux;
}

function setInitParams() {  
  var ancho=0;
  var alto=0;
  
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  ancho = document.body.offsetWidth;
	  alto = document.body.offsetHeight;
	 } else {
	  ancho = window.innerWidth;
	  alto = window.innerHeight;
	 }
	}

  initParam={'gridWidth':'930',
                 'gridHeight':'395',
                 'site':site,
                 'site_comun':site_comun,
                 'wdwWidth':ancho,
                 'wdwHeight':alto
                };
}

// Esta funci&#243;n pone, si lo hay, un valor por defecto en los inputs y text&#225;reas y hace los efectos de onBlur y onFocus
function preparaInputs() {
	$("input[@type='text'],textarea").each(function() {
		var porDefecto=""+$(this).attr('defaultValue');
		if(porDefecto!="undefined") $(this).val(porDefecto);
	});
	
	$("input[@type='text'],textarea").focus(function(){
		var porDefecto=""+$(this).attr('defaultValue');
		if($(this).val() == porDefecto)
			if(("-"+$(this).val()).indexOf("*")<0) $(this).val('');
			else $(this).select();
  });
  
	$('input[@type=text],textarea').blur(function() {
		var porDefecto=""+$(this).attr('defaultValue');
		if($(this).val() == '' && porDefecto!="undefined") $(this).val(porDefecto);
	});
}

function setWindowSize() {	
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
	$.session("wdwWidth",myWidth);
	$.session("wdwHeight",myHeight);
}

//$(document).ready( setWindow );
