var arrayTab = new Array("letti","commentati");
var arrayFile = new Array("letti.html","commentati.html");
var baseUrlFile = "marieclaire/tab";

function showTab(idTab)
{
    for(var i=0;i<arrayTab.length;i++)
    {
        if(i==idTab)
            document.getElementById(arrayTab[i]).className="sel";
        else
            document.getElementById(arrayTab[i]).className="";
    }
    var content = makeRequest(baseUrlFile+"/"+arrayFile[idTab], false);
    document.getElementById("contenutiTab").innerHTML = content;
    
}

function makeRequest(url,async) 
{
    if(async != false)
        async = true;
	if (window.XMLHttpRequest) // Mozilla, Safari,...
	{ 
		http_request = new XMLHttpRequest();
		/*if (http_request.overrideMimeType) 
            http_request.overrideMimeType('text/xml');*/
	} 
	else if (window.ActiveXObject) // IE
	{ 
		http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if(async == true)
	   http_request.onreadystatechange = alertContents;
	http_request.open('GET', url, async);
	
	http_request.send(null);
	
	if(async == false)
	{
	    return http_request.responseText;
	}
}

function addEvent(object,event,functionName)
{
	if(object.addEventListener) 
		object.addEventListener(event, functionName, false);
	else if(object.attachEvent) 
		object.attachEvent('on'+event, functionName);
}

function initTab()
{
    showTab(0);
}

addEvent(window,'load',initTab);
