// JavaScript Document

// JavaScript Document
$('document').ready(function(){
	init();
	initForm();
});

function init(){
	//initialize dissapearing labels inside text input(s)
	initGhostLabels();
	$("#slider").easySlider({
		auto: true,
		continuous: true 
	});
}

//initialize inputs with inside label that dissapears on focus, then and input gets "active" class
//works for all text inputs with class "ghost_labelled"
function initGhostLabels(){
	//add ghost label behaviour to all inputs with class 'ghost_labelled'
	var ghost_labelled = $('input.ghost_labelled');
	ghost_labelled.each(function(){
		if($(this).val() == ''){
			$(this).get(0).value = $(this).get(0).defaultValue;
			$(this).removeClass('active');
		}
		else if($(this).val() != $(this).attr('defaultValue')){
			$(this).addClass('active');
		}
		$(this).bind('focus', function(e){
											  if($(this).get(0).value == $(this).get(0).defaultValue){
												$(this).get(0).value = '';
												$(this).addClass('active');
											  }
										  });
		$(this).bind('blur', function(e){
											  if($(this).get(0).value == ''){
												$(this).get(0).value = $(this).get(0).defaultValue;
											  	$(this).removeClass('active');
											  }
										  });
	});
}
