// JavaScript Document
var B_Type = new crossBrowserType();
function crossBrowserType()
{
	this.IE = false;
	this.NS4 = false;
	this.NS6 = false;
	this.id = "";

	if (document.all)
	{
		this.IE = true;
		this.id = "IE";
	}
	else if(document.getElementById)
	{
		this.NS6 = true;
		this.id = "NS6";
	}
	else if(document.layers)
	{
		this.NS4 = true;
		this.id = "NS4";
	}
}

// Mausposition zurückgeben
var crossMouseX, crossMouseY;
if (B_Type.NS4) document.captureEvents(Event.MOUSEMOVE);

function crossMousePosition(e)
{
	if (B_Type.IE)
	{
		crossMouseX = event.x + document.body.scrollLeft; 
		crossMouseY = event.y + document.body.scrollTop;
	}
	else
	{
		crossMouseX = e.pageX;
		crossMouseY = e.pageY;
	}
}

// Objekt positionieren x/y
function crossMoveTo(obj, x, y)
{
	if (B_Type.IE)
	{
		obj.style.marginLeft = x + "px";
		obj.style.marginTop = y + "px";
	}
	else if(B_Type.NS4)
	{
		obj.left = x;
		obj.top = y;
	}
	else if(B_Type.NS6)
	{
		obj.style.left = x + "px";
		obj.style.top= y + "px";
	}
}


//tooltip
ttip = null;
document.onmousemove = cursorMove;

function showttip(id)
{
	ttip = document.getElementById('mapToolTip');
	ttip.style.display = "block";
}
function hidettip()
{
	ttip.style.display = "none";
}
function cursorMove(e)
{
	if(ttip != null)
	{
		crossMousePosition(e);
		crossMoveTo(ttip, crossMouseX+15, crossMouseY+10);
	}
}
//tooltip

function confirmAction(question, url)
{
	check = confirm(question);
	if(check == true)
	{
		document.location.href = url;	
	}
}
function number_format(number, decimals, dec_point, thousands_sep)
{
	var n = !isFinite(+number) ? 0 : +number, 
	prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
	sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
	dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
	s = '',
	toFixedFix = function (n, prec)
	{
		var k = Math.pow(10, prec);
		return '' + Math.round(n * k) / k;
	};
	// Fix for IE parseFloat(0.55).toFixed(0) = 0;
	s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
	if(s[0].length > 3)
	{
		s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
	}
	if((s[1] || '').length < prec)
	{
		s[1] = s[1] || '';
		s[1] += new Array(prec - s[1].length + 1).join('0');
	}
	return s.join(dec);
}
function calculateSum()
{
	var count = 0;
	var len = document.getElementById('adtext').value.length;
	if(document.getElementById('adtypeg').checked == true)
	{
		var adtype = "g";
	}
	else
	{
		var adtype = "p";
	}
	
	if(len <= 120)
	{
		adsum = parseInt(document.getElementById(adtype + "Price").value);
		
	}
	if(len <= 0)
	{
		adsum = 0;
	}
	if(len > 120)
	{
		sumAddMulti = parseInt(Math.ceil((len-120)/30));
		
		adPrice = parseInt(document.getElementById(adtype + "Price").value);
		adPriceAdditional = parseInt(document.getElementById(adtype + "PriceAdditional").value);
		
		adsum = adPrice+adPriceAdditional*sumAddMulti;
	}
	
	adsum = number_format(adsum/100, 2, ",", ".");
	
	document.getElementById('colCounter').innerHTML = "Sie haben " + len + " Zeichen verbraucht...<br />Die Anzeige kostet Sie " + adsum + "&euro;";
}
function checkContactSelect(selVal)
{
	if(selVal == "c")
	{
		top.location = "index.php?go=complaint";
	}
	else if(selVal == "d")
	{
		top.location = "index.php?go=jobs";
	}
	else
	{
		return 0;
	}
}

if (document.layers){ 
window.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP) 
window.onmousedown=rightclick; 
window.onmouseup=rightclick; 
function rightclick(e) { 
if (e.which == 3) { 
alert('Sorry, diese Aktion ist nicht gestattet !'); 
return false; 
} 
else { 
return true; 
} 
} 
} 
if (document.all){ 
function click() { 
if (event.button==2) {alert('Sorry, diese Aktion ist nicht gestattet !')} 
if (event.button==3) {alert('Sorry, diese Aktion ist nicht gestattet !')} 
if (event.button==4) {alert('Sorry, diese Aktion ist nicht gestattet !')}} 
document.onmousedown=click 
} 
