// JavaScript Document

function ajaxFileUpload()
{
	jQuery('#popup_upload').ajaxStart(function(){
		jQuery(this).togglePopup();
		jQuery('#loading_inside_popup').togglePopup();
	})
	.ajaxComplete(function(){
	});

	jQuery.ajaxFileUpload
	(
		{
			url:'ajax/upload.php',
			secureuri:false,
			fileElementId:'image',
			dataType: 'json',
			success: function(data, status)
			{
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != '')
					{
						alert(data.error);
						jQuery('#loading_inside_popup').togglePopup();
						jQuery('#popup_upload').togglePopup();
					}
					else
					{
						jQuery('#loading_inside_popup').togglePopup();
						var pathParts = location.href.split('/');
						newLoc = '';
						for (j = 0; j < (pathParts.length-1); j++) {
							newLoc += pathParts[j]+'/';
						}
						location.href = newLoc + 'customize/uploaded';
					}
				}
			},
			error: function (data, status, e)
			{
				alert(e);
			}
		}
	)
	
	return false;

}