$(document).ready(function(){
	var areaZ = 999;
	$('.formArea').each(function(){
		areaZ = areaZ - 1;
		this.style.zIndex = areaZ;
	});
	$('.formArea, .areaHeading').each(function(){
		this.style.zoom = '1';
	});
	$('.dropForm').click(function(){
		if (this.state != 1) {
			this.state = 1;
			$(this).parent().each(function(){
				this.style.position = "relative";
				dropFormList = '<li><a onmousedown="$(this).parent().parent().parent().children(\'input\').each(function(){this.value = \'lorna ipsum\'});" href="#">Lorem ipsum</a></li><li><a onmousedown="$(this).parent().parent().parent().children(\'input\').each(function(){this.value = \'Dolar consecutor\'});" href="#">Dolar consecutor</a></li><li><a onmousedown="$(this).parent().parent().parent().children(\'input\').each(function(){this.value = \'lorna ipsum\'});" href="#">Lorem ipsum</a></li>'
				$(this).append('<ul class="dropFormPull">' + dropFormList + '</ul>');
				$(this).children('ul').each(function(){this.style.zoom = '1'})
			});
		}
	});
	$('.dropForm').blur(function(){
		if (this.state == 1) {
			this.state = 0;
			$(this).parent().each(function(){
				this.style.position = "";
				$(this).children('.dropFormPull').remove();
			});
		}
	});
	
	$('.autoTest').blur(function(){
		$(this).parent().each(function(){
			if (this.state == 1) {
				$(this).children('.autoTestResult').remove();
			}
			else{
				this.state = 1;
				this.style.position = "relative";
			}
			if (Math.random() > 0.5) {
				$(this).append('<div class="autoTestResult ok">' + 'ok' + '</div>');
			}
			else {
				$(this).append('<div class="autoTestResult err">' + 'Sorry this name is unavaliable' + '</div>');
			}
			$(this).children('.autoTestResult').each(function(){this.style.zoom = '1'})
		});
	});

	$('#cvv').hide();
	var cvvShow = false;
	$(document).click(function(){
		if(cvvShow == true){
			$('#cvv').hide(100);
			cvvShow = false;
		}
	});
	$('.cvv').click(function(){
		$('#cvv').show(300);
		cvvShow = true;
		return false;
	});
	
	// Hide password reminder box if it is present
	if($("#reminderbox")) {
		$("#reminderbox").hide();
	}
	//passwordreminder
	if($("#passwordreminder")) {
		$("#passwordreminder").click(function(){
			$("#reminderbox").show();	
			
			// Set the email reminder box to take the value in the email box (save the user from typing it)
			$("#emailreminder").value = $("#email").value;
		});
	}
});