function createRequestObject() {
	var tmpXmlHttpObject;
				
//depending on what the browser supports, use the right way to create the XMLHttpRequest object
if (window.XMLHttpRequest) { 
// Mozilla, Safari would use this method ...
	tmpXmlHttpObject = new XMLHttpRequest();
			
	} else if (window.ActiveXObject) { 
	// IE would use this method ...
	     tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
	}
				
	return tmpXmlHttpObject;
}
			
//call the above function to create the XMLHttpRequest object
var http = createRequestObject();
			
function makeGetRequest(wordId,div) {
				
	function processResponse() {
	//check if the response has been received from the server
		if(http.readyState == 4){
						
		//read and assign the response from the server
			var response = http.responseText;
					
			//do additional parsing of the response, if needed
							
			//in this case simply assign the response to the contents of the <div> on the page. 
			document.getElementById(div).innerHTML = response;
							
			//If the server returned an error message like a 404 error, that message would be shown within the div tag!!. 
			//So it may be worth doing some basic error before setting the contents of the <div>
	    }
    }
			
			
		//make a connection to the server ... specifying that you intend to make a GET request 
		//to the server. Specifiy the page name and the URL parameters to send
		http.open('get', wordId);
						
		//assign a handler for the response
		http.onreadystatechange = processResponse;
				
		//actually send the request to the server
		http.send(null);
}




// JavaScript Document
var subon = 0;


function onMouseOver_f (id) {
	div = document.getElementById(id);
	div.className = id+'-on';
}

function onMouseOut_f (id) {
	div = document.getElementById(id);
	div.className = id;
}


function doc (a) {
	doc_a =	document.getElementById(a);
	doc_a.className = a;
	if (subon == 1) {
		document.getElementById('submenu_activ').style.display = 'none';
		subon = 0;
	}
	
	if (subon == 2) {
		document.getElementById('submenu_gal').style.display = 'none';
		subon = 0;
	}

	doc_a.onmouseout = function () { onMouseOut_f (a); }
}

var lastFocused;
function onClick_f (id) {
	
	div = document.getElementById(id);
	if (div == lastFocused) {
		return;
	}
	lastFocused = div;

	var bhome = 'home';
	var badmitere = 'admitere';
	var bactivitati = 'activitati';
	var bgalerie = 'galerie';
	var bprofesori = 'profesori';
	var bcontact = 'contact';
	
	
	switch (id) {
	
	case bhome :
		div.className = id+'-on';
		div.onmouseout = null;
		
		doc (badmitere);
		doc (bactivitati);
		doc (bgalerie);
		doc (bprofesori);
		doc (bcontact);
		break;
	
	
	case badmitere :
		div.className = id+'-on';
		div.onmouseout = null;
		doc (bhome);
		doc (bactivitati);
		doc (bgalerie);
		doc (bprofesori);
		doc (bcontact);
		break;
	
	
	case bactivitati :
		div.onmouseout = null;
		div.className = id+'-on';
		document.getElementById('submenu_activ').style.display = 'block';
		
		doc (bhome);
		doc (badmitere);
		doc (bgalerie);
		doc (bprofesori);
		doc (bcontact);
		
		subon = 1;
		break;
	
	
	case bgalerie :
		div.onmouseout = null;
		div.className = id+'-on';
		
		document.getElementById('submenu_gal').style.display = 'block';

		doc (bhome);
		doc (badmitere);
		doc (bactivitati);
		doc (bprofesori);
		doc (bcontact);
		subon =2;
		break;
		
	case bprofesori :
		div.className = id+'-on';
		div.onmouseout = null;
		
		doc (bhome);
		doc (badmitere);
		doc (bactivitati);
		doc (bgalerie);
		doc (bcontact);
		break;
	
	
	case bcontact:
		div.onmouseout = null;
		div.className = id+'-on';
		doc (bhome);
		doc (badmitere);
		doc (bactivitati);
		doc (bgalerie);
		doc (bprofesori);
		break;
	}
}

//    ---------------------- ------- -----    ------------   Fade in out cont cont text
var clika = 0;
var fade = 0;
var gal_f = 0;

function cont_in(cont) {
	Effect.Appear(cont, { duration: 0.5 });
	fade = 1;
}

function cont_out(cont) {
	Effect.Fade(cont, { duration: 0.5});
	fade = 0;
}

function buton_clik(page,cont) {
	if (gal_f == 1){
		gal_out('tot_galerie');
		buton_clik (page,cont);
	} else {
		cont_out(cont);
		setTimeout ('cont_in("'+cont+'")',1000);
		setTimeout ('makeGetRequest("'+page+'","text-cont-a")',500); 
	}
}

// galerie

function gal_pic_on (id) {
	div = document.getElementById(id);
	div.className = 'pic_gal-on';
}

function gal_pic_of (id) {
	div = document.getElementById(id);
	div.className = 'pic_gal';
}

function gal_click (pic) {
	div = document.getElementById('gal_pic_ch');
	div.src = pic;
	div.style.marginLeft = "auto";
	div.style.marginRight = "auto";
}

function gal_in(cont) {
	Effect.Appear(cont, { duration: 0.5 });
	gal_f = 1;
}

function gal_out(cont) {
	Effect.Fade(cont, { duration: 0.5});
	gal_f = 0;
}



function gal_fade (page,cont) {
	
	if (fade == 1){
		cont_out('text_cont');
		gal_fade (page,cont);
	} else {
		gal_out(cont);
		setTimeout ('gal_in("'+cont+'")',1000);
		setTimeout ('makeGetRequest("'+page+'","tot_galerie")',500);
	}
		
}

