function AgregarEstiloOnLoad(styleUrl)
{
	document.observe( "dom:loaded", function() {
		AgregarEstilo( styleUrl );
	});
}

function AgregarEstilo(styleUrl)
{
	if(document.createStyleSheet) 
	{
		document.createStyleSheet(styleUrl);
	}
	else 
	{	
		var newSS=document.createElement('link');
		newSS.rel='stylesheet';
		newSS.type = 'text/css';
		newSS.href= styleUrl;
		document.getElementsByTagName("head")[0].appendChild(newSS);
	}
}

var BtnNaranja22 = Class.create();

BtnNaranja22.prototype = {
	_id: '',
	_texto: '',
	_callback: '',
	_width: '',
	
	initialize: function ( id, texto, width, callback ) {
		this._id = id;
		this._texto = texto;
		this._width = width;
		this._callback = callback;
		
		var btnDiv = $( this._id );
		
		btnDiv.addClassName( "BotonV3" );
		btnDiv.addClassName( "BotonNaranja" );
		
		var inputElm = document.createElement( "input" );
		inputElm.setAttribute( "type", "button" );
		inputElm.style.width = this._width + "px";
		inputElm.setAttribute( "onclick", this._callback );
		inputElm.setAttribute( "value", this._texto );
		btnDiv.appendChild( inputElm );
		
		var BV3_1 = document.createElement( "div" );
		btnDiv.appendChild( BV3_1 );
		$( BV3_1 ).addClassName( "BV3_1" );
		
		var BV3_2 = document.createElement( "div" );
		BV3_1.appendChild( BV3_2 );
		$( BV3_2 ).addClassName( "BV3_2" );
	}
}

var BtnVerde22 = Class.create();

BtnVerde22.prototype = {
	_id: '',
	_texto: '',
	_callback: '',
	_width: '',
	
	initialize: function ( id, texto, width, callback ) {
		this._id = id;
		this._texto = texto;
		this._width = width;
		this._callback = callback;
		
		var btnDiv = $( this._id );
		
		btnDiv.addClassName( "BotonV3" );
		btnDiv.addClassName( "BotonVerde" );
		
		var inputElm = document.createElement( "input" );
		inputElm.setAttribute( "type", "button" );
		inputElm.style.width = this._width + "px";
		inputElm.setAttribute( "onclick", this._callback );
		inputElm.setAttribute( "value", this._texto );
		btnDiv.appendChild( inputElm );
		
		var BV3_1 = document.createElement( "div" );
		btnDiv.appendChild( BV3_1 );
		$( BV3_1 ).addClassName( "BV3_1" );
		
		var BV3_2 = document.createElement( "div" );
		BV3_1.appendChild( BV3_2 );
		$( BV3_2 ).addClassName( "BV3_2" );
	}
}

var BtnAzul22 = Class.create();

BtnAzul22.prototype = {
	_id: '',
	_texto: '',
	_callback: '',
	_width: '',
	
	initialize: function ( id, texto, width, callback ) {
		this._id = id;
		this._texto = texto;
		this._width = width;
		this._callback = callback;
		
		var btnDiv = $( this._id );
		
		btnDiv.addClassName( "BotonV3" );
		btnDiv.addClassName( "BotonAzul" );
		
		var inputElm = document.createElement( "input" );
		inputElm.setAttribute( "type", "button" );
		inputElm.style.width = this._width + "px";
		inputElm.setAttribute( "onclick", this._callback );
		inputElm.setAttribute( "value", this._texto );
		btnDiv.appendChild( inputElm );
		
		var BV3_1 = document.createElement( "div" );
		btnDiv.appendChild( BV3_1 );
		$( BV3_1 ).addClassName( "BV3_1" );
		
		var BV3_2 = document.createElement( "div" );
		BV3_1.appendChild( BV3_2 );
		$( BV3_2 ).addClassName( "BV3_2" );
	}
}



var BtnNaranja27 = Class.create();

BtnNaranja27.prototype = {
	_id: '',
	_texto: '',
	_callback: '',
	_width: '',
	
	initialize: function ( id, texto, width, callback ) {
		this._id = id;
		this._texto = texto;
		this._width = width;
		this._callback = callback;
		
		var btnDiv = $( this._id );
		
		btnDiv.addClassName( "BotonV3_27" );
		btnDiv.addClassName( "BotonNaranja27" );
		
		var inputElm = document.createElement( "input" );
		inputElm.setAttribute( "type", "button" );
		inputElm.style.width = this._width + "px";
		inputElm.setAttribute( "onclick", this._callback );
		inputElm.setAttribute( "value", this._texto );
		btnDiv.appendChild( inputElm );
		
		var BV3_1 = document.createElement( "div" );
		btnDiv.appendChild( BV3_1 );
		$( BV3_1 ).addClassName( "BV3_1" );
		
		var BV3_2 = document.createElement( "div" );
		BV3_1.appendChild( BV3_2 );
		$( BV3_2 ).addClassName( "BV3_2" );
	}
}

var BtnVerde27 = Class.create();

BtnVerde27.prototype = {
	_id: '',
	_texto: '',
	_callback: '',
	_width: '',
	
	initialize: function ( id, texto, width, callback ) {
		this._id = id;
		this._texto = texto;
		this._width = width;
		this._callback = callback;
		
		var btnDiv = $( this._id );
		
		btnDiv.addClassName( "BotonV3_27" );
		btnDiv.addClassName( "BotonVerde27" );
		
		var inputElm = document.createElement( "input" );
		inputElm.setAttribute( "type", "button" );
		inputElm.style.width = this._width + "px";
		inputElm.setAttribute( "onclick", this._callback );
		inputElm.setAttribute( "value", this._texto );
		btnDiv.appendChild( inputElm );
		
		var BV3_1 = document.createElement( "div" );
		btnDiv.appendChild( BV3_1 );
		$( BV3_1 ).addClassName( "BV3_1" );
		
		var BV3_2 = document.createElement( "div" );
		BV3_1.appendChild( BV3_2 );
		$( BV3_2 ).addClassName( "BV3_2" );
	}
}

var BtnAzul27 = Class.create();

BtnAzul27.prototype = {
	_id: '',
	_texto: '',
	_callback: '',
	_width: '',
	
	initialize: function ( id, texto, width, callback ) {
		this._id = id;
		this._texto = texto;
		this._width = width;
		this._callback = callback;
		
		var btnDiv = $( this._id );
		
		btnDiv.addClassName( "BotonV3_27" );
		btnDiv.addClassName( "BotonAzul27" );
		
		var inputElm = document.createElement( "input" );
		inputElm.setAttribute( "type", "button" );
		inputElm.style.width = this._width + "px";
		inputElm.setAttribute( "onclick", this._callback );
		inputElm.setAttribute( "value", this._texto );
		btnDiv.appendChild( inputElm );
		
		var BV3_1 = document.createElement( "div" );
		btnDiv.appendChild( BV3_1 );
		$( BV3_1 ).addClassName( "BV3_1" );
		
		var BV3_2 = document.createElement( "div" );
		BV3_1.appendChild( BV3_2 );
		$( BV3_2 ).addClassName( "BV3_2" );
	}
}

function BtnTools_Enable( id )
{
	$(id).select("input")[0].disabled = false;
}

function BtnTools_Disable( id )
{
	$(id).select("input")[0].disabled = true;
}


document.observe("dom:loaded", function() {
	initButtons( );
});

function initButtons()
{
	$$( ".BtnNaranja22" ).each( function (boton) {
		var texto =  boton.innerHTML;
		boton.innerHTML = "";
		var callback = boton.onclick;
		new BtnNaranja22( boton.id, texto, boton.readAttribute("width"), callback );
		if ( Prototype.Browser.IE )
		{
			boton.onclick = "";
		}
	} );
	
	$$( ".BtnNaranja27" ).each( function (boton) {
		var texto =  boton.innerHTML;
		boton.innerHTML = "";
		var callback = boton.onclick;
		new BtnNaranja27( boton.id, texto, boton.readAttribute("width"), callback );
		if ( Prototype.Browser.IE )
		{
			boton.onclick = "";
		}
	} );
	
	$$( ".BtnVerde22" ).each( function (boton) {
		var texto =  boton.innerHTML;
		boton.innerHTML = "";
		var callback = boton.onclick;
		new BtnVerde22( boton.id, texto, boton.readAttribute("width"), callback );
		if ( Prototype.Browser.IE )
		{
			boton.onclick = "";
		}
	} );
	
	$$( ".BtnVerde27" ).each( function (boton) {
		var texto =  boton.innerHTML;
		boton.innerHTML = "";
		var callback = boton.onclick;
		new BtnVerde27( boton.id, texto, boton.readAttribute("width"), callback );
		if ( Prototype.Browser.IE )
		{
			boton.onclick = "";
		}
	} );
	
	$$( ".BtnAzul22" ).each( function (boton) {
		var texto =  boton.innerHTML;
		boton.innerHTML = "";
		var callback = boton.onclick;
		new BtnAzul22( boton.id, texto, boton.readAttribute("width"), callback );
		if ( Prototype.Browser.IE )
		{
			boton.onclick = "";
		}
	} );
	
	$$( ".BtnAzul27" ).each( function (boton) {
		var texto =  boton.innerHTML;
		boton.innerHTML = "";
		var callback = boton.onclick;
		new BtnAzul27( boton.id, texto, boton.readAttribute("width"), callback );
		if ( Prototype.Browser.IE )
		{
			boton.onclick = "";
		}
	} );
}

/**
 * Cross browser method for creating new DOM nodes with name attributes. This
 * gets around an Internet Explorer bug that prevents that get the name property
 * assigned to them and their values aren't sent when the form submits.
 *
 * @param   string  required  Node name, like "div" or "input"
 * @param   string  required  Value of the name attribute
 * @return  object  New DOM node
 */
function createElement(nodeName, name) {
  var node;
  try {
    node = createElementMsie(nodeName, name);
    createElement = createElementMsie;
  } catch (e) {
    node = createElementStandard(nodeName, name);
    createElement = createElementStandard;
  }
  return node;
}

/**
 * Code required by Internet Explorer when creating a new DOM node with the
 * name attribute set.
 */
function createElementMsie(nodeName, name) {
  return document.createElement("<"+nodeName+" name="+name+">");
}

/**
 * Code required by all other browsers that support web standards.
 */
function createElementStandard(nodeName, name) {
  var node = document.createElement(nodeName);
  node.name = name;
  return node;
}

function stringificarJSON(parametro) 
{
    var JSONstringificado = Object.toJSON ? Object.toJSON(parametro) : JSON.stringify(parametro);

	return JSONstringificado;
}

function NewWin(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function InvocarWebServiceUsandoJQuery( url, metodo, nombreParametro, valorParametro, callbackExito, callbackError ) 
{
	jQuery.ajax({
            type: "POST",
            url: url + "/" + metodo,
            contentType: "application/x-www-form-urlencoded",
            dataType: "xml",
            data: nombreParametro + "=" + stringificarJSON(valorParametro),
            success: function(xml) {
				var respuesta;
				jQuery(xml).find("string").each( function() {
					respuesta = jQuery(this).text();
				} );
                if (callbackExito != undefined) {
					callbackExito(respuesta);
                }
            },
            error: function(request, status, error) {
				if ( callbackError != undefined )
				{
					callbackError( error );
                }
            }
        });
}

function EjecutarRequestAjax( url, metodo, parametros, callbackExito, callbackError ) 
{
	new Ajax.Request( url, {
			method: metodo,
			parameters: parametros ,
			onSuccess: callbackExito,
			onFailure: callbackError
		});
}