$(document).ready(function() {	
	$('#gallery a').lightBox();
	$('#dialog-content').dialog({buttons: {}, width: 500, height:400, autoOpen: false, closeOnEscape: true});
	$('#accept_btn').click(function() { $('#dialog-content').dialog('close'); });
	$('#showTermsAndConditions').click(function() {$('#dialog-content').dialog('open')});
	
	$('#acceptTermsAndConditions').click(function(){
		disabled = $('#submit_btn').attr('disabled');
		$('#submit_btn').attr('disabled', !disabled);
	});
		
	$('#USERNAME, #USER_EMAIL').focus(function () {		
		if ($(this).attr("emptyText") == $(this).val()) $(this).val('');
	});
	
	$('#USERNAME, #USER_EMAIL').blur(function () {
		if ($(this).val() == '') $(this).val($(this).attr("emptyText"));
	});
	
	$('#PASSWORDTXT').focus(function () {		
		$(this).css('display', 'none');
		$('#PASSWORD').css('display', 'inline').focus();		
	});
	
	$('#PASSWORD').blur(function () {		
		if ($(this).val() == '') {			
			$(this).css('display', 'none');
			$('#PASSWORDTXT').css('display', 'inline');
		}
	});
	
	$('#submit_btn').click( function() { 
				
		$.ajax({
			async:true,
			type: "GET",
			dataType: "html",
			url: 'http://' + $("#registerform").attr("postUrl") + '/control/doRegisterExternalLocale',	       
			data: $("#registerform").serialize(),
			success: function (html) {	
				var code = processStandardResponse(html);
				if (code == "success") window.location.replace("/completed.php?registercode=xasYBpq3");
			},				
        	error: function () {
				
			}
		});
	});
	
});