function fixMapTdHeight()
{
	var the_menu 	= getElement('the_menu_td');
	var the_map		= getElement('the_map_td');
	
	if(browser == "ie")
	{
		the_map.style.height = the_menu.offsetHeight-78;	
	}
	else
	{
		the_map.style.height = the_menu.offsetHeight-77;
	}
	
	
}

function editVetInfo(type, vet_id, obj, event)
{
	setMouseXY(event);
	
	/** Getting the data for the input box **/
	var type_data = getElement("vet_data_"+type+"_"+vet_id).innerHTML;
	createVeil();
	createOverlay_new('<div style="background-color:#FFFFFF;padding:5px;border:1px dotted black;text-align:center;"><textarea id="edit_vet_data_overlay_input" style="width:200px;height:200px;">'+type_data+'</textarea><br><a style="cursor:pointer;" onclick="saveEditVetInfo(\''+type+'\', '+vet_id+');" title="Gem"><img src="images/icons/save_icon.png" border="0"></a> <a style="cursor:pointer;" onclick="closeEditVetInfo();" title="Luk"><img src="images/icons/close_icon.png" border="0"></a></div>', 'fixed', mouseY, mouseX);
	getElement("edit_vet_data_overlay_input").focus();
}

function closeEditVetInfo()
{
	closeOverlay('overlay_div');
}

function saveEditVetInfo(type, vet_id)
{
	var new_data = getElement("edit_vet_data_overlay_input").value;
	ajaxRequest('GET', 'ajax/practice.php?action=editVetInfo&vet_id='+vet_id+'&type='+type+'&data='+urlencode(new_data), function(){handleSaveEditVetInfo(type, vet_id, new_data);});
}

function handleSaveEditVetInfo(type, vet_id, new_data)
{
	getElement("vet_data_"+type+"_"+vet_id).innerHTML = new_data;
	
	closeEditVetInfo();
}

function editPracticeInfo(type, practice_id, obj, event)
{
	setMouseXY(event);
	
	/** Getting the data for the input box **/
	var type_data = getElement("practice_data_"+type+"_"+practice_id).innerHTML;
	createVeil();
	createOverlay_new('<div style="background-color:#FFFFFF;padding:5px;border:1px dotted black;text-align:center;"><textarea id="edit_practice_data_overlay_input" style="width:200px;height:200px;">'+type_data+'</textarea><br><a style="cursor:pointer;" onclick="saveEditPracticeInfo(\''+type+'\', '+practice_id+');" title="Gem"><img src="images/icons/save_icon.png" border="0"></a> <a style="cursor:pointer;" onclick="closeEditPracticeInfo();" title="Luk"><img src="images/icons/close_icon.png" border="0"></a></div>', 'fixed', mouseY, mouseX);
	getElement("edit_practice_data_overlay_input").focus();
}

function closeEditPracticeInfo()
{
	closeOverlay('overlay_div');
}

function saveEditPracticeInfo(type, practice_id)
{
	var new_data = getElement("edit_practice_data_overlay_input").value;
	if(type == 'phone')
	{
		new_data = str_replace(' ', '', new_data);
	}
	
	ajaxRequest('GET', 'ajax/practice.php?action=editPracticeInfo&practice_id='+practice_id+'&type='+type+'&data='+urlencode(new_data), function(){handleSaveEditPracticeInfo(type, practice_id, new_data);});
}

function handleSaveEditPracticeInfo(type, practice_id, new_data)
{
	getElement("practice_data_"+type+"_"+practice_id).innerHTML = new_data;
	
	closeEditPracticeInfo();
}

function chooseVet()
{
	createVeil(50, true, "#000000", chooseVetAjax);
}

function chooseVetAjax()
{
	ajaxRequest('GET', '../_modules/_webcam/ajax.php?action=show_choose_vet', handleChooseVetAjax);
}

function handleChooseVetAjax()
{
	createOverlay(ajax_request_data);
}

function setWhoAmI(id)
{
	ajaxRequest('GET', '_modules/_webcam/ajax.php?action=set_who_am_i&who_am_i='+id, checkForInvites);
	closeOverlay(true);
}

function setOffline()
{
	ajaxRequest('GET', '_modules/_webcam/ajax.php?action=setoffline', checkForInvites);		
	if (typeof(getFunction) == 'function')
	{
		getFunction();
		if (invites)
		{
			unset(invites);
		}
	}
}

function popupQuestion(id)
{
	createVeil(50, true, "#000000", 
		function ()
		{
			popupQuestionAjax(id);
		}
	);
}

function popupQuestionAjax(id)
{
	ajaxRequest('GET', '_modules/_question/ajax.php?action=show_questionform&id='+id, handlePopupQuestionAjax);
}

function handlePopupQuestionAjax()
{
	createOverlay(ajax_request_data);
}

function submitQuestion()
{
	if (document.getElementById('navn').value == '' || document.getElementById('email').value == '' || document.getElementById('question').value == '') 
	{
		alert('Udfyld venglist alle felter.');
	}
	else
	{
		var vet_id = '';
		if (getElement('vet_id'))
		{
			var vet_id = getElement('vet_id').value;
		}
		
		var type = getElement('type').value;
		var type_id = getElement('type_id').value;
		var navn = getElement('navn').value;
		var email = getElement('email').value;
		var question = getElement('question').value;
		var responsible_id = getElement('responsible_id').value;
		var reply_directly = (getElement('check_me_to_reply_directly').checked ? 'true' : 'false');
		
		var question_string = str_replace('\n', ':newline:', question);
		
		ajaxRequest('GET', '_modules/_question/ajax.php?action=submit_question&vet_id='+vet_id+'&type='+type+'&type_id='+type_id+'&navn='+navn+'&email='+email+'&question='+question_string+'&responsible_id='+responsible_id+'&reply_directly='+reply_directly, submitQuestionDone);
	}
}

function submitQuestionDone()
{
	closeOverlay();
	fadeInFadeOutAndRemove('<div style="background-color:#FFFFFF;border:2px solid #000000;padding:5px;">Spørgsmål afsendt</div>', 
		undefined, 
		undefined, 
		undefined, 
		undefined, 
		undefined, 
		undefined, 
		function ()
		{
			location.reload(true);
		}
	);
}

function declineWebcamInvite(id)
{
	closeOverlay(true);
	ajaxRequest('GET', '_modules/_webcam/ajax.php?action=declineInvite&id='+id);
	checkForInvites();
	popped_up = false;
}

if (document.getElementsByClassName == undefined) 
{
	document.getElementsByClassName = function(className)
	{
		var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
		var allElements = document.getElementsByTagName("*");
		var results = [];

		var element;
		for (var i = 0; (element = allElements[i]) != null; i++) 
		{
			var elementClass = element.className;
			if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
				results.push(element);
		}

		return results;
	}
}

if (typeof console == "undefined") {
    this.console = {log: function() {}};
}
