// JavaScript Document
var dialogCreated = false;

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
$(function () {
$(".img1").each(function() {
        var button = $('#btnBrowse1');
        var userId = $("#user_id").val();

        $.ajax_upload(button,{
            action: 'ajaxProxy.php?mode=uploadBeautycheck&userId='+userId+'&img=1',
            name: 'myfile1',
            onSubmit : function(file, ext){
                this.disable();
				$("#btnBrowse1").html('<img src="images/web/flower-loader.gif" alt="Uploading...."/>');
            },
            onComplete: function(file, response){
              $("#btnBrowse1").html('');
			  $('#btnBrowse1').css("background-image", "url("+response+")");  
			  
                this.enable();
               // location.reload(true);
            }
        });
    });
$(".img2").each(function() {
        var button = $('#btnBrowse2');
        var userId = $("#user_id").val();

        $.ajax_upload(button,{
            action: 'ajaxProxy.php?mode=uploadBeautycheck&userId='+userId+'&img=2',
            name: 'myfile2',
            onSubmit : function(file, ext){
                this.disable();
            },
            onComplete: function(file, response){
			  $('#btnBrowse2').css("background-image", "url("+response+")");  
                this.enable();
                
            }
        });
    });
$(".img3").each(function() {
        var button = $('#'+this.id);
        var userId = $("#user_id").val();

        $.ajax_upload(button,{
            action: 'ajaxProxy.php?mode=uploadBeautycheck&userId='+userId+'&img=3',
            name: 'myfile3',
            onSubmit : function(file, ext){
                this.disable();
            },
            onComplete: function(file, response){
                alert(response);
                this.enable();
                location.reload(true);
            }
        });
    });
$(".img4").each(function() {
        var button = $('#'+this.id);
        var userId = $("#user_id").val();

        $.ajax_upload(button,{
            action: 'ajaxProxy.php?mode=uploadBeautycheck&userId='+userId+'&img=4',
            name: 'myfile4',
            onSubmit : function(file, ext){
                this.disable();
            },
            onComplete: function(file, response){
                alert(response);
                this.enable();
                location.reload(true);
            }
        });
    });
$(".img5").each(function() {
        var button = $('#'+this.id);
        var userId = $("#user_id").val();

        $.ajax_upload(button,{
            action: 'ajaxProxy.php?mode=uploadBeautycheck&userId='+userId+'&img=5',
            name: 'myfile4',
            onSubmit : function(file, ext){
                this.disable();
            },
            onComplete: function(file, response){
                alert(response);
                this.enable();
                location.reload(true);
            }
        });
    });
});
