
/*$(document).ready(function()
{
	$('.main_container').jScrollPane({showArrows:true});
});*/

function el(element)
{
	return document.getElementById(element);
}

function search()
{
	//document.location.href = 'http://www.google.de/search?q=site%3Acw2.de+' + el('searchbox').value;
	document.location.href = 'http://www.cw2.de/de/search/?q=' + el('searchbox').value;
}

var  checkSearch = false;
function clearSearch()
{
	if(!checkSearch)
	{
		checkSearch = true;
		el('searchbox').value = '';
	}
}

function blurSearch()
{
	if(el('searchbox').value == '')
	{
		checkSearch = false;
		el('searchbox').value = 'Suche';
	}
}

function checkEntry(e)
{
	var characterCode = (window.event) ? event.keyCode : e.keyCode;
	if (characterCode == 13) search();		// ENTER
}

function resizeBackground()
{
	if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.appVersion.substring(0, 1) == "4")
	{
		var imgWidth = 1280, imgHeight = 919; /*853;*/
		
		var winWidth = document.documentElement.offsetWidth;
		if(winWidth < 920) winWidth = 920;
			
		var winHeight = document.documentElement.offsetHeight;
		if(winHeight < 620) winHeight = 620;

		var ratio = imgWidth / imgHeight;
		var isWide = (ratio > (winWidth/winHeight));
		
		var backWidth = 0, backHeight = 0, backLeft = 0, backTop = 0;
		
		if(isWide)
		{
			backWidth = Math.round(winHeight * ratio);
			backHeight = winHeight;
			backLeft = ((backWidth - winWidth) / 2);
		}
		else
		{
			backWidth = winWidth;
			backHeight = Math.round(winWidth / ratio);
			backTop = ((backHeight - winHeight) / 2);
		}
		
		el('cwAutoControl[backImage]').style.width = backWidth + "px";
		el('cwAutoControl[backImage]').style.height = backHeight + "px";
		el('cwAutoControl[backImage]').style.marginLeft = "-" + backLeft + "px";
		el('cwAutoControl[backImage]').style.marginTop = "-" + backTop + "px";	
		el('cwAutoControl[backImage]').style.display = 'block';
		
		// content
		el('main_content').style.height = (winHeight - 142) + "px";			// 160 px
		el('content_center').style.height = (winHeight - 172) + "px";		// 190 px
		el('container').style.height = (winHeight - 199) + "px";			// 215 px
	}
	
	//$('.container').jScrollPane({showArrows:true});
}
window.onresize = resizeBackground;
