$(document).ready(function() {

			window.parent.$("#XML_BODY_FIELD_action").find("iframe").css("height" , $(".formQueue").height() + "px" );
			window.parent.$("#XML_BODY_FIELD_action").find(".iframe_loading").slideUp();

			var timeout;

			function ReadData() {

/*

$.ajaxSetup({
    timeout: 3000, 
    retryAfter:7000
});

function func(param){
    $.ajax('http://www.example.com/')
        .success(function(){
            console.log('Ajax request worked');
        })
        .error(function(){
            console.log('Ajax request failed...');
            setTimeout ('func("'+param+'")', $.ajaxSetup().retryAfter);
        });
}
*/

				url = $(".formQueue").attr("data-link");

				$.ajax({
				  dataType: "json",
				  url: url,
				  data: "",
				  success: function( data) {
					$.each( data, function( key, val ) {
							switch (key){
								case "progress":
									$("#progress").css("width" , val + "%");
									$("#progress").attr("aria-valuenow" , val);
									//$("#progress_nr").html(val + "%");

									if (val >= 100){

										$("#msg").fadeOut("slow" , function() {
											$("#succ").fadeIn();
										});

										//clearInterval(timeout);
									} else {
										setTimeout(ReadData , 1);
									}
								break;

								default:
									if ($("#" + key).length){
										$("#" + key).html(val);
									}
								break;
							
							}

						});					
				  }

				});
			}

			if ($("#progress").attr("aria-valuenow") == "100"){
				$( "#startbutton" ).hide();
			}
			
			$( "#startbutton" ).click(function() {

				$("#startbutton").fadeOut("slow" , function() {
					$("#msg").fadeIn("slow" , function() { 
						ReadData();
					});
				});

			});

		});