// JavaScript Document

var leuwico = new Leuwico();

function Leuwico()
{
	this.link_navi = function(p_element, p_url)
	{
		var ausfuehren = new Object();		
		ausfuehren.onAfterLoad = function(req)
		{
			var link_element = document.getElementById('navigation').firstChild;
			
			do
			{
				link_element.className = 'navi_link';
				link_element = link_element.nextSibling;
				
			} while (link_element);
			
			p_element.className = 'link_active';
			
			document.getElementById('content').outerHTML = document.getElementById('content').outerHTML;
		}
		ajax.send_load(p_url, 'content', ausfuehren);
	}
	
	this.special_link = function(p_typ)
	{
		document.getElementById('special_products').style.display = 'block';
		document.getElementById('special_products').innerHTML = '';
		
		switch(p_typ)
		{
			case 'moebel':
				var ausfuehren = new Object();		
				ausfuehren.onAfterLoad = function(req)
				{
					
				}
				ajax.send_load('products_moebel.php', 'special_products', ausfuehren);
			break;
			
			case 'stuehle':
				document.getElementById('special_products').style.display = 'none';
			break;
			
			case 'waende':
				var ausfuehren = new Object();		
				ausfuehren.onAfterLoad = function(req)
				{
					
				}
				ajax.send_load('products_waende.php', 'special_products', ausfuehren);
			break;
			
			case 'beleuchtung':
				var ausfuehren = new Object();		
				ausfuehren.onAfterLoad = function(req)
				{
					
				}
				ajax.send_load('products_beleuchtung.php', 'special_products', ausfuehren);
			break;
		}
	}
	
	this.mailversand = function()
	{
		var ausfuehren = new Object();		
		ausfuehren.onAfterLoad = function(req)
		{
			var rueckgabe = req.responseText.split('@@');
			
			if(rueckgabe[0] != '')
			{
				if(rueckgabe[0] == 'ok')
				{
					ajax.send_load('mail_true.php', 'content');
				}
				else
				{
					ajax.send_load('mail_false.php', 'content');
				}
			}
		}
		ajax.send_load(document.forms['kontakt_formular'], '','form', ausfuehren);
	}
	
	this.produkt_vorschau = function(img_src)
	{
		this.produkt_vorschau_layer = document.getElementById('produkt_vorschau');
		this.produkt_vorschau_layer.innerHTML = '<img src="img/' + img_src + '.jpg" border="0" title="vorschau" alt="vorschau" />';
	}
	
	this.produkt_vorschau_beenden = function()
	{
		if(document.getElementById('produkt_vorschau'))
		{
			document.getElementById('produkt_vorschau').innerHTML = '';
		}
	}
}

/* Google Map */

var gdir; 
function showPlanner() 
{ 
	
	if(typeof GMap2 != 'function')
	{
		setTimeout('showPlanner()',100);
		return;
	}
										
	if (GBrowserIsCompatible()) 
	{ 
		var map = new GMap2(document.getElementById("map")); 
		var geocoder = new GClientGeocoder();				

		address = 'Landwiedstrasse 23, 4020 Linz, Austria';
		if (geocoder) {
			geocoder.getLatLng(address, 
				function(point) {
					if (!point) 
					{
						alert(address + " konnte nicht gefunden werden.\nBitte geben Sie eine Adresse wie \"Neue Weinsteige 71\" ein");
					}
					else 
					{	
						
						map.addControl(new GLargeMapControl()); 
						var PosPoint = new GLatLng(point.lat(),point.lng()); 
						map.setCenter(PosPoint, 14); 
						var marker = new GMarker(PosPoint, {title: "LEUWICO Büroeinrichtungen Gmbh"}); 
						map.addOverlay(marker); 
						gdir = new GDirections(map, document.getElementById("directions")); 
					}
				}
			);
		}
	}
} 

function setDirections(fromAddress) 
{ 
	gdir.load("from: " + fromAddress + " to: Landwiedstrasse 23, 4020 Linz, Austria" , { "locale": "de" }); 
} 
