// JavaScript Document

function getX(obj,relative)
{
	var x = 0;
			
	if(typeof(obj)=="object" && document.getElementById)
	{
		x = obj.offsetLeft;
		if(obj.offsetParent && !relative)
		{
			x += getX(obj.offsetParent);
		}
		return x;
	}
	else
	{
		return false;
	}
}

function getY(obj,relative)
{
	var y = 0;
			
	if(typeof(obj)=="object" && document.getElementById)
	{
		y = obj.offsetTop;
		if(obj.offsetParent && !relative)
		{
			y += getY(obj.offsetParent);
		}
		return y;
		}
	else
	{
		return false;
	}
}

// Funktionen für Google Maps API
//-------------------------------

function loadMap() {
	if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("mapdiv"));
		map.setMapType(G_HYBRID_MAP);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		var point = new GLatLng(36.4878, -5.3602);//(36.4872, -5.3608);
		var marker = new GMarker(point);
		map.setCenter(new GLatLng(36.5878, -5.3602), 8);//(36.5872, -5.3608), 8);
		map.addOverlay(marker);
		var myHtml = "<span style='font-size: 14px; font-weight: bold;'>Sun-Gate-Ranch</span><br />CL Finca La Hoya 9<br />E-29480 Gaucin (Malaga)";
		GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(myHtml) });
		marker.openInfoWindowHtml(myHtml);
	}
}

// Funktionen zur dynamischen Anpassung des Textbereiches
//-------------------------------------------------------

function resizeInhalt()
{
	var x,y; // Fenstergröße des Browsers
	var yPos;  // y-Position des Imhalts
	var hoehe;
	var hoeheText;
	var logoTop;
	var logoTopText;

	// Begin - Fenstergröße des Browsers ermitteln
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	// End - Fenstergröße des Browsers ermitteln
	
	hoehe = y - 200;
	hoeheText = hoehe.toString() + "px";
	
	if (y < 700) {
		logoTop = y - 109;
		logoTop = (logoTop > 470 ? logoTop : 470);
		logoTopText = logoTop.toString() + "px";
	}
	else {
		logoTopText = "590px";
	}

	document.getElementById("navigation").style.height = hoeheText;
	document.getElementById("content").style.height = hoeheText;
	document.getElementById("logo_img").style.top = logoTopText;
	
	document.getElementById("navigation").style.display = "block";
	document.getElementById("content").style.display = "block";
	document.getElementById("logo_img").style.display = "block";
	document.getElementById("button_home").style.display = "block";
	document.getElementById("button_about").style.display = "block";
	document.getElementById("button_offers").style.display = "block";
	document.getElementById("button_location").style.display = "block";
	document.getElementById("button_contact").style.display = "block";
	document.getElementById("button_news").style.display = "block";
	
	if (document.getElementById("mapdiv")) {
		loadMap();
		document.getElementById("mapdiv").style.display = "block";
	}
}

function resizeInhaltLoad(evt)
{
	resizeInhalt();
}

function resizeInhaltResize()
{
	resizeInhalt();
}

// Überwachung starten
//--------------------
window.onload = resizeInhaltLoad;
window.onresize = resizeInhaltResize;

// Funktionen zur Steuerung der Untermenüs
//----------------------------------------
var timer;

function setTimer() {
	timer = setTimeout("hideMenue()", 5);
}

function clearTimer() {
	clearTimeout(timer);
}

function showMenue(submenue) {
	if (submenue == "about") {
		document.getElementById("sub_about").style.display = "block";
	}
	else if (submenue == "offers") {
		document.getElementById("sub_offers").style.display = "block";
	}
	else if (submenue == "contact") {
		document.getElementById("sub_contact").style.display = "block";
	}
}

function hideMenue () {
	document.getElementById("sub_about").style.display = "none";
	document.getElementById("sub_offers").style.display = "none";
	document.getElementById("sub_contact").style.display = "none";
}

// Überprüfung von Formulareingaben
//---------------------------------
function checkContactForm() {
	return true;
}
