function GetOperatingSystem()
{
	queryString = window.location.search.substring(1);
	queryStringParameters = queryString.split("&");
	for (i=0; i<queryStringParameters.length; i++)
	{
		parameter = queryStringParameters[i].split("=");
		if (parameter[0] == "os")
			return parameter[1];
	}
	return GetOS();
}

function GetOS()
{
	if (navigator.platform.toLowerCase().indexOf("win") > -1)
		return "windows";
	else if (navigator.platform.toLowerCase().indexOf("mac") > -1)
		return "mac";
	else if (navigator.userAgent.toLowerCase().indexOf("ipod") > -1 || navigator.userAgent.toLowerCase().indexOf("iphone") > -1 || navigator.userAgent.toLowerCase().indexOf("ipad") > -1 || navigator.userAgent.toLowerCase().indexOf("android") > -1)
		return "mobile";
	else if (navigator.platform.toLowerCase().indexOf("linux") > -1)
		return "linux";
	else
		return "windows";
}

//Index Seiten
function SetDownloadUrls(macQS, macFull)
{	
	var parent=document.getElementById("nospace").parentNode;		
	
	try
	{
		var os = GetOS();
		if (os == "mac")
		{
			document.getElementById("dlQS").href = macQS;
			document.getElementById("dlFull").href = macFull;
			document.getElementById("dlQJ").href = "download/index.aspx?os=mac";
			document.getElementById("dlQJ").firstChild.innerHTML="TeamViewer 7 Mac Beta";
			parent.getElementsByTagName('table')[2].style.display="none";
			parent.getElementsByTagName('table')[3].style.display="none";			
		}
		else if (os == "linux")
		{
			document.getElementById("dlFull").href = "download/index.aspx?os=linux";
			parent.getElementsByTagName('table')[0].style.display="none";
			parent.getElementsByTagName('table')[1].style.display="none";
			document.getElementById("nospace").style.display="none";
		}
		else if(os == "mobile")
		{
			document.getElementById("dlQS").parentNode.parentNode.parentNode.parentNode.style.display = "none";
			document.getElementById("dlFull").href = "download/index.aspx?os=mobile";
			document.getElementById("dlQJ").parentNode.parentNode.parentNode.parentNode.style.display = "none";
			document.getElementById("nospace").style.display = "none";
		}
	}
	catch(e) {}
}


var pathToImages = "../../images/icons";

//Download Seiten
function SetDownloadArea(os)
{
	if (typeof ClickTaleExec == "function")
		ClickTaleExec("SetDownloadArea('" + os + "')");
	
	if (os == "windows")
	{
		area = document.getElementById("downloadAreaWindows");
		area.style.display = "";		
		ActivateHighslide(area);		
		icon = document.getElementById("downloadAreaWindowsIcon");
		icon.src = pathToImages + "/select-windows-active.gif";
		icon.name = "active";
		
		area = document.getElementById("downloadAreaMac");
		area.style.display = "none";
		DeactivateHighslide(area);
		icon = document.getElementById("downloadAreaMacIcon");
		icon.src = pathToImages + "/select-mac.gif";
		icon.name = "";
		
		area = document.getElementById("downloadAreaLinux");
		area.style.display = "none";
		DeactivateHighslide(area);
		icon = document.getElementById("downloadAreaLinuxIcon");
		icon.src = pathToImages + "/select-linux.gif";
		icon.name = "";
		
		document.getElementById("downloadAreaMobile").style.display = "none";
		icon = document.getElementById("downloadAreaMobileIcon");
		icon.src = pathToImages + "/select-mobile.gif";
		icon.name = "";
	}
	else if (os == "mac")
	{
		area = document.getElementById("downloadAreaWindows");
		area.style.display = "none";
		DeactivateHighslide(area);
		icon = document.getElementById("downloadAreaWindowsIcon");
		icon.src = pathToImages + "/select-windows.gif";
		icon.name = "";
		
		area = document.getElementById("downloadAreaMac");
		area.style.display = "";
		ActivateHighslide(area);
		icon = document.getElementById("downloadAreaMacIcon");
		icon.src = pathToImages + "/select-mac-active.gif";
		icon.name = "active";
		
		area = document.getElementById("downloadAreaLinux");
		area.style.display = "none";
		DeactivateHighslide(area);
		icon = document.getElementById("downloadAreaLinuxIcon");
		icon.src = pathToImages + "/select-linux.gif";
		icon.name = "";
		
		document.getElementById("downloadAreaMobile").style.display = "none";
		icon = document.getElementById("downloadAreaMobileIcon");
		icon.src = pathToImages + "/select-mobile.gif";
		icon.name = "";
	}
	else if (os == "linux")
	{
		area = document.getElementById("downloadAreaWindows");
		area.style.display = "none";
		DeactivateHighslide(area);
		icon = document.getElementById("downloadAreaWindowsIcon");
		icon.src = pathToImages + "/select-windows.gif";
		icon.name = "";
		
		area = document.getElementById("downloadAreaMac");
		area.style.display = "none";
		DeactivateHighslide(area);		
		icon = document.getElementById("downloadAreaMacIcon");
		icon.src = pathToImages + "/select-mac.gif";
		icon.name = "";
		
		area = document.getElementById("downloadAreaLinux");
		area.style.display = "";
		ActivateHighslide(area);		
		icon = document.getElementById("downloadAreaLinuxIcon");
		icon.src = pathToImages + "/select-linux-active.gif";
		icon.name = "active";
		
		document.getElementById("downloadAreaMobile").style.display = "none";
		icon = document.getElementById("downloadAreaMobileIcon");
		icon.src = pathToImages + "/select-mobile.gif";
		icon.name = "";
	}
	else if (os == "iphone" || os == "android" || os == "mobile" || os == "ipad" || os == "ipod")
	{
		document.getElementById("downloadAreaWindows").style.display = "none";
		icon = document.getElementById("downloadAreaWindowsIcon");
		icon.src = pathToImages + "/select-windows.gif";
		icon.name = "";
		
		document.getElementById("downloadAreaMac").style.display = "none";
		icon = document.getElementById("downloadAreaMacIcon");
		icon.src = pathToImages + "/select-mac.gif";
		icon.name = "";
		
		document.getElementById("downloadAreaLinux").style.display = "none";
		icon = document.getElementById("downloadAreaLinuxIcon");
		icon.src = pathToImages + "/select-linux.gif";
		icon.name = "";
		
		document.getElementById("downloadAreaMobile").style.display = "";
		icon = document.getElementById("downloadAreaMobileIcon");
		icon.src = pathToImages + "/select-mobile-active.gif";
		icon.name = "active";
	}
	else
	{
		area = document.getElementById("downloadAreaWindows");
		area.style.display = "";		
		ActivateHighslide(area);		
		icon = document.getElementById("downloadAreaWindowsIcon");
		icon.src = pathToImages + "/select-windows-active.gif";
		icon.name = "active";
		
		area = document.getElementById("downloadAreaMac");
		area.style.display = "none";
		DeactivateHighslide(area);
		icon = document.getElementById("downloadAreaMacIcon");
		icon.src = pathToImages + "/select-mac.gif";
		icon.name = "";
		
		area = document.getElementById("downloadAreaLinux");
		area.style.display = "none";
		DeactivateHighslide(area);
		icon = document.getElementById("downloadAreaLinuxIcon");
		icon.src = pathToImages + "/select-linux.gif";
		icon.name = "";
		
		document.getElementById("downloadAreaMobile").style.display = "none";
		icon = document.getElementById("downloadAreaMobileIcon");
		icon.src = pathToImages + "/select-mobile.gif";
		icon.name = "";
	}
}

function DeactivateHighslide(area)
{
	while (area.innerHTML.indexOf('onclick="return hs.expand(this)"') != -1)
		area.innerHTML = area.innerHTML.replace('onclick="return hs.expand(this)"', 'onclick=""');
}

function ActivateHighslide(area)
{
	while (area.innerHTML.indexOf('onclick=""') != -1)
		area.innerHTML = area.innerHTML.replace('onclick=""', 'onclick="return hs.expand(this)"');
}


//Download Seiten
function SetActive(element)
{
	if (element.name != "active")
		element.src = element.src.replace(".gif", "-active.gif");
}

//Download Seiten
function SetInactive(element)
{
	if (element.name != "active")
		element.src = element.src.replace("-active.gif", ".gif");
}

