var currentURL = document.URL.split("?");
currentURL = currentURL[0];
currentURL = currentURL.split("#");
currentURL = currentURL[0];

function jsResizeWindow(w, h, leftMargin, rightMargin, topMargin, bottomMargin, center) {
	var maxW = screen.availWidth - window.screenLeft + 3;
	var maxH = screen.availHeight - window.screenTop + 22; // XP 29px, 2000 22px
	var newW = leftMargin + w + rightMargin + 10; // 3px window border, 2px body border, body, 2px body border, 3px window border
	var newH = topMargin + h + bottomMargin + 36; // 29px title(XP) + 2px body border + window + 2px body border + 3px window border

	if (newW > maxW) newH += 17; // scrollbar
	if (newH > maxH) newW += 17; // scrollbar
	
	if (newW > maxW && newW < screen.availWidth)
	{
		window.moveBy(maxW - newW, 0);
		jsResizeWindow(w, h, leftMargin, rightMargin, topMargin, bottomMargin, center);
		return;
	}
	
	if (newH > maxH && newH < screen.availHeight)
	{
		window.moveBy(0, maxH - newH);
		jsResizeWindow(w, h, leftMargin, rightMargin, topMargin, bottomMargin, center);
		return;
	}
	
	if (newW > maxW || newH > maxH)
	{
		document.body.scroll = "yes";
		if (newW > maxW) newW = maxW;
		if (newH > maxH) newH = maxH;
	}
	else
	{
		document.body.scroll = "no";
	}
	
	window.resizeTo(newW, newH);
	if (center) window.moveTo((screen.availWidth - newW) / 2, (screen.availHeight - newH) / 2);
	
	document.body.leftMargin = leftMargin;
	document.body.rightMargin = rightMargin;
	document.body.topMargin = topMargin;
	document.body.bottomMargin = bottomMargin;
}


function jsError(text)
{
	if (document.readyState != "complete")
	{
		document.NG_error = text;
		setTimeout("jsError(document.NG_error);", 500);
	}
	else alert(text);
}

function jsIsNumber(value)
{
	if (value == null) return false;
	value = value.toString().replace(",", ".");
	return value > -1000000000000 && value < 1000000000000;
}

// ------------------------------------------------------------------------------------------------------
// ------------------------------------------ MENU
// ------------------------------------------------------------------------------------------------------
function micl(id, obj)
{
	var container = document.getElementById(id), o;
	if (new Number(container.sID) != 0 && (o = document.getElementById(id + '_' + container.sID)) != null) o.className = 'trtc';

	while (obj.tagName != 'TABLE') obj = obj.parentNode;
	obj.rows.item(0).cells.item(1).className = 'trtc2';

	var s = obj.rows.item(0).cells.item(1).id.split('_');
	container.sID = s[s.length - 1];

	var table = obj.nextSibling;
	if (table == null || table.tagName != 'TABLE' || table.style.marginLeft != '13px')
	{
		try { obj.rows.item(0).cells.item(1).firstChild.click(); }
		catch (e) {}
		return false;
	}

	if (table.style.display == '')
	{
		table.style.display = 'none';
		obj.rows.item(0).cells.item(0).firstChild.src = imPlus.src;
	}
	else
	{
		table.style.display = '';
		obj.rows.item(0).cells.item(0).firstChild.src = imMinus.src;
	}

	return false;
}

function miov(obj)
{
	
}

function miou(obj)
{
	obj.style.backgroundColor = obj.baC_;
	obj.style.borderColor = obj.boC_;
}

function mido(obj)
{
	obj.baC1_ = obj.style.backgroundColor;
	obj.style.backgroundColor = '#999999';
}

function miup(obj)
{
	obj.style.backgroundColor = obj.baC1_;
}

// ------------------------------------------------------------------------------------------------------
// ------------------------------------------ IMAGES
// ------------------------------------------------------------------------------------------------------
function jsOpen(url)
{
	var obj = window.open(url, "", "width = 300, height = 50, resizable = yes, left = " + (window.top.screenLeft + 50) + ", top = 40");
	obj.focus();
}

function jsResizeWindow(w, h)
{
	if (opener == null) return;
	
	document.body.leftMargin = document.body.rightMargin = document.body.topMargin = document.body.bottomMargin = 8;
	
	var maxW = screen.availWidth - (window.screenLeft - 3);
	var maxH = screen.availHeight - (window.screenTop - 22);
	var newW = 26 + w;
	var newH = 45 + h;

	try { if (opener != null) newH += jsNumber(opener.top.document.xptheme) + jsNumber(opener.top.document.xpsp2); }
	catch (e) {}
	
	if (newW > maxW) newH += 17;
	if (newH > maxH) newW += 17;
	
	if (newW > maxW && newW < screen.availWidth)
	{
		window.moveBy(maxW - newW, 0);
		jsResizeWindow(w, h);
		return;
	}
	
	if (newH > maxH && newH < screen.availHeight)
	{
		window.moveBy(0, maxH - newH);
		jsResizeWindow(w, h);
		return;
	}
	
	if (newW > maxW || newH > maxH)
	{
		document.body.scroll = "yes";
		if (newW > maxW) newW = maxW;
		if (newH > maxH) newH = maxH;
	}
	else
	{
		document.body.scroll = "no";
	}
	
	try
	{
		window.resizeTo(newW, newH);
		
		var dif = document.body.scrollHeight - document.body.clientHeight, h2 = newH;
		if (dif == 7 || dif == 30)
		{
			newH += 7;
			
			try { if (opener != null) opener.top.document.xptheme = 7; }
			catch (e) {}
		}
		if (dif == 20 || dif == 30)
		{
			newH += dif == 20 ? 20 : 23;
			
			try { if (opener != null) opener.top.document.xpsp2 = dif == 20 ? 20 : 23; }
			catch (e) {}
		}
		if (h2 != newH) window.resizeTo(newW, newH);
	}
	catch (e) {}
}



// ------------------------------------------------------------------------------------------------------
// ------------------------------------------ URLs
// ------------------------------------------------------------------------------------------------------
function addURLCommand(url, cid, cv)
{
	var ch;
	if (url.indexOf("?") == -1) ch = "?"; else ch = "&";
	return url + ch + cid + "=" + cv;
}

function goToURL(url)
{
	location = addURLCommand(url, "sID", jsSID);
}

function compileLinks()
{
	var href = "";
	for (var i = 0; i < document.links.length; i++)
	{
		href = document.links[i].href;
		if (href.indexOf("javascript:") == -1 && href.indexOf(".zip") == -1 && href.indexOf("mailto:") == -1 && href.indexOf("#") == -1 && href.indexOf(jsDomainURL) != -1) document.links[i].href = addURLCommand(href, "sID", jsSID);
	}
}



// ------------------------------------------------------------------------------------------------------
// ------------------------------------------ DOWNLOAD MANUAL
// ------------------------------------------------------------------------------------------------------
function downloadManual(name)
{
	goToURL(jsDomainURL + "download_manual.asp?name=" + name);
}

// ------------------------------------------------------------------------------------------------------
// ------------------------------------------ WARENKORB
// ------------------------------------------------------------------------------------------------------
function warenKorb(id, preisID)
{
	goToURL(jsDomainURL + "aspx/Warenkorb.aspx?id=" + id + "&preisID=" + preisID + "&back=" + jsClientPage);
}
