function changeText( id, txt ) {

	if ( $( id ) ) $( id ).innerHTML = txt; 

}


function jump_menu( ele ) {

	if ( Event && Event.element ) {
		ele = Event.element( ele );
	} else {
		ele = this;
	}

	url = ele.options[ ele.selectedIndex ].value;

	window.location.assign( url );

}


function selectText( ele ) { 

		
	try {
		focus = ele.focus;
		select = ele.select;
		
		try {
			ele.observe( "click", focus );
			ele.observe( "click", select );
		} catch ( err ) {
			ele.addEvent( "click", focus );
			ele.addEvent( "click", select );
		}		
		
	} catch ( err ) {
		ie = true;
	}



}


try {
	$$( ".selectText" ).each( selectText );
} catch ( err ) {
	$$( ".selectText" ).forEach( selectText );
}









/**
 * Auto inject is a crafty way to place content in a html page
 * from another place on the page
 *
 * The use of this is/was primarilly aimed at loading adverts
 * last. This also offers the adverts to be centralised
 */

function autoInject( autoInjectElement ){

    this.source = ( autoInjectElement ) ? autoInjectElement : $('autoInject');
    this.destinationSuffix = 'Container';
    this.itemNodeSelector = 'li';

    /*
     * Return the html value of a node
     *
     * @param Element
     * @return String
     */
    this.getItemContent = function( item ){

        if(item){
            return item.innerHTML;
        }
    }

    /*
     * Go and look for the individual elements under the source block
     *
     * eg.
     * <ul>
     *  <li>some content</li>
     * </ul>
     *
     * @return Element
     */
    this.getItems = function(){

        if(this.source){
            var elements = this.source.getElementsBySelector( this.itemNodeSelector );
            if(elements){
               return elements;
            }
            return;
        }
    }

    /*
     * Get the html element (destination) that will the content will be placed into
     * Don't confuse this with the temp Destination (the source)
     *
     * @param Element
     * @return Element
     */
    this.getDestination = function( item ){

        if(item){
           // get the current items id
           var itemId = item.id;

           // see if the item has a matching Destination with the same name and the provided suffix
           var destinationId = itemId.replace(this.destinationSuffix, '');
           if($(destinationId)){
               // return it!
               return $(destinationId);
           }
        }
        else{
            return;
        }
    }

    /*
     * Fill the Destination element
     *
     * @param Element
     * @return boolean
     */
    this.populateDestination = function( item ){

        if(item){
            var itemDestination = this.getDestination(item);
            if(itemDestination){
                var bufferContents = this.getItemContent(item);
                this.removeItem(item);
                itemDestination.innerHTML = bufferContents;
                return true;
            }
            return;
        }
    }

    /*
     * Fill all the Destination elements with its matching source content
     *
     * @return boolean
     */
    this.populateDestinations = function(){

        var elements = this.getItems();

        if(elements){
            for(i = 0; i < elements.length; i++){
                this.populateDestination(elements[i]);
            }

            return true;
        }
        return;
    }

    /*
     * Remove an element node
     *
     * @param Element
     * @return boolean
     */
    this.removeItem = function( item ){

        if(item){
            item.remove();
            return true;
        }
        return;
    }
}

