/** Nylon Coffee, Lowa */
document.write('<script type="text/javascript" src="/lowa/script/advajax.js"></script>');
document.write('<script type="text/javascript" src="/lowa/script/swfobject.js"></script>');
document.write('<script type="text/javascript" src="/lowa/script/overlaygallery.js"></script>');
document.write('<script type="text/javascript" src="/lowa/script/popup.js"></script>');
document.write('<script type="text/javascript" src="/lowa/script/Cookie.js"></script>');
document.write('<script type="text/javascript" src="/lowa/script/func_cookie.js"></script>');

function myLoad()
{
	/** Player */
	if(typeof(player_vars)!='undefined')
	{
		var player_params = {
		  allowFullScreen: true,
		  menu: false,
		  wmode: 'transparent'
		};
		var player_attributes = { align: 'center' }
		swfobject.embedSWF(SITE_URL+'lowa/flash/player.swf', 'player', 276, 156, '9.0.0', '', player_vars, player_params, player_attributes);
	}

	if(document.getElementById('flash_top'))
		OverlayGallery.aHide.push(document.getElementById('flash_top'));

	if(document.getElementById('player'))
		OverlayGallery.aHide.push(document.getElementById('player'));

	var a = document.getElementsByTagName('A');
	for(var i=0;i<a.length;i++)
	{
		if(a[i].rel.indexOf('external')>-1)
			a[i].target = '_blank';
		if(a[i].className.indexOf('popup')>-1)
		{
			a[i].onclick = OverlayGallery.click;
			OverlayGallery.aImage.push(a[i]);
		}
	}
	if(typeof(technologie)!='undefined' && technologie.length>0)
		searchTechnologie();

	if(Cookie.get('popup')==null)
	{
		popup.show();
		Cookie.set('popup','showPopup');
	}
}

var html_right;
function searchTechnologie()
{
	html_right = document.getElementById('right');
	var string = html_right.innerHTML.toLowerCase(),lower;
	for(var i=0;i<technologie.length;i++)
	{
		lower=technologie[i].name.toLowerCase();
		if(string.match(lower))
		{
			myReplace(html_right,technologie[i].name,technologie[i].id);
		}
	}
}

function myReplace(node,oldstring,id)
{
	var lower;
	for(var i=0;i<node.childNodes.length;i++)
	{
		if(node.childNodes.item(i).nodeName=='#text')
		{
			lower=node.childNodes.item(i).nodeValue.toLowerCase()
			if(lower.match(oldstring.toLowerCase()))
			{
				var temp = node.childNodes.item(i).nodeValue.split(oldstring);
				var technologytitle = document.createElement('SPAN');
				technologytitle.id='t_'+id;
				technologytitle.className='technologie_info';
				technologytitle.appendChild(document.createTextNode(oldstring));
				technologytitle.onmouseover=showTechnology;
				technologytitle.onmouseout=hideTechnology;
				var root = document.createElement('SPAN');

				if(temp[0].length>0)
					root.appendChild(document.createTextNode(temp[0]));
				root.appendChild(technologytitle);
				if(temp[1].length>0)
					root.appendChild(document.createTextNode(temp[1]));

				node.replaceChild(root,node.childNodes.item(i));
			}
		} else {
			myReplace(node.childNodes.item(i),oldstring,id);
		}
	}
}

function showTechnology()
{
	var box = document.getElementById('t'+this.id);
	var screenWidth = window.innerWidth ? window.innerWidth - 40: document.documentElement.clientWidth - 40;
	var screenHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;

	if(box!=null)
	{
		box.style.visibility='visible';

		this.style.position='absolute';
		box.style.top = (this.offsetTop-(box.offsetHeight/2))+'px';
		var left = (this.offsetLeft+this.offsetWidth+10);
		box.style.top = (this.offsetTop + this.offsetHeight)+'px';
		box.style.left = ((screenWidth-box.offsetWidth)/2)+'px';
		this.style.position='static';
	}
}

function hideTechnology()
{
	document.getElementById('t'+this.id).style.visibility='hidden';
}

function shoppopup(id)
{
	advAJAX.get({
		url: SITE_URL+"shopinfo"+LINK_SEP+id,
		onSuccess : function(obj) { showshoppopup(obj.responseText); }
	});
	return false;
}

function showshoppopup(res)
{
	if(res!='false')
	{
		OverlayGallery.callbackAfter = function()
		{
			document.getElementById('flash_top').style.visibility='visible';
			document.getElementById('flash_mapa').style.visibility='visible';
		}
		document.getElementById('flash_top').style.visibility='hidden';
		document.getElementById('flash_mapa').style.visibility='hidden';

		var aUrl = res.split(';');
		for(var i=0;i<aUrl.length;i++)
		{
			var a = document.createElement('A');
			a.href=aUrl[i];
			a.onclick = OverlayGallery.click;
			OverlayGallery.aImage.push(a);
			if(i==0)
				a.onclick();
		}
		//,
	}
	return false;
}

function testBrowser(k)
{
	switch(k)
	{
		case 'ie6':
			if(navigator.userAgent.indexOf('MSIE 6.0')>-1)
			return true;
		break;
	}
	return false;
}

