$(document).ready(function() {
	var page = (getUrlVars()['page'] !== undefined) ? getUrlVars()['page'].split('.') : '';
	var action = '';
	var objOrigFormVals = new Object();
	
	// SET ORIGINAL VALUES FOR FIELDS : START
	objOrigFormVals.strLicenceKey = 'Licence Key';
	objOrigFormVals.strFirstName = 'First name';
	objOrigFormVals.strLastName = 'Last name';
	objOrigFormVals.strUsername = 'Username';
	objOrigFormVals.strEmailAddress = 'Email Address';
	// SET ORIGINAL VALUES FOR FIELDS : STOP
	
	if (page.length > 1) action = page[1];
	
	// DISPLAY PASSWORD TEXT FIELDS
	if (action !== 'submit') {
		$('#strPassword').next().css('display','block');
		$('#strPassword').hide();
		$('#strPass1').next().css('display','block');
		$('#strPass1').hide();
		$('#strPass2').next().css('display','block');
		$('#strPass2').hide();
	}
	
	$('#strPassword').next().click(function() {
		$('#strPassword').next().hide();
		$('#strPassword').show().val('').focus().blur(function() {
			if ($(this).val().length == 0) {
				$('#strPassword').next().css('display','block');
				$('#strPassword').next().val('Password');
				$('#strPassword').hide();
			}
		});
	});
	
	$('#strPassword').next().focus(function() {
		$('#strPassword').next().hide();
		$('#strPassword').show().val('').focus().blur(function() {
			if ($(this).val().length == 0) {
				$('#strPassword').next().css('display','block');
				$('#strPassword').next().val('Password');
				$('#strPassword').hide();
			}
		});
	});
	
	$('#strPass1').next().click(function() {
		$('#strPass1').next().hide();
		$('#strPass1').show().val('').focus().blur(function() {
			if ($(this).val().length == 0) {
				$('#strPass1').next().css('display','block');
				$('#strPass1').next().val('Password');
				$('#strPass1').hide();
			}
		});
	});
	
	$('#strPass1').next().focus(function() {
		$('#strPass1').next().hide();
		$('#strPass1').show().val('').focus().blur(function() {
			if ($(this).val().length == 0) {
				$('#strPass1').next().css('display','block');
				$('#strPass1').next().val('Password');
				$('#strPass1').hide();
			}
		});
	});
	
	$('#strPass2').next().click(function() {
		$('#strPass2').next().hide();
		$('#strPass2').show().val('').focus().blur(function() {
			if ($(this).val().length == 0) {
				$('#strPass2').next().css('display','block');
				$('#strPass2').next().val('Confirm Password');
				$('#strPass2').hide();
			}
		});
	});
	
	$('#strPass2').next().focus(function() {
		$('#strPass2').next().hide();
		$('#strPass2').show().val('').focus().blur(function() {
			if ($(this).val().length == 0) {
				$('#strPass2').next().css('display','block');
				$('#strPass2').next().val('Confirm Password');
				$('#strPass2').hide();
			}
		});
	});
	
	$('input').click(function() {
		var page = (getUrlVars()['page'] !== undefined) ? getUrlVars()['page'].split('.') : '';
		var action = '';
		
		if (page.length > 1) action = page[1];
		if (action !== 'submit') {
			this.value = '';
		}
	});
	
	$('input').blur(function() {
		if ($(this).val().length == 0) {
			$(this).val(objOrigFormVals[$(this).attr('name')]);
		}
	});
	
	$('div#box_register.fadedOut').fadeTo(10,0.40);
	$('div#box_sign_in.fadedOut').fadeTo(10,0.40);
});

