window.onresize = resizeMe;
/*********************************
* Calls onresize function
**********************************/

function resizeMe()
{
	resizeOverlay();
	resizeWrapper();
}

/*********************************
* Returns value of querystring variable
**********************************/
function getQueryVariable(variable) 
{ 
  var query = window.location.search.substring(1); 
  var vars = query.split("&");
   
  for (var i=0;i<vars.length;i++) 
  { 
    var pair = vars[i].split("="); 
    if (pair[0] == variable) 
	{ 
      return pair[1]; 
    }
	else
	{
		return null;
	}
  } 
} 

/*********************************
* Returns height of window in pixels
**********************************/
function getWindowHeight()
{
	// calculate windowheight 
	var height = 0;
	
	if( typeof(window.innerHeight ) == 'number' )
	{
		//Non-IE
		height = window.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight )
	{
		//IE 6+ in 'standards compliant mode'
		height = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight )
	{
		//IE 4 compatible
		height = document.body.clientHeight;
	}
	return height;
}

/*********************************
* Returns width of window in pixels
**********************************/
function getWindowWidth()
{
	// calculate windowheight 
	var width = 0;
	
	if( typeof(window.innerWidth ) == 'number' )
	{
		//Non-IE
		width = window.innerWidth;
	}
	else if( document.documentElement && document.documentElement.clientWidth )
	{
		//IE 6+ in 'standards compliant mode'
		width = document.documentElement.clientWidth;
	}
	else if( document.body && document.body.clientWidth )
	{
		//IE 4 compatible
		width = document.body.clientWidth;
	}
	return width;
}

/*********************************
* Returns height of body in pixels
**********************************/

function getBodyHeight()
{
	return document.getElementsByTagName('body')[0].clientHeight;
}

/*********************************
* Returns width of body in pixels
**********************************/

function getBodyWidth()
{
	return document.getElementsByTagName('body')[0].clientWidth;
}

/*********************************
* lightbox map functions
**********************************/
function showMapById(id)
{
	url = id + '.html';
	activateLightbox(url);
	return false;
}
function showMap(anchor)
{
	url = anchor.href;
	activateLightbox(url);
	return false;
}
function closeMap()
{
	document.getElementById('iframe').src = '';
	document.documentElement.className='';
}

/* lightbox utility functions for internal use only */
function activateLightbox(url)
{
	document.documentElement.className='lightbox';
	document.getElementById('iframe').src = url;
	resizeOverlay();	
}
function resizeOverlay()
{
	var overlay 		 = document.getElementById('lb_overlay');
	var wrapper 		 = document.getElementById('wrapper');
	var html			 = document.documentElement;
	var body			 = document.getElementsByTagName('body')[0];
	var newleft 		 = -(getWindowWidth() - wrapper.clientWidth) / 2;
	if (newleft > 0)
	{
		newleft = 0;
	}
	overlay.style.left	 = newleft + 'px';
	overlay.style.height = getWindowHeight() + 'px';
	overlay.style.width  = getWindowWidth() + 'px';
	
	body.style.height	 = getWindowHeight() + 'px';
	html.style.height	 = getWindowHeight() + 'px';
}
function resizeWrapper()
{
	//alert(getWindowHeight());
	//alert(document.getElementById('wrapper').clientHeight);
	
	var wrapperdiv    		= document.getElementById('wrapper');
	wrapperdiv.style.height = 'auto';
	var wrapperheight 		= wrapperdiv.clientHeight;
	var windowheight  		= getWindowHeight();
		
	if(wrapperheight < windowheight)
	{
		wrapperdiv.style.height = (windowheight - 152) + 'px';
	}
	else
	{
		wrapperdiv.style.height = 'auto';
	}
}
/* tab selection on homepage */
function selectTab(tab)
{
    var tab_check     = document.getElementById('tab_check');
    var tab_login     = document.getElementById('tab_login');
    var content_check = document.getElementById('content_check');
    var content_login = document.getElementById('content_login');

	if(tab.id == 'tab_check')
	{
		tab_check.className = 'tab first active';
		tab_login.className = 'tab last';
		content_check.className = 'tabcontent active';
		content_login.className = 'tabcontent';		
	}
	if(tab.id == 'tab_login')
	{
		window.open('http://www.glashart.nl/extranet/documenten');
		/*
		tab_check.className = 'tab first';
		tab_login.className = 'tab last active';
		content_check.className = 'tabcontent';
		content_login.className = 'tabcontent active';		
		*/
	}
	resizeMe();
}
/* returns link mail this page */
function getMailThisPageLink()
{
	var url  = window.location;
	var link = '<a href="mailto:?subject=Reggefiber.nl. Een webpagina om eens te bekijken&body=Deze pagina vond ik op ' + url + ' en dacht dat het wel eens interessant voor je kon zijn." title="Mail deze pagina">Mail deze pagina</a>';
	return link;
}
/* english returns link mail this page */
function getMailThisPageLink_EN()
{
	var url  = window.location;
	var link = '<a href="mailto:?subject=Reggefiber.nl. A web page worth having a look at&body=I found this page on ' + url + ' and thought it might be of interest to you." title="Mail this page">Mail this page</a>';
	return link;
}