var currentTab = 'tt-sel-1';

function swapBTN(id, im)
{
	element = document.getElementById(id);
	if (!element || !element.src) return;
	
	element.src = im;
}

var preloaded = new Array();

function preload_images() {
    for (var i = 0; i < arguments.length; i++){
        preloaded[i] = document.createElement('img');
        preloaded[i].setAttribute('src',arguments[i]);
    };
};


function swapTAB(element, newClass, master)
{
	if (element.id == currentTab && master == 0) return;
	
	if (!element || !element.className) return;
	
	newName = element.className;
	
	
	if (newClass == 'on')
	{
		if (element.className == tabLeftOff)
		{
			newName = tabLeftOn;
		}
		else if (element.className == tabOff)
		{
			newName = tabOn;
		}
	}
	else if (newClass == 'off')
	{
		if (element.className == tabLeftOn)
		{
			newName = tabLeftOff;
		}
		else if (element.className == tabOn)
		{
			newName = tabOff;
		}		
	}
	
	element.className = newName;
	if (element.id != currentTab && newClass == 'on') swapTAB2(currentTab, 'off');	
	if (element.id != currentTab && newClass == 'off') swapTAB2(currentTab, 'on');	
	
}




function swapTAB2(id, newClass)
{
	element = document.getElementById(id);
	swapTAB(element, newClass, 1);
}

function setCurrent(element)
{
	if (currentTab == element.id) return;
	
	addToURL = '';
	
	if (strefa_id && !isNaN(strefa_id))
	{
		addToURL = '&strefa_id=' + strefa_id;
	}
	
	currentTab = element.id;
	
	swapTAB(element, 'on', 1);
	
	textZone = document.getElementById('inner-info-2-content');
	
	if (currentTab == 'tt-sel-1')
	{
		myUrl = '/ajax/aktualnosci.php?headStyle=' + headStyle + addToURL;
		advAJAX.get({
	    url : myUrl,
	    onSuccess : function(obj) { 
	    	textZone.innerHTML = obj.responseText; 
	    },
	    onError : function(obj) 
	    { 
	    		alert("Error: " + obj.status); 
	    }
		});
	}
	else if (currentTab == 'tt-sel-2')
	{
		myUrl = '/ajax/promocje.php?headStyle=' + headStyle + addToURL;
		advAJAX.get({
	    url : myUrl,
	    onSuccess : function(obj) { 
	    	textZone.innerHTML =  obj.responseText; 
	    },
	    onError : function(obj) 
	    { 
	    		alert("Error: " + obj.status); 
	    }
		});
	}
	else if (currentTab == 'tt-sel-3')
	{
		myUrl = '/ajax/nowosci.php?headStyle=' + headStyle + addToURL;
		advAJAX.get({
	    url : myUrl,
	    onSuccess : function(obj) { 
	    	textZone.innerHTML = obj.responseText; 
	    },
	    onError : function(obj) 
	    { 
	    		alert("Error: " + obj.status); 
	    }
		});
	}
}


preload_images(
    'i/btn2-zabawki-on.gif',
    'i/btn2-opony-on.gif',
    'i/btn2-mp3-on.gif',
    'i/btn2-komputery-on.gif',
    'i/btn2-hotele-pl-on.gif',
    'i/btn2-hotele-sw-on.gif',
    'i/btn2-gry-on.gif',
    'i/btn2-finanse-on.gif',
    'i/btn2-dzwonki-on.gif',
    'i/btn2-armatura-on.gif',
    'i/btn2-agd-on.gif',
    'i/btn2-123market-on.gif'
);


