function printf() 
{ 
  var num = arguments.length; 
  var oStr = arguments[0];   
  for (var i = 1; i < num; i++) { 
    var pattern = "\\{" + (i-1) + "\\}"; 
    var re = new RegExp(pattern, "g"); 
    oStr = oStr.replace(re, arguments[i]); 
  } 
  return oStr; 
}

function goto($url)
{
	document.location.href = $url;
}

function set_progress_text(text, id, val)
{
    // set the progress bar value
    if(val == 0) $(id).show();
    var val2 = val.toFixed(0);
    $(id).children(".progress").progressbar('value', val2);

    // set the progress bar label
    //$("#t1").text($(id).html());
    if(val == 100){
	// only the label
	$(id).children(".progress_label").text(text);
    }else{
	// label and number with %
	$(id).children(".progress_label").text(text + " - " + val2 + "%");
    }
}

function get_progress_value(id)
{
    // set the progress bar value
    var pb = $(id).children(".progress");
    if(pb.length > 0) return pb.progressbar('value');
    return 0;
}

function setup_help()
{
    $('.helpsnippet').hide();
    $('.helpsnippet:first').show();
    $('.help_title').click(function(e){
	//$('.helpsnippet').slideUp('normal');
	$('.helpsnippet').hide();
	//$(e.currentTarget).next().slideDown('normal');
	$(e.currentTarget).next().show();
    });
    $("#helpExpansion").click(function(e){
	if(helpExpanded){
	    $("#helpExpansion").removeClass("ui-icon-carat-1-n");
	    $("#helpExpansion").addClass("ui-icon-carat-1-s");
	    //$('.helpsnippet').slideUp('normal');
	    $('.helpsnippet').hide();
	    helpExpanded = false;
	}else{
	    $("#helpExpansion").removeClass("ui-icon-carat-1-s");
	    $("#helpExpansion").addClass("ui-icon-carat-1-n");
	    //$('.helpsnippet').slideDown('normal');
	    $('.helpsnippet').show();
	    helpExpanded = true;
	}
    });

}

var requirerefresh = false;
function queuerefresh()
{
    requirerefresh = true;
}

function closeshadowbox()
{
    Shadowbox.close();
    if(requirerefresh) refresh();
}


