/*
----------------------------------------------
 CORE website / Custom JS
 Developed by Ollie Bettany / Twist Internet
 Created: 16/09/09
----------------------------------------------
*/

/* ------------------------------ */
/* Initiate JS				*/
/* ------------------------------ */

function init_custom_js(){
	jQuery("label[for='name']").overlabel();
	jQuery("label[for='ttkjtt-ttkjtt']").overlabel();
	jQuery("label[for='s']").overlabel();
}

/* ------------------------------ */
/* Form overlabels				  */
/* ------------------------------ */

(function($){
	jQuery.fn.overlabel = function() {
		this.each(function(index) {
			var label = $(this); var field;
			var id = this.htmlFor || label.attr('for');
			
			if (id && (field = document.getElementById(id))) {
				var control = $(field);
				label.addClass("overlabel");
				
				if (field.value !== '') {
					label.fadeOut(100);
				}
				control.focus(function () {label.fadeOut(100);}).blur(function () {
				
				if (this.value === '') {
					label.fadeIn(100);
				}
			});
				
			label.click(function() {
				var label = $(this); var field;
				var id = this.htmlFor || label.attr('for');
				
				if (id && (field = document.getElementById(id))) {
					field.focus();
				}
			});
			}
		});
	};
})(jQuery);

/* ------------------------------ */
/* END Form overlabels 			  */
/* ------------------------------ */