function createAJAX(){
	var xmlhttp;
	try{
		xmlhttp = new XMLHttpRequest(); 	//For Firefox, Opera, Chrome, Safari and IE7+
	}catch(e){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 	//For IE
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");		//For IE5, IE6	
			}catch(e){
				return false;
			}
		}
	}
	return xmlhttp;
}




function wczytajZamiennikiPrzedmiotu(idPrzedmiotu, divId)
{
	var div = document.getElementById(divId).parentNode;
	var contentsDiv = document.getElementById(divId);
	//wczytajZamiennikiPrzedmiotuUrl = '/plan.php?zamienniki=1&jezyk=pl';
	var hostUrl = location.protocol + '//' + location.host;
	
	
	if (div.style.display != 'none')
		div.style.display = 'none';
	else if (contentsDiv.innerHTML == ''){
		var xmlhttp = createAJAX();
		if(xmlhttp == false){
			alert('Twoja przeglądarka nie obsługuje AJAX');
			return false;
		}
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
				var msg = xmlhttp.responseText;
				
				contentsDiv.innerHTML = msg;
				div.style.display = '';
			}
		};
		var uri = hostUrl+'/skrypty/includes/plany_studiow/planyAjax.php?idPrzedmiotu='+idPrzedmiotu+'&zamienniki=1';
		//alert(encodeURI(uri));
		xmlhttp.open("GET", encodeURI(uri) , true);
		xmlhttp.send();
		
		/*
			advAJAX.get({
				url : wczytajZamiennikiPrzedmiotuUrl,
				parameters : {
					idPrzedmiotu : idPrzedmiotu
				},
				onSuccess : function(obj)
				{
					contentsDiv.innerHTML = obj.responseText;
					div.style.display = '';
				}
			});
		*/	
		
	}else{
		div.style.display = '';
	}
}
