var current_project = 0;

function ShowProject(strUrl, id) {
	current_project = id;
	
	var popup = document.getElementById('prj_ajax_' + id);
	if (!popup) {
		return;
	}
	if (popup.innerHTML.length) {
		//popup.style.display = 'inline';
		popup.style.display = 'block';
		return;
	}
	
	ajax_updater = new Ajax.Request(strUrl + '?by_ajax=1', {
		method: 'get',
		onSuccess: function(transport) {
			var response = transport.responseText || '';
			onGetProjectContent(response, id);
			}
		});
}

function onGetProjectContent(text, id) {
	var popup = document.getElementById('prj_ajax_' + id);
	if (!text.length || !popup) {
		return;
	}
	popup.innerHTML = text;
	if (current_project == id) {
		//popup.style.display = 'inline';
		popup.style.display = 'block';
	}
}

function HideProject(id) {
	var popup = document.getElementById('prj_ajax_' + id);
	if (popup) {
		popup.style.display = 'none';
	}
	current_project = 0;
}

function on_move(e, id) {
	
		if (!e){
			var e = window.event;
		}
		
		client_height = window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight);
		client_width = window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth);
	
		a = document.getElementById('prj_ajax_' + id);
		
		if (a.firstChild) {
			div_width = a.getElementsByTagName('div')[0].offsetWidth;
			div_height = a.getElementsByTagName('div')[0].offsetHeight;
			
			if ( ((client_width - e.clientX) < div_width) && ((client_height - e.clientY) > (div_height + 20)) ) {
			a.getElementsByTagName('div')[0].className = 'ajax_pop_up from_right from_top';
			}
			else if ( ((client_width - e.clientX) < div_width) && ((client_height - e.clientY) < (div_height + 20)) ) {
			a.getElementsByTagName('div')[0].className = 'ajax_pop_up from_right from_bottom';
			}
			else if ( ((client_width - e.clientX) > div_width) && ((client_height - e.clientY) < (div_height + 20)) ) {
			a.getElementsByTagName('div')[0].className = 'ajax_pop_up from_left from_bottom';
			}
			else if ( ((client_width - e.clientX) > div_width) && ((client_height - e.clientY) > (div_height + 20)) ) {
			a.getElementsByTagName('div')[0].className = 'ajax_pop_up from_left from_top';
			}
			
		}
			else return;
		
	}