function changePage(obj, container) {
	if(container == "content") $('#meniu > a').removeClass('selected');
	else $('#meniu_portofoliu > a').removeClass('selected');

	obj.className = 'selected';
	
	 $('#incarcare').css("display","inline");
	 $("#"+container).animate({
	   height: 'toggle', opacity: 'toggle'
	 }, "normal", function() {getPage(obj.id, container);});
	
}
//-------------------------------------------------------------
function getXHR() {
	var xmlhttp=null;
	if (window.XMLHttpRequest) {
  		xmlhttp=new XMLHttpRequest();
  	}
	else if (window.ActiveXObject) {
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	if (xmlhttp!=null)
  		return xmlhttp;
	else alert("Browserul dumnevoastra nu suporta tehnologia AJAX necesara rularii aplicatiei.");
}
//-------------------------------------------------------------
function getPage(url, container) {
	
	var req = getXHR();
	req.open("GET", url);
	req.onreadystatechange = function () {
		if (req.readyState==4 && req.status==200) {
			$('#'+container).html(req.responseText);
			$("#"+container).animate({
			   height: 'toggle', opacity: 'toggle'
			 }, "slow", function () {$('#incarcare').css("display","none");});
			
			if(url == "templates/servicii.php" || url == "english/servicii.php") {
				$(function() {
					$("#accordion").accordion({
							header: "h3"
						});
				});
			}//
			if(url == "templates/portofoliu.php" || url == "english/portofoliu.php") {
				$(function() {
					changePage(document.getElementById('get_port.php?cat=1'), 'portofoliu_cnt');
				});
			}//
		}
	}
	req.send(null);
}

