function openWindow(url,name,width,height) {
  window.open(url,name,"menubar=0,resizable=1,toolbar=0,directories=0,location=0,scrollbars=1,width=" + width + ",height=" + height);
}

var ToggleRadio = Class.create();
ToggleRadio.prototype = {
    initialize:    function (ids) {
    	  this.ids = ids;
				for (var a = 0 ; a < this.ids.length ; a++)
			    Event.observe ($(this.ids[a][0]), 'change', this.actua.bindAsEventListener (this), true);
				this.actua ();
    },
    actua: function (e) {
          for (var a = 0 ; a < this.ids.length ; a++)
          {
            if ($ (this.ids [a][0]).checked == true)
  						$(this.ids[a][1]).style.display = 'block';
  					else $(this.ids[a][1]).style.display = 'none';
          }
    }
};

var ToggleCheckBox = Class.create();
ToggleCheckBox.prototype = {
  initialize: function (ids) {
   		this.input = ids[0];
    	this.div = ids[1];
		
  		if (typeof this.input == 'string')
  			this.input = [this.input];
  		for (var i = 0 ; i < this.input.length ; i++)
  		{
  			Event.observe( $(this.input [i]), 'click', this.actua.bindAsEventListener (this), true);
  		}
      this.actua ();
  },
            
  actua: function (e) {
			var checked = false;
			for (var i = 0 ; i < this.input.length ; i++)
					if ($(this.input [i]).checked == true)
						checked = true;
    	if (checked)
      	$(this.div).style.display = 'block';
    	else
    	$(this.div).style.display = 'none';
  }
};

function autofocus(field, limit, next, evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && field.value.length == limit) {
        field.form.elements[next].focus();
    }
}

function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Por favor, introduzca sólo números en este campo");
        return false;
    }
    return true;
}
