var clickedLink = "";
var clickedLinkTimer;
var refreshing = false;

$(document).ready(function()
{
	$('#kontaktform input, #kontaktform textarea').not('.button').each(function()
	{
		if($(this).val() == "")
		{
			$('#kontaktform label[for=' + $(this).attr('id') + ']').css({'left': '55px', 'text-align': 'left'});
		}
	}).focusin(function()
	{
		$('#kontaktform label[for=' + $(this).attr('id') + ']').css({'text-align': 'right'}).animate({'left': '0px'});
	}).focusout(function()
	{
		if($(this).val() == "")
		{
			$('#kontaktform label[for=' + $(this).attr('id') + ']').css({'text-align': 'left'}).animate({'left': '55px'});
		}
	});
	
	$(".accordion").accordion(
	{
		collapsible: true
	});
	
	$.post("/stats/stats.php",
	{
		action: 'start',
		unihash: unihash,
		request: request,
		page: page,
		type: type,
		url: document.location.toString(),
		referrer: referrer
	});
	
	$('a').click(function()
	{
		if($(this).attr('href') != "")
		{
			$.post("/stats/stats.php",
			{
				action: 'link',
				ip: ip,
				unihash: unihash,
				url: url,
				page: page,
				deferrer: $(this).attr('href')
			});
			
			window.clearTimeout(clickedLinkTimer);
			clickedLink = $(this).attr('href');
			clickedLinkTimer = window.setTimeout('resetClickedLink()',10);
		}
	});
	
	$(window).bind('beforeunload', function()
	{
		if(!refreshing)
		{
			$.post("/stats/stats.php",
			{
				action: 'end',
				ip: ip,
				unihash: unihash,
				deferrer: clickedLink
			});
		}
	});
	
	$(document).keydown(function(event)
	{
		if(event.keyCode == 116)
		{
			refreshing = true;
			$.post("/stats/stats.php",
			{
				action: 'end',
				ip: ip,
				unihash: unihash,
				deferrer: request
			});
		}
	});
});

$(window).load(function()
{
	map();
})

var map;
var latlng = new google.maps.LatLng(51.38732, 7.67878);

function map()
{
	if(document.getElementById("map"))
	{
		map = new google.maps.Map(document.getElementById("map"), {
			zoom: 15,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		});
		
		setTimeout(function() 
		{
			
			var marker = new google.maps.Marker(
			{
				position: latlng,
				map: map,
				draggable: false,
				animation: google.maps.Animation.DROP
			});
		}, 1000);
	}
}

function resetClickedLink()
{
	clickedLink = "";
}
