// Department of Premier and Cabinet, Office of Environment and Heritage
// Education for sustainability (EFS) DotNetNuke skin - Javascript functions

var resizeIncrements = 0;
var baseSize = 100;

addLoadEvent (formatPage);

function addLoadEvent(func) 
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	} 
	else 
	{
		window.onload = function() 
		{
			if (oldonload) 
			{
				oldonload();
			}
			func();
		}
	}
}

function formatPage()
{
  var objElementArray2 = document.getElementsByTagName ? document.getElementsByTagName('a') : document.all.tags('a');
  for (intControlIndex = 0; intControlIndex < objElementArray2.length; intControlIndex ++) 
  {
 	  enableButtons(objElementArray2[intControlIndex]);
  }
  
  //var leftHeight = document.getElementByName ('cim_left-col').style.height;
  //var contentHeight = document.getElementByName ('cim_left-col').style.height;
  
}

function enableButtons(linkElement)
{
  if (linkElement.className.indexOf('widget_button') >= 0)
    linkElement.style.display='inline';
}

function resizeUp() 
{
  var ctlWrapper = document.getElementById('cim_page-wrapper');

	if (!ctlWrapper.style.fontSize)
	{
	  resizeIncrements=1;		
	}
	else 
	{
  	resizeIncrements++;
		//var str_fontsize = ctlWrapper.style.fontSize;
		//var num_fontsize = str_fontsize.substring(0,str_fontsize.length-1);		
		//var num_newsize = num_fontsize * 1.1;		
	}
	resizecheckLimit();
	num_newsize = baseSize * ((0.1 * resizeIncrements)+1);
	ctlWrapper.style.fontSize = num_newsize + '%';
}

function resizecheckLimit()
{
  if (resizeIncrements < -4) resizeIncrements = -4;
  if (resizeIncrements > 4) resizeIncrements = 4;
}

function resizeZero() 
{
	resizeIncrements=0;
	document.getElementById('cim_page-wrapper').style.fontSize = baseSize + '%';
	
}

function resizeDown() 
{
  var ctlWrapper = document.getElementById('cim_page-wrapper');
  
	if (!ctlWrapper.style.fontSize)
	{
		resizeIncrements=-1;
	}
	else 
	{
	  resizeIncrements--;
		//var str_fontsize = ctlWrapper.style.fontSize;
		//var num_fontsize = str_fontsize.substring(0,str_fontsize.length-1);
		//var num_newsize = num_fontsize * 0.9;		
	}
	resizecheckLimit();
	num_newsize = baseSize * ((0.1 * resizeIncrements)+1);
	ctlWrapper.style.fontSize = num_newsize + '%';
}

function focusSearch()
{
  document.getElementById('dnn_dnnSEARCH_txtSearch').focus();  
}

function toggle(toggleid)
{
  if (document.getElementById(toggleid))
  {
    if (document.getElementById(toggleid).style.display=='block')
    {
      document.getElementById(toggleid).style.display='none';
    }
    else
    {
      document.getElementById(toggleid).style.display='block';
    }
  }
}


function stripHttp(url) {
	url = str_replace(url, 'http://', '');
	url = str_replace(url, 'https://', '');
	return url;
}

function str_replace(haystack, needle, replacement) {
	var temp = haystack.split(needle);
	return temp.join(replacement);
}



