count = 0;
http_request = new Array();
http_request_watch = new Array();
active_tab = new Array();
global_continue_link = "";

function setOpacity(obj,opacity){
	
	opacity=(opacity==100) ? 99.999 : opacity;
// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity){
	if(!document.getElementById) return;
		obj = document.getElementById(objId);
	if(opacity <= 100){
  		setOpacity(obj,opacity);
  		opacity += 10;
  		window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 1000);
  	}
}



function tab_makeRequest(link, tabId, continuelink) {
	
	
	var wrap = document.getElementById('wrap');
	var tab = document.getElementById('tab_'+tabId);
	var img = document.getElementById('loader');
	
	global_continue_link = continuelink;

	for (i=0; i<active_tab.length; i++) {
		var tab_2 = document.getElementById('tab_'+active_tab[i]);
		tab_2.className = 'normal';
	}
	active_tab.length++;
	active_tab[active_tab.length-1] = tabId;
	 	
	tab.className = 'selected';
				
	if (window.innerWidth) {
		H = window.innerHeight;
		W = window.innerWidth;
	} else if (document.all) {
		W = document.body.clientWidth;
		H = document.body.clientHeight;	
	}
	
	var top = Math.round((H-25)/2);
	var left = Math.round((W-76)/2);
		
	img.style.top = top + 'px';
	img.style.left = left + 'px';
	   
	img.style.visibility = 'visible';
	//setOpacity(wrap, 30); 
	// wrap.className = 'opacity30';
	
	                    
	http_request.length = count+1;
	http_request_watch.length = count+1;
	
	if (window.XMLHttpRequest) {
    	http_request[count] = new XMLHttpRequest();
    	http_request_watch[count] = true;
    	
      	if (http_request[count].overrideMimeType) {
        	http_request[count].overrideMimeType('text/xml');
      	}
   	} else if (window.ActiveXObject) {
      	try {
        	http_request[count] = new ActiveXObject("Msxml2.XMLHTTP");
        	http_request_watch[count] = true;
      	} catch (e) {
        	try {
            	http_request[count] = new ActiveXObject("Microsoft.XMLHTTP");
            	http_request_watch[count] = true;
         	} catch (e) {}
      	}
   	}
   	
   	if (link.indexOf('?') == -1) {
	    link = link+'?';
	}
   		
	http_request[count].onreadystatechange = tab_manageResult;
	http_request[count].open("GET", link+"&count="+count+"&"+Math.random(123), true);
	
	http_request[count].send(null);
	
	count++;
}


function tab_manageResult() {
	
	var wrap = document.getElementById('wrap');
	var tutti_false = true;
	
	for (i=0; i<http_request.length; i++) {
		
		if (http_request_watch[i] != false) {
			
			if (http_request[i].readyState == 4) {
				
				if (http_request[i].status == 200) {
					var text = http_request[i].responseText;
					var obj = document.getElementById('tab');
					var continue_obj = document.getElementById('tabfooter');
					
					obj.innerHTML = text;	
					obj.style.visibility = 'visible';
					
					
					if (global_continue_link != '') {
						
						continue_obj.innerHTML = '<a href="'+global_continue_link+'"> Continue ></a>'; 
													
					} else {
						continue_obj.innerHTML = ''; 	
					}
					
				}
				
				http_request_watch[i] = false;
			} else {
				tutti_false = false;
			}	
		}
	}
	 
	
	if (tutti_false == true) {
		var img = document.getElementById('loader');
		img.style.visibility = 'hidden';
		//fadeIn('wrap', 100);
	}
}