$(function(){ 
	var t;
	t=setTimeout("loadXMLDoc()",0);
	SetProgress();
	}) 

var currentName=new Array();
function OnHide(elem){
	var name = $(elem).attr('name')

	for (x in currentName)
	{
		if(currentName[x] == name) return ;
	}
	var divCtl = document.getElementById(name);
	divCtl.style.display="none";
	var data = {"name":name}
	$.post("/InstallApp/Cancel",data,function(){			
			})
		}
function ClearCompleteTask()
{
   $.post("/InstallApp/Clear",function(){			
			});
}
function OpenDownFolder()
{
   $.post("/InstallApp/Folder",function(){			
			});
}
function loadXMLDoc()
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	     {
		 var jsondata = $.parseJSON(xmlhttp.responseText);
		 if (jsondata == "Complete")
		 {
		 	clearTimer();
		 	currentName = new Array();
		 }
		 else
		 {
		 $.each(jsondata, function(i, field){
		 	currentName[i] = field.Name
			temp1 = $("div[name='"+field.Name+"']").find(".progress-label");
			temp1.html( field.Label );
			//$("#"+field.Name+" .progressNum").html(field.Label);
			//$("#"+field.Name+" .Progress").progressbar({ value: field.Number });
			//$("#"+field.Name+" .Progress").progressbar( "option", "value", field.Number );
		})


		 }
	     }
	  }
	xmlhttp.open("GET","InstallApp/json?now="+new Date().getTime(),true);
	xmlhttp.send();
	t=setTimeout("loadXMLDoc()",800);
}

function clearTimer()
{
	clearTimeout(t);
	}
function SetProgress()
{
	
	$.each(Init_data, function(i, field)
		{
			
			if (field.Finished)
			{
				
				//$("#"+field.Name+" .Progress").progressbar({ value: 0 });
				temp1 = $("div[name='"+field.Name+"']").find(".progress-label");
				//temp1= $("#"+field.Name).find(".progress-label");
				temp1.html( field.Label );
				temp2 = $("div[name='"+field.Name+"']").find(".Progress");
				
				temp2.progressbar( {value: 0 });
				
				//temp2 = $("div[name="+field.Name+"]").find(".Progress");
				//temp2 = $("#"+field.Name).find(".Progress");
				//temp2.progressbar({ value: 100 });
				//temp1.css('margin-left', '40%');
			}
			else
			{
				temp1 = $("div[name='"+field.Name+"']").find(".progress-label");
				//temp1= $("#"+field.Name).find(".progress-label");
				temp1.html( field.Label );
			}

		})
		
	
}