
// Javascript functions for the <div> popup or an actual window.open popup for a lowerlevelbrowser.
function HidePopUp() 
{ 
	if(document.getElementById) 
		document.getElementById("popup").style.display = "none"; 
} 

function ShowPopUp()
{
	if(document.getElementById) 
		document.getElementById("popup").style.display = "block"; 
}

function OpenNewPopUpForLowLevelBrowser(entityId, entityLevel)
{
	window.open('../../general/tabs/PopUpTabGenerator.aspx?entityId=' + entityId + '&entityLevel=' + entityLevel, 
		entityId + '_' + entityLevel, 
		'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=455,height=358,left=700,top=500');
}


// More / Less details javascripting.
function SetDetails() 
{
	if(document.getElementById("textBlock") != null)
	{
		if(document.getElementById("textBlock").scrollHeight < document.getElementById("textBlock").clientHeight)
		{
			document.getElementById("moreDetails").style.display = 'none';
		}
	}
}	


function ShowDetails() 
{
	document.getElementById("textBlock").className = 'textBlockShowBig';
	document.getElementById("moreDetails").style.display = 'none';
	document.getElementById("lessDetails").style.display = 'block';
} 

function HideDetails() 
{
	document.getElementById("textBlock").className = 'textBlockShowSmall'
	document.getElementById("moreDetails").style.display = 'block';
	document.getElementById("lessDetails").style.display = 'none';
}

// More / Less details javascripting. //

function fndclass(node, className)
{
	var els = node.getElementsByTagName('*');
	for(var i=0; i<els.length; i++)
	{
		if(els[i].className.indexOf(className) > -1) return els[i];
	}
	return null;
}

/* Tab control helper functions */
// Shows the tab control by swapping the classes of the tab controller element and the body element
function ShowTabControl(tabController)
{	
	tabController.parentNode.className += ' on';
	// Hide all selection boxes so that they do not get in front of the tab control
	document.body.className += ' hideSelect';
}
								
// Restores the classes of the tab controller and the body
function HideTabControl(tabController)
{	
	tabController.parentNode.parentNode.parentNode.className = tabController.parentNode.parentNode.parentNode.className.replace(/\s+on/g, '');
	document.body.className = document.body.className.replace('hideSelect', '');	
}


/*
resolves the url with the base url to an absolute path
for ie it takes the base url and strips of the page.
then it adds the original url because ie ignores the basetag in javascript
(tested in IE en FF)
This is intended for javascript links 
*/
function resolveUrl(url)
{
  var path = '';
  
  if (url.indexOf('http://') == -1)
  {
    //ie other browsers dont have the document.all element
    if(document.all)
    {
      var elements;
      elements = document.getElementsByTagName('BASE');
      
      if (elements != null && elements.length > 0)
      {
        path = elements[0].href;
        path = path.substr(0,path.lastIndexOf('/')+1);
      }
    }
    path += url;
    return path;
  }
  else
  {
    return url;
  }
}


/*
Redirect to page 'url'
for ie it takes the base url and strips of the page.
then it adds the original url because ie ignores the basetag in javascript
(tested in IE en FF)
*/
function redirect(url)
{
  var path = '';
  
  if (url.indexOf('http://') == -1)
  {
    //ie other browsers dont have the document.all element
    if(document.all)
    {
      var elements;
      elements = document.getElementsByTagName('BASE');
      
      if (elements != null && elements.length > 0)
      {
        path = elements[0].href;
        path = path.substr(0,path.lastIndexOf('/')+1);
      }
    }
    path += url;
    window.location.href = path;
  }
  else
  {
    window.location.href = url;
  }
}


