// ----------------------------------------------------------------------
// Globale Standardwerte setzen
//-----------------------------------------------------------------------
var browserID = "MZ";
if (navigator.userAgent.indexOf("MSIE") != -1)
	browserID = "IE";
var webKit = navigator.userAgent.toLowerCase().indexOf("webkit") != -1;

var IP = false;
if ((navigator.platform.toLowerCase().indexOf("ipod") != -1) || (navigator.platform.toLowerCase().indexOf("iphone") != -1) || (navigator.platform.toLowerCase().indexOf("ipad") != -1))
	IP = true;


var pageStatus = 0; // Overview	
var mediaZoom = 0;

var winWidth, winHeight;
var bgWidth, bgHeight;
var bgPath = "xvga";

if (screen.width > 1280) 
	bgPath = "uxga";
else if (screen.width > 1024)
	bgPath = "sxga";

// ----------------------------------------------------------------------
// Hintergrund an Fenstergröße anpassen
//-----------------------------------------------------------------------
function Get_ClientSize()
{
	var w, h;
	
	if (self.innerHeight)
	{
		w = self.innerWidth;
		h = self.innerHeight;
		if ((navigator.platform.toLowerCase().indexOf("ipod") != -1) || (navigator.platform.toLowerCase().indexOf("iphone") != -1))
			h += 128;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}

	winWidth = w;
	winHeight = h;

	if (w > h * 1.78)
		h = w * 0.5625;
	else if (h > w * 0.5625)
		w = h * 1.78;

	bgWidth = w;
	bgHeight = h;
}

function Adjust_Layer()
{
	Get_ClientSize();
	document.getElementById("background0").style.width = winWidth + "px";
	document.getElementById("background0").style.height = winHeight + "px";
	document.getElementById("bg0").style.width = bgWidth + "px";
	document.getElementById("bg0").style.height = bgHeight + "px";
	
	if (bgSlides)
	{
		document.getElementById("background1").style.width = winWidth + "px";
		document.getElementById("background1").style.height = winHeight + "px";
		document.getElementById("bg1").style.width = bgWidth + "px";
		document.getElementById("bg1").style.height = bgHeight + "px";
	}
	
	var w, h;
	
	if (mediaZoom)
	{
		document.getElementById("fullsize").style.width = winWidth + "px";	
		document.getElementById("fullsize").style.height = winHeight + "px";
		fullWidth = winWidth - 336;
		if (pageStatus == 3)  // Slideshow
		{
			w = sldSize[2];
			h = sldSize[3];
		}
		else if (pageStatus == 5)	// Video
		{
			var data = mediaVid.split("|");
	
			w = data[3];
			h = data[4];
		}
		
		if (w > fullWidth)
		{
			h = Math.floor(h * fullWidth / w);
			w = fullWidth;
		}
		document.getElementById("fullmedia").style.width = w + "px";		
		document.getElementById("fullmedia").style.height = h + "px";		
		document.getElementById("fullinfo").style.height = h + "px";		
	}
}

window.onresize = Adjust_Layer; 

function Do_Click(e) 
{
	return;
	
	if (!e)
		e = window.event;
	if ((e.type && e.type == "contextmenu") || (e.button && e.button == 2) || (e.which && e.which == 3)) 
	{
    	return false;
	}
}

function Do_Drag()
{
	return false;
}

if (top.location == this.location)
{		
	document.onmousedown = Do_Click;
	document.oncontextmenu = Do_Click;
	document.ondragstart = Do_Drag;
}

//----------------------------------------------------------------------
// iPhone / iPad
//----------------------------------------------------------------------
var startX, startY, moveX, moveY;
var touch = 0;

function Touch_Start(event)
{
	//event.preventDefault();
	if (event.touches.length > 1)
		return;
		
	startX = event.touches[0].pageX;
	startY = event.touches[0].pageY;
	touch = 1;
}

function Touch_Move(event)
{
	event.preventDefault();
	if (!touch)
		return;
	if (event.touches.length > 1)
		return;
	
	moveX = event.touches[0].pageX;
	moveY = event.touches[0].pageY;
	var y = document.getElementById("fulltext").scrollTop + (startY - moveY);
	if (y < 0)
		y = 0;
//	else if (y > document.getElementById("fulltext").scrollHeight)
//		y = document.getElementById("fulltext").scrollHeight;
	document.getElementById("fulltext").scrollTop = y;
	startY = moveY;
	startX = moveX;
}

function Touch_End(event)
{
	//event.preventDefault();
	touch = 0;
}

