// show about and contact
function showTopTab(obj, txt)
{
	if (document.getElementById(txt).style.display != "block")
	{
		var tabs = obj.parentNode.getElementsByTagName("td");
		for (i=0; i < tabs.length; i++)
		{
			if (tabs[i] != obj)
			{
				if (tabs[i].onclick != null)
				{
					tabs[i].style.border = "none";
					tabs[i].style.backgroundColor = "transparent";
					tabs[i].innerHTML = tabs[i].innerHTML.replace("&nbsp;<B>", "").replace("</B>&nbsp;", "").replace("&nbsp;<b>", "").replace("</b>&nbsp;", "");
				}
				
				tabs[i].style.borderBottom = "solid 1px #666666";
			}
		}
		
		obj.style.border = "solid 1px #666666";
		obj.style.borderBottom = "none";
		obj.style.backgroundColor = "#ffffff";
		obj.innerHTML = "&nbsp;<b>" + obj.innerHTML + "</b>&nbsp;";
		
		changeVisibility("content", true);
		
		document.getElementById(txt).style.display = "block";
		if (txt == "about") 
		{
		    document.getElementById("contact").style.display = "none";
		    document.getElementById("partners").style.display = "none";
		}
		else if(txt == "contact")
		{
		    document.getElementById("about").style.display = "none";
		    document.getElementById("partners").style.display = "none";		
		}
		else if(txt == "partners")
		{
		    document.getElementById("about").style.display = "none";
		    document.getElementById("contact").style.display = "none";		
		}
		else document.getElementById("about").style.display = "none";
	}
	else closeTabs();
}

function changeVisibility(id, show)
{
	var obj = document.getElementById(id);
	
	if (show)
	{
		obj.style.visibility = "visible";
		obj.style.position = "relative";
	}
	else
	{
		obj.style.visibility = "hidden";
		obj.style.position = "absolute";
	}
}


function closeTabs()
{
	document.getElementById("contact").style.display = "none";
	document.getElementById("about").style.display = "none";
	document.getElementById("partners").style.display = "none";
	changeVisibility("content", false);
	
	var tabs = document.getElementById("content").parentNode.childNodes[0].getElementsByTagName("td");
	for (i=0; i < tabs.length; i++)
	{
		if (tabs[i].onclick != null)
		{
			tabs[i].style.border = "none";
			tabs[i].style.backgroundColor = "transparent";
			tabs[i].innerHTML = tabs[i].innerHTML.replace("&nbsp;<B>", "").replace("</B>&nbsp;", "").replace("&nbsp;<b>", "").replace("</b>&nbsp;", "");
		}
		else tabs[i].style.borderBottom = "none";
	}
}



// show or hide picture
function changePicVisibility(btn, replaceBtn, id)
{
	btn.style.display = "none";
	document.getElementById(replaceBtn).style.display = "block";
	
	if (document.getElementById(id).style.display == "none") document.getElementById(id).style.display = "block";
	else document.getElementById(id).style.display = "none";
}



// open features
function openFeatures(tab, id)
{
	var features = document.getElementById(id + "Features");
	var under_tabs_features = document.getElementById("under_tabs_features");
	var tabs = tab.parentNode.parentNode.getElementsByTagName("div");
	
	if (features.style.display == "none")
	{
		var tabLocation;
		
		//change look of tabs and spaces
		for (i=0; i < tabs.length; i++)
		{
			if (tabs[i] != tab)
			{
				tabs[i].style.position = "static";
				tabs[i].style.backgroundColor = "#f0f0f0";
				tabs[i].style.border = "solid 1px #666666";
				tabs[i].style.borderTop = "none";
				
				tabs[i].onmouseover = function()
				{
					this.style.cursor = "pointer";
					this.style.backgroundColor = "#dcdcdc";
				}
				tabs[i].onmouseout = function(){this.style.backgroundColor = "#f0f0f0"}
			}
			else tabLocation = i*2;
		}
		
		// change chosen tab look
		tab.style.position = "relative";
		tab.style.top = "6px";
		tab.style.backgroundColor = "#ffffff";
		tab.style.border = "solid 1px #666666";
		tab.style.borderBottom = "none";
		tab.onmouseover = function () {this.style.cursor = "pointer";}
		tab.onmouseout = null;
		
		// define the lines under the tab
		under_tabs_features.style.visibility = "visible";
		var under_tab = under_tabs_features.getElementsByTagName("td");
		for (i=0; i < under_tab.length; i++)
		{
			under_tab[i].style.border = "none";
			
			if(tabLocation == i)
			{
				if (i == 0) under_tab[i].style.borderLeft = "solid 1px #666666";
				else if (i == (under_tab.length-1)) under_tab[i].style.borderRight = "solid 1px #666666";
				else under_tab[i].style.border = "none";
			}
			else if (i == 0)
			{
				under_tab[i].style.borderLeft = "solid 1px #666666";
				under_tab[i].style.borderTop = "solid 1px #666666";
			}
			else if ((i+1) == under_tab.length)
			{
				under_tab[i].style.borderRight = "solid 1px #666666";
				under_tab[i].style.borderTop = "solid 1px #666666";
			}
			else under_tab[i].style.borderTop = "solid 1px #666666";
		}
		
		// hide all features and display the chosen one
		var allFeatures = features.parentNode.getElementsByTagName("div");
		for (i=0; i < allFeatures.length; i++)
		{
			if (allFeatures[i] != features) allFeatures[i].style.display = "none";
		}
		features.style.display = "block";
	}
	else
	{
		features.style.display = "none";
		
		// change other tabs look
		for (i=0; i < tabs.length; i++)
		{
			if (tabs[i] != tab)
			{
				tabs[i].style.backgroundColor = "#f0f0f0";
				tabs[i].style.border = "solid 1px #666666";
				tabs[i].style.borderTop = "none";
				
				tabs[i].onmouseover = function()
				{
					this.style.cursor = "pointer";
					this.style.backgroundColor = "#dcdcdc";
				}
				tabs[i].onmouseout = function(){this.style.backgroundColor = "#f0f0f0"}
			}
		}
		
		// change chosen tab look
		tab.style.position = "static";
		tab.style.backgroundColor = "#f0f0f0";
		tab.style.border = "solid 1px #666666";
		tab.style.borderTop = "none";
		
		tab.onmouseover = function()
		{
			this.style.cursor = "pointer";
			this.style.backgroundColor = "#dcdcdc";
		}
		tab.onmouseout = function(){this.style.backgroundColor = "#f0f0f0"}
		
		// hide lines under tab
		under_tabs_features.style.visibility = "hidden";
	}
}



// open short overview in technology and business solutions page
function openShortOverview(tab, id)
{
	var overview = document.getElementById(id + "Overview");
	var under_tabs_overviews = document.getElementById("under_tabs_overviews");
	var tabs = tab.parentNode.parentNode.getElementsByTagName("div");
	
	if (overview.style.display == "none")
	{
		var tabLocation;
		
		//change look of tabs and spaces
		for (i=0; i < tabs.length; i++)
		{
			if (tabs[i] != tab)
			{
				tabs[i].style.position = "static";
				tabs[i].style.backgroundColor = "#f0f0f0";
				tabs[i].style.border = "solid 1px #666666";
				tabs[i].style.borderTop = "none";
				
				tabs[i].onmouseover = function()
				{
					this.style.cursor = "pointer";
					this.style.backgroundColor = "#dcdcdc";
				}
				tabs[i].onmouseout = function(){this.style.backgroundColor = "#f0f0f0"}
			}
			else tabLocation = i*2;
		}
		
		// change chosen tab look
		tab.style.position = "relative";
		tab.style.top = "6px";
		tab.style.backgroundColor = "#ffffff";
		tab.style.border = "solid 1px #666666";
		tab.style.borderBottom = "none";
		tab.onmouseover = function () {this.style.cursor = "pointer";}
		tab.onmouseout = null;
		
		// define the lines under the tab
		under_tabs_overviews.style.visibility = "visible";
		var under_tab = under_tabs_overviews.getElementsByTagName("td");
		for (i=0; i < under_tab.length; i++)
		{
			under_tab[i].style.border = "none";
			
			if(tabLocation == i)
			{
				if (i == 0) under_tab[i].style.borderLeft = "solid 1px #666666";
				else if (i == (under_tab.length-1)) under_tab[i].style.borderRight = "solid 1px #666666";
				else under_tab[i].style.border = "none";
			}
			else if (i == 0)
			{
				under_tab[i].style.borderLeft = "solid 1px #666666";
				under_tab[i].style.borderTop = "solid 1px #666666";
			}
			else if ((i+1) == under_tab.length)
			{
				under_tab[i].style.borderRight = "solid 1px #666666";
				under_tab[i].style.borderTop = "solid 1px #666666";
			}
			else under_tab[i].style.borderTop = "solid 1px #666666";
		}
		
		// hide all overviews and display the chosen one
		var allOverview = overview.parentNode.getElementsByTagName("div");
		for (i=0; i < allOverview.length; i++)
		{
			if (allOverview[i] != overview) allOverview[i].style.display = "none";
			i++;
		}
		overview.style.display = "block";
		overview.parentNode.style.visibility = "visible";
	}
	else
	{
		overview.style.display = "none";
		overview.parentNode.style.visibility = "hidden";
		
		// change other tabs look
		for (i=0; i < tabs.length; i++)
		{
			if (tabs[i] != tab)
			{
				tabs[i].style.backgroundColor = "#f0f0f0";
				tabs[i].style.border = "solid 1px #666666";
				tabs[i].style.borderTop = "none";
				
				tabs[i].onmouseover = function()
				{
					this.style.cursor = "pointer";
					this.style.backgroundColor = "#dcdcdc";
				}
				tabs[i].onmouseout = function(){this.style.backgroundColor = "#f0f0f0"}
			}
		}
		
		// change chosen tab look
		tab.style.position = "static";
		tab.style.backgroundColor = "#f0f0f0";
		tab.style.border = "solid 1px #666666";
		tab.style.borderTop = "none";
		
		tab.onmouseover = function()
		{
			this.style.cursor = "pointer";
			this.style.backgroundColor = "#dcdcdc";
		}
		tab.onmouseout = function(){this.style.backgroundColor = "#f0f0f0"}
		
		// hide lines under tab
		under_tabs_overviews.style.visibility = "hidden";
	}
}



// open business short overview
function openBusinessOverview()
{
	var overview = document.getElementById("bsOverview");
	if (overview.style.display == "block")
	{
		overview.parentNode.style.backgroundColor = "transparent";
		overview.style.display = "none";
	}
	else
	{
		overview.parentNode.style.backgroundColor = "#ffffff";
		overview.style.display = "block";
	}
}


// change content tabs
function changeTab(tab, contentName)
{
	if (tab.className != null)
	{
		var tabLocation = 0;
		
		// change tab properties
		tab.onmouseout = null;
		tab.className = null;
		tab.onmouseover = function () {
			tab.style.cursor = "pointer";
		}
		
		// change other tabs properties
		var tabs = tab.parentNode.getElementsByTagName("td");
		for (i=0; i < tabs.length; i++)
		{
			if ((tabs[i] != tab) && (tabs[i].parentNode.parentNode.parentNode.id.length == 0))
			{
				tabs[i].className = "transparentTab";
				tabs[i].onmouseover = function () {
					this.style.cursor = "pointer";
					this.className = "transparentTabOver";
				}
				tabs[i].onmouseout = function () {
					this.className = "transparentTab";
				}
			}
			else if (tabs[i].parentNode.parentNode.parentNode.id.length == 0) tabLocation = i;
			i++;
		}
		
		// create lines under the tabs
		var under_tab = document.getElementById("under_tab").getElementsByTagName("td");
		for (i=0; i < under_tab.length; i++)
		{
			under_tab[i].style.border = "none";
			
			if(tabLocation == i)
			{
				if (i == 0) under_tab[i].style.borderLeft = "solid 1px #666666";
				else under_tab[i].style.border = "none";
			}
			else if (i == 0)
			{
				under_tab[i].style.borderLeft = "solid 1px #666666";
				under_tab[i].style.borderTop = "solid 1px #666666";
			}
			else if ((i+1) == under_tab.length)
			{
				under_tab[i].style.borderRight = "solid 1px #666666";
				under_tab[i].style.borderTop = "solid 1px #666666";
			}
			else under_tab[i].style.borderTop = "solid 1px #666666";
		}
		
		// show right txt and hide others
		var content = document.getElementById("tabContentTD").getElementsByTagName("div");
		for (i=0; i < content.length; i++)
		{
			if (content[i].id == (contentName + "_txt")) content[i].style.display = "block";
			else if (content[i].id.indexOf("_txt") > -1) content[i].style.display = "none";
		}
	}
}



// open the first panel and close the other
function openPanel()
{
	var panel = document.getElementById("register");
	
	if (panel.style.display == "none") panel.style.display = "block";
	else panel.style.display = "none";
}


// show one product in tab
function showOneSolution(arr)
{
	document.getElementById(arr[0]).style.display = "block";
	for (i=1; i<arr.length; i++)
	{
		document.getElementById(arr[i]).style.display = "none";
	}
}



// limit text for textareas
function countdown(e, text, limit)
{
	var key = window.event ? e.keyCode : e.which;
	
	// if erase
	if (key == 8) return true;
	else if (text.length >= limit) return false;
}


function countdownPresentation(textarea, limit, charactersLeft)
{
	if (textarea.value.length > limit) textarea.value = textarea.value.substring(0, limit);
	document.getElementById(charactersLeft).innerHTML = limit-textarea.value.length;
}