$(document).ready(function()
{	
	/*
	$("body").attr("onload", function(e) 
	{
		h1 = $("#content").attr("offsetHeight");
		h2 = $("#menu").attr("offsetHeight");
		h3 = $("#right").attr("offsetHeight");
		h = Math.max(h1, h2);
		h = Math.max(h, h3);
		$("#page").css("height", (h + 100) + "px");
	});
	*/
	txtSearch = $("input#txtPhoneTableSearch");
	if(txtSearch != null)
	{
		txtSearch.bind("blur", function(e)
		{
			if(this.value == '')
				this.value = 'Søg';
		});
		txtSearch.bind("focus", function(e)
		{
			if(this.value == 'Søg')
				this.value = '';
		});
		txtSearch.bind("keyup", function(e) 
		{
			searchWord = this.value.toLowerCase();
			if(searchWord != 'søg')
			{
				$(".phoneName").each(function(i) {
					if(this.innerHTML.toLowerCase().indexOf(searchWord) >= 0)
						this.parentNode.parentNode.style.display = '';
					else			
						this.parentNode.parentNode.style.display = 'none';
				});
			}
		});
	}
});

var currentPhoneId = null;
var currentMousePos = null;
var currentPhonePopupTimer = null;

function ShowPhonePopup()
{
	if(currentPhoneId != null)
	{			
		id = currentPhoneId.substr(currentPhoneId.indexOf("_") + 1);
		popupDiv = $("#divPopup");
		popupDivContent = $("#divPopupContent");
		$("#divLoadInfo").css("display", "block");
		popupDivContent.css("display", "none");
		popupDiv.css("display", "block");
		popupDiv.css("top", currentMousePos.clientY);
		popupDiv.css("left", currentMousePos.clientX);
		
		popupDivContent.load("/phonepopup.php?phoneId=" + id, function(e)
		{				
			$("#divLoadInfo").css("display", "none");
			popupDivContent.css("display", "block");					
		});
	}
}

function EnablePhonePopup()
{	
	$("table.listview tr td").bind("mouseenter", function(e)
	{
		
		currentPhoneId = this.parentNode.id;
		currentMousePos = e;
		currentPhonePopupTimer = setTimeout("ShowPhonePopup()", 500);
		
	});
	
	$("table.listview tr td").bind("mouseleave", function(e)
	{
		if(currentPhonePopupTimer != null)
			clearTimeout(currentPhonePopupTimer);
		$("#divPopup").css("display", "none");
	});	
}
