var changeTabHomePage = function(tabNum, languageId) {

	if(!languageId) languageId = "sk";

	var d = new Date;
	var unixtimeMs = d.getTime();
	var unixtime = parseInt(unixtimeMs / 1000);
	
	var active = $("#switch-" + tabNum + "-" + languageId);
	active.addClass("active");

	var notActive = $(".switch").not(active);
	notActive.removeClass("active");
	
	// if ($("img", active).length > 0) {
	// 	$("img", active).attr("src", $("img", active).attr("src").replace(/_off_/, "_on_"));
	// 	
	// 	$("img", notActive).each(function(){
	// 		$(this).attr("src", $(this).attr("src").replace(/_on_/, "_off_"));
	// 	});
	// }

	try {
		if (imagesPreloaded) {
			for (i=1;i<=4;i++) {
				if (i == tabNum)
					document.getElementById("switchimg-" + i + "-" + languageId).src = images[i].src;
				else
					document.getElementById("switchimg-" + i + "-" + languageId).src = images_off[i].src;			
			}
		}
	} catch(e) {}

	var activeContent = $("#hp-content-" + tabNum);
	activeContent.show();

	$("#hp-content > div").not(activeContent).hide();
	
	var activeBanner = $("#banner-hp-" + tabNum);
	$("##hp-topBanners > div").not(activeBanner).hide();		
	m = {1: 5900, 2: 5901, 3: 5902, 4: 5903};
	activeBanner.load("indexAjax.cfm?module=ActiveWeb&page=getRandomBanner&CategoryID=" + m[tabNum] + "&NewLanguageID=" + languageId + "Timestamp=" + unixtime).show();
	
}

$(document).ready(function(){
	$("#hp-menu a.switch").click(function() {
		changeTabHomePage($(this).attr("id").split("-")[1],$(this).attr("id").split("-")[2]);
	});
});