function clearValues() {
	if(!document.getElementsByTagName) return false;
		
	var formFields = document.getElementsByTagName('input');
                
	for(var i=0; i < formFields.length; i++) {
		if(formFields[i].type == 'text' && formFields[i].value.length > 0 && formFields[i].className.indexOf('clearvalue') != -1) {
			formFields[i].defaultValue = formFields[i].value;

			formFields[i].onfocus = function(){ if(this.value == this.defaultValue) this.value = ''; }
			formFields[i].onblur  = function(){ if(this.value.length == 0) this.value = this.defaultValue; }
		}
	}
}

TOC = new Class({
	initialize: function() {
		$$('.toc').each(function(parent){
			this.build(parent);
		}.bind(this));
	},
	
	build: function(parent) {
		$A(parent.getElementsByTagName('h3')).each(function(el, i) {
			if(!$('toc')) {
				var toc = new Element('ol');
				toc.setAttribute('id', 'toc');
				$('box-toc').adopt(toc);
			}
			
			var item = new Element('li');
			item.setHTML(' <a href="#section-'+i+'">'+el.innerHTML+'</a>');
			$('toc').adopt(item);
	
			/*var top = new Element('a');
			top.addClass('totop');
			top.setAttribute('href', '#head');
			top.setHTML('top');*/
	
			el.setAttribute('id', 'section-'+i);
			//el.adopt(top);
		}.bind(this));
	}
});



window.addEvent('domready', function(){
	clearValues();
	new TOC();	
	new SmoothScroll();					 
});