$(document).ready(function() {

    $(".register-form input.firstName").setInputBox('First name', 'focus', 'filled', '50');
    $(".register-form input.lastName").setInputBox('Last name', 'focus', 'filled', '50');
    $(".register-form input.email").setInputBox('Email', 'focus', 'filled', '1000');
    $(".register-form input.mobile").setInputBox('Mobile', 'focus', 'filled', '10');
    $(".register-form input.stNum").setInputBox('Street number', 'focus', 'filled', '10');
    $(".register-form input.stName").setInputBox('Street address', 'focus', 'filled', '50');
    $(".register-form input.suburb").setInputBox('Suburb', 'focus', 'filled', '100');
    $(".register-form input.postcode").setInputBox('Postcode', 'focus', 'filled', '4');


    $('.rate-carousel').cycle({
        fx: 'fade',
        speed: 1000
    });

    if($('.landing-register-form-holder')) 
	{
		$('.landing-register-form-holder').css('top', ((560 - $('.landing-register-form-holder').height())>0?(560 - $('.landing-register-form-holder').height()):0)/2);
	}
	
});


jQuery.fn.setInputBox = function(message, onfocusClass, filledClass, setMaxLength) {
    return this.each(function() {
        var defaultMaxLength = setMaxLength;
        //alert(setMaxLength);
        var messageDefault = $(this).attr('value') ? $(this).attr('value') : message;
        $(this).attr('value', messageDefault);
        
        $(this).click(function() {        	
            if ($.trim($(this).attr('value')) == $.trim(messageDefault)) $(this).attr('value', '');
            $(this).removeClass(filledClass);
            $(this).addClass(onfocusClass);
            $(this).attr('maxLength', defaultMaxLength);
        });

        $(this).blur(function() {
        	$(this).attr('maxLength', '100000');       
            if ($.trim($(this).attr('value')) == '') $(this).attr('value', messageDefault);
            else $(this).addClass(filledClass);
            $(this).removeClass(onfocusClass);
            
        });

    });
};
