
function retrieveURL(url,pars) {
	//alert(url);
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
		req.onreadystatechange = processStateChange;
		try {
			req.open("POST", url);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		} catch (e) {
			alert(e);
		}
		req.send(pars);
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processStateChange;
			req.open("POST", url);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send(pars);
		}
	}
}

function processStateChange() {
	if (req.readyState == 4) { // Complete
		if (req.status == 200) { // OK response
			document.getElementById(Obj).innerHTML = req.responseText;
			tfm_progressBarEnd(tfm_ProgressBar);
			tfm_progressBarEnd(tfm_ProgressBar1);
		} else {
			alert("Problem: " + req.statusText);
		}
	}
}

//==========================================//
function TFMProgressBar() { //v1.0.0
	this.create = function(container,id,len,width,height,speed,color,border,elementborder,traillength,multiplier) {
		this.container = container;
		this.id = id;
		this.len = (len && len != "") ? len : 10;
		this.width = (width && width != "") ? width : 15;
		this.height =(height && height != "") ? height : 16;
		this.speed = (speed && speed != "") ? speed : 100;
		this.color=(color && color != "") ? color : "#00dd66";
		this.border=(border && border != "") ? border : "0";
		this.elementborder = (elementborder && elementborder != "") ? elementborder : "0";
		this.traillength = (traillength && traillength != "") ? traillength : 6;
		this.multiplier = (multiplier && multiplier != "") ? multiplier : 1.05;
		this.counter = 0;
		this.red = parseInt(this.color.substr(1,2),16)/2.56;
		this.green = parseInt(this.color.substr(3,2),16)/2.56;
		this.blue = parseInt(this.color.substr(5,2),16)/2.56;			
	}
	
	this.init = function() {
		this.list = document.createElement("span");
		this.list.setAttribute("id", this.id);	
		this.list.speed = this.speed;
		this.list.style.border = this.border;
		this.list.style.margin = "0";
		this.list.style.padding = "0";
		this.list.style.fontSize= this.height + "px";
		for(var i=0;i<this.len;i++)	{
			var baritem = document.createElement("span");
			baritem.style.backgroundColor='transparent';
			baritem.style.padding = "0 " + Math.abs(this.width/2) + "px";
			baritem.style.margin = "0";
			baritem.style.fontSize= this.height + "px";
			baritem.style.textDecoration = 'none';
			baritem.style.borderLeft = this.elementborder;
			baritem.innerHTML = '&nbsp;';
			this.list.appendChild(baritem);
		}
		return this;
	}
	
	this.start = function(){
		this.end();
		this.init();
		if(window.focus)window.focus();
		this.div = document.getElementById(this.container);
		this.div.style.fontSize = this.height;
		this.div.appendChild(this.list);
		if(this.interval)clearInterval(this.interval);
		var theObj = this;	
		theObj.counter = 0;
		theObj.elements = theObj.list.getElementsByTagName('span');
		theObj.elementsLength = theObj.elements.length;
		var TFMProgressBar_Run = function() {
			if (theObj.counter++ >= theObj.elementsLength) theObj.counter = 0;
			var startPos = (theObj.counter-theObj.traillength > 0) ? theObj.counter-theObj.traillength : 0;
			for(var i=0; i<=startPos; i++) {
				theObj.elements[i].style.backgroundColor = '#fff';
			}
			var red = theObj.red;
			var green = theObj.green;
			var blue = theObj.blue;
			for(i=theObj.counter-1;i>=startPos;i--){
				theObj.elements[i].style.backgroundColor = "rgb(" + red + "%," + green + "%," + blue + "%)";
				red = red * theObj.multiplier;
				green = green * theObj.multiplier;
				blue = blue * theObj.multiplier;
			}
			for(i=theObj.counter; i<theObj.elementsLength; i++) {
				theObj.elements[i].style.backgroundColor = '#fff';
			}
		}
		this.interval = setInterval(TFMProgressBar_Run, this.speed);
	}
	
	this.end = function() {
		if(this.div && document.getElementById(this.id)) {		
			this.div.removeChild(this.list);
		}
		if(this.interval)clearInterval(this.interval);	
	}
}

function initProgressBar(url,pars,DivMain,BarLength) { //v1.0.0
	//============ Begin Configution Progress Bar ==============/
	container 	    = "blah";
	id		  	    = "tfm_ProgressBar";
	theBar        	= tfm_ProgressBar;
	//-------------------/
	container1 	    = "blah1";
	theBar1        	= tfm_ProgressBar1;	
	id1		  	    = "tfm_ProgressBar1";	
	//-------------------/
	len		  		= BarLength;
	width	  		= 3;	
	height    		= 5;
	speed     		= 100;
	color     		= "#214DF8";
	border    		= "1px solid #ffffff";
	elementborder   = "1px solid #cccccc";
	traillength   	= 10;
	multiplier    	= 1.2;

	//============ End Configution Progress Bar ==============/
	
	theBar1.create(container1,id1,len,width,height,speed,color,border,elementborder,traillength,multiplier);
	theBar1.start();
	
	theBar.create(container,id,len,width,height,speed,color,border,elementborder,traillength,multiplier);
	theBar.start();
	StatusClick(url,pars,DivMain);	
}

function tfm_progressBarEnd(bar) { //v1.0.0
	bar.end();
}

