m = new Measure();
img_x = null;
img_y = null;
can_hover = 0;
can_click = 1;
is_active = 0;
im_down = 0;

function init_position() {
	img_x = m.X($('main_map'));
	img_y = m.Y($('main_map'));
	can_hover = 1;
}

function hover(id) {
	if(can_hover) {
		$(id).style.left = img_x + 'px';
		$(id).style.top  = img_y + 'px';
	}
}

function reset(id) {
	$(id).style.left = '-1000px';
	$(id).style.top  = '-1000px';
}

function showClient(param) {
	if(can_click) {
		can_click = 0;
		if(is_active) {
			$('holder').style.left = '-1000px';
			$('holder').style.top = '-1000px';
			$('ajaxContent').style.display = 'none';
			$('ajaxContent').innerHTML = '';
		};
		new Ajax.Request('/get_client.html',{
			method: 'post',
			parameters: 'reg='+param,
		  	onSuccess: function(display) {
							if(display.responseText.length) {
								$('holder').style.left = img_x + 350 + 'px';
								$('holder').style.top = img_y + 'px';
								$('ajaxContent').style.left = img_x + 350 + 'px';
								$('ajaxContent').style.top = img_y + 'px';
								$('ajaxContent').style.display = 'block';
								$('ajaxContent').update(display.responseText);
								$('ajaxContent').innerHTML;
								can_click = 1;
								is_active = 1;
							} else {
								can_click = 1;
							}
						}
		});
	}
}

function closeAjax() {
	$('holder').style.left = '-1000px';
	$('holder').style.top = '-1000px';
	$('ajaxContent').style.display = 'none';
	$('ajaxContent').innerHTML = '';
}


function showDet(param) {
	new Ajax.Request('/get_client.html',{
			method: 'post',
			parameters: 'id='+param,
		  	onSuccess: function(display) {
							if(display.responseText.length) {
								$('citat').update(display.responseText);
								$('citat').innerHTML;
							};
							if(im_down == 0) {
								window.location.href = "#descriere";
								im_down = 1;
							}
						}
		});
}

function  hideDescriere() {
	$('citat').innerHTML = '';
	im_down = 0;
}

function search_check() {
	value = document.getElementById('keyword').value;
	if(value.length > 2) {
		return true;
	};
	return false;
}

function showhide(id) {
	if($(id).style.display == 'none') {
		$(id).style.display = 'block';
	} else {
		$(id).style.display = 'none'
	}
}