function addEvent(element, eventType, theFunc, useCapture)
{
  if (element.addEventListener)
  {
    element.addEventListener(eventType, theFunc, useCapture);
    return true;
  } 
  else if (element.attachEvent)
  {
    var result = element.attachEvent("on" + eventType, theFunc);
    return result;
  } 
  else 
  {
    alert("Handler could not be attached");
  }
}

function ShowHideInfo(containerName)
{
	if (document.getElementById(containerName).style.display == "none")
	{	
		document.getElementById(containerName).style.display = "block";
		document.getElementById(containerName + "button").src = "images/hide_info_button.gif";		
	}
	else 
	{
		document.getElementById(containerName).style.display = "none";
		document.getElementById(containerName + "button").src = "images/more_info_button.gif";		
	}
}

function setupEventListeners()
{
	addEvent(document.getElementById("nav_services"), "mouseover", function(){document.getElementById('nav_services').src='images/navigation/services_nav_on.gif';}, false);
//	addEvent(document.getElementById("nav_testimonials"), "mouseover", function(){document.getElementById('nav_testimonials').src='images/navigation/testimonials_nav_on.gif';}, false);
	addEvent(document.getElementById("nav_kontact"), "mouseover", function(){document.getElementById('nav_kontact').src='images/navigation/kontact_nav_on.png';}, false);
	addEvent(document.getElementById("nav_contact"), "mouseover", function(){document.getElementById('nav_contact').src='images/navigation/contact_us_nav_on.gif';}, false);
	addEvent(document.getElementById("nav_support"), "mouseover", function(){document.getElementById('nav_support').src='images/navigation/support_nav_on.gif';}, false);

	addEvent(document.getElementById("nav_services"), "mouseout", function(){document.getElementById('nav_services').src='images/navigation/services_nav.gif';}, false);
//	addEvent(document.getElementById("nav_testimonials"), "mouseout", function(){document.getElementById('nav_testimonials').src='images/navigation/testimonials_nav.gif';}, false);
	addEvent(document.getElementById("nav_kontact"), "mouseout", function(){document.getElementById('nav_kontact').src='images/navigation/kontact_nav.png';}, false);
	addEvent(document.getElementById("nav_contact"), "mouseout", function(){document.getElementById('nav_contact').src='images/navigation/contact_us_nav.gif';}, false);
	addEvent(document.getElementById("nav_support"), "mouseout", function(){document.getElementById('nav_support').src='images/navigation/support_nav.gif';}, false);

//	window.onresize = handleResize;
}

function setupKontactEventListeners()
{
	addEvent(document.getElementById("nav_services"), "mouseover", function(){document.getElementById('nav_services').src='../images/navigation/services_nav_on.gif';}, false);
//	addEvent(document.getElementById("nav_testimonials"), "mouseover", function(){document.getElementById('nav_testimonials').src='../images/navigation/testimonials_nav_on.gif';}, false);
	addEvent(document.getElementById("nav_kontact"), "mouseover", function(){document.getElementById('nav_kontact').src='../images/navigation/kontact_nav_on.png';}, false);
	addEvent(document.getElementById("nav_contact"), "mouseover", function(){document.getElementById('nav_contact').src='../images/navigation/contact_us_nav_on.gif';}, false);
	addEvent(document.getElementById("nav_support"), "mouseover", function(){document.getElementById('nav_support').src='../images/navigation/support_nav_on.gif';}, false);

	addEvent(document.getElementById("nav_services"), "mouseout", function(){document.getElementById('nav_services').src='../images/navigation/services_nav.gif';}, false);
//	addEvent(document.getElementById("nav_testimonials"), "mouseout", function(){document.getElementById('nav_testimonials').src='../images/navigation/testimonials_nav.gif';}, false);
	addEvent(document.getElementById("nav_kontact"), "mouseout", function(){document.getElementById('nav_kontact').src='../images/navigation/kontact_nav.png';}, false);
	addEvent(document.getElementById("nav_contact"), "mouseout", function(){document.getElementById('nav_contact').src='../images/navigation/contact_us_nav.gif';}, false);
	addEvent(document.getElementById("nav_support"), "mouseout", function(){document.getElementById('nav_support').src='../images/navigation/support_nav.gif';}, false);

//	window.onresize = handleResize;
}

function handleResize()
{
	var currentHeight = getViewportHeight();
	var newHeightValue = currentHeight - 120;	
	if (newHeightValue < 550)
	{
		newHeightValue = 550;	
	}
	var contentPanelHeightValue = newHeightValue - 111;


	document.getElementById("black_left_panel").style.height = newHeightValue + "px";
	document.getElementById("left_panel").style.height = newHeightValue + "px";
	document.getElementById("left_panel_content").style.height = (newHeightValue - 20) + "px";		
	document.getElementById("content_panel").style.height = (contentPanelHeightValue - 36) + "px";
	document.getElementById("right_panel").style.height = newHeightValue + "px";
}

function getViewportHeight()
{
	var viewportwidth;
	var viewportheight;

	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

	if (typeof window.innerWidth != 'undefined')
	{
	  viewportwidth = window.innerWidth,
	  viewportheight = window.innerHeight
	}

	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	else if (typeof document.documentElement != 'undefined'
	 && typeof document.documentElement.clientWidth !=
	 'undefined' && document.documentElement.clientWidth != 0)
	{
	   viewportwidth = document.documentElement.clientWidth,
	   viewportheight = document.documentElement.clientHeight
	}

	// older versions of IE

	else
	{
	   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	
	return viewportheight;
}

function toggleElement(theElementID)
{
	theElement = document.getElementById(theElementID);

	if (theElement.style.visibility == "visible")
	{
		theElement.style.visibility = "hidden";
		theElement.style.display = "none";
	}
	else
	{
		theElement.style.visibility = "visible";
		theElement.style.display = "inline";
	}
}

function setupExternalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

