$(document).ready(function()
{
	$("a[rel='tooltip_213']").colorbox({inline:true, href:"#tooltip", width:"100%", maxWidth:"922px", maxHeight:"100%", scrolling:false, onComplete:function() { afterComplete(); }});
	initQTip();
	
	//window.setTimeout( function() { openMap(); }, 500);
});

function initQTip()
{
	var pos = "absolute";
	if ($.browser.msie && $.browser.version.substring(0,1) == 7  && (typeof window.XMLHttpRequest == "object"))
	{
		pos = "relative";
	}
	
	$('.qtip').each(function()
	{
		$(this).qtip(
		{
			position:
			{
				type: pos,
				adjust: { screen: true },
				corner: { target: 'bottomRight', tooltip: 'leftTop'}
			},
			style:
			{
				width:
				{
					max: 500
				},
				classes:
				{
					tooltip: 'tooltip',
					wrapper: 'tooltip'
				}
			},
			content:
			{
				text: $("#"+$(this).attr('rel')).html()
			}
		});
	});
}

function openMap()
{
	$("a[rel='tooltip_213']").click();
}

function afterComplete()
{
	var img = new Image();
	img.src = $("img[usemap=#Dachbox]").attr("src");
	var iNaturalWidth = 0;
	iNaturalWidth = img.width;
	delete img;
	var iDividor = iNaturalWidth / $("img[usemap=#Dachbox]").width();
	
	$("area").each(function()
	{
		var nums = $(this).attr("coords").split(',');
		for (var i=0; i<nums.length; i++)
		{
			nums[i] = parseFloat(nums[i]) / iDividor;
		}
		$(this).attr("coords", nums.join(','));
	});
}

