var Kirjasto = {
    input: null,
    urlhash: '',
    start: function() {
        this.input = document.getElementById( 'searchinput' );
        this.urlhash = window.location.hash; 
        this.input.value = this.inputText();
        this.input.className = 'ready';
        which = this.activeLink();
        which.style.fontWeight = 'bold';
        if ( this.urlhash == '#kirja' ) {
            which.style.marginRight = '4px';
        }
    },
    inputFocus: function() {
        this.input.className='write'; 
        this.input.value='';
    },
    inputText: function() {
        if ( this.urlhash == '' || this.urlhash == '#kirja' ) {
            return 'Kirja tai Kirjailija';
        }
        if ( this.urlhash == '#video' || this.urlhash == '#dvd' ) {
            return 'Elokuva, nayttelija, tai ohjaaja';
        }
    },
    activeLink: function() {
        if ( this.urlhash == '' || this.urlhash == '#kirja' ) {
            return document.getElementById( 'kirjalink' );
        }
        else if ( this.urlhash == '#dvd' ) {
            return document.getElementById( 'dvdlink' );
        }
        else if ( this.urlhash == '#video' ) {
            return document.getElementById( 'videolink' );
        }
        return false;
    },
    inputBlur: function() {
        if ( this.input.value == '' ) { 
            this.input.value = this.inputText(); 
            this.input.className = 'ready'; 
        }
    },
    Go: function( section, which ) {
        if ( this.activeLink() != false ) {
            this.activeLink().style.fontWeight = 'normal'; 
            this.activeLink().style.marginRight = '10px';
        }
        this.urlhash = section;
        this.input.focus();
        which.style.fontWeight = 'bold';
        if ( this.urlhash == '#kirja' ) {
            which.style.marginRight = '4px';
        }
        else if ( this.urlhash == '#dvd' ) {
            which.style.marginRight = '7px';
        }
    }
};
