function ajaxFileUpload()
	{
		$("#loading")
		.ajaxStart(function(){
			$(this).show();
		})
		.ajaxComplete(function(){
			$(this).hide();
		});

		$.ajaxFileUpload
		(
			{
				url:'/common/doajaxfileupload.php',
				secureuri:false,
				fileElementId:'fileToUpload',
				dataType: 'json',
				success: function (data, status)
				{
					if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{
							alert(data.error);
						}else
						{
							
							document.getElementById('img_filename').value = data.msg;
							document.getElementById('encrypted_filename').value = data.encrypted_filename;
							if ( ! checkExt('img_filename')) {
								document.getElementById('img_filename').value = "";
							} else {
								document.getElementById('fileToUpload').disabled = true;
								document.getElementById('buttonUpload').disabled = true;
								document.getElementById('imgfront').src = "/uploads/" + data.encrypted_filename;
								document.getElementById('imgfront').width = 136;
								document.getElementById('imgfront').height = 136;
								document.getElementById('uploadnote').innerHTML = "<strong>Picture uploaded successfully!</strong>";
								//alert("/uploads/" + data.encrypted_filename);
							}
						}
					}
				},
				error: function (data, status, e)
				{
					alert(e);
				}
			}
		)
		
		return false;

	}
	
function checkExt(filenamex){
	var img_filename = document.getElementById(filenamex);
	var filename = img_filename.value;
	var filelength = parseInt(filename.length) - 3;
	var fileext = filename.substring(filelength,filelength + 3);
	
	// Check file extenstion
	if (fileext.toLowerCase() != "jpg"){
		alert ("You can only upload jpg images.");
		return false;
	}
	return true;
}

function removeImage(){
	document.getElementById('fileToUpload').disabled = true;
	document.getElementById('buttonUpload').disabled = true;
	//document.getElementById('buttonRemove').disabled = false;
	
	
}

