function getElement(id) 
{ 
	return document.getElementById? document.getElementById(id) : document.all? document.all(id) : null; 
} 
function getIFRAME_doc_width(oIframe) 
{	
	return document.body && document.body.scrollWidth? oIframe.document.body.scrollWidth : oIframe.document.width? oIframe.document.width : null; 
} 
function getIFRAME_doc_height(oIframe) 
{ 
	return document.body && document.body.scrollHeight? oIframe.document.body.scrollHeight : oIframe.document.height? oIframe.document.height : null; 
} 
function IFRAME_size_to_content(iframe_id) 
{
	var oIframe = frames[iframe_id]; 
	if (typeof oIframe!= 'undefined') 
	{
		var wid = getElement(iframe_id).offsetWidth; 
		var hgt = getIFRAME_doc_height(oIframe); if (wid && hgt) oIframe.resizeTo(wid,hgt);
	} 
}

function findPageSize() {
  if (top.innerWidth) {
    pageW=top.innerWidth;
    pageH=top.innerHeight;
  }
  else if (top.document.body) {
    pageW=top.document.body.clientWidth;
    pageH=top.document.body.clientHeight;
  }
}

function resize() {
  oldW=pageW;
  oldH=pageH;
  findPageSize();
  if (pageW != oldW || pageH != oldH)
    location.reload();
}
//onresize=resize;

findPageSize();

/* function popup(filename){

var xsize = 660;
var ysize = 600;
	window.open(filename,'Popup', 'width=' + xsize + ',height=' + ysize + ',resizable=yes,scrollbars=yes');
}
*/

function CurrentSessionInfo_Get(name) 
{
	if(!document.cookie)
		return null;
		
	var start = document.cookie.indexOf("sessioninfo=");
	var len = start + 12;
	if ( ( !start ) && ( "sessioninfo" != document.cookie.substring( 0, 11 ) ) )
	{
		return null;
	}
	if ( start == -1 ) 
		return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) 
		end = document.cookie.length;
	var strSessionInfo = unescape( document.cookie.substring( len, end ) );
	var SessionArray = strSessionInfo.split("&");
	for(var i=0;i < SessionArray.length;i++)
	{
		var c = SessionArray[i];
		var hash = c.split("=");
		if (hash[0].toLowerCase() == name.toLowerCase())
		{
			return hash[1];
		}
	}
	return null;
}

function popupWnd(filename,x,y, resizable, scrollbars){

/* Standard Sizes to be used if none are supplied */
var xsize = 660;
var ysize = 600;

if (!resizable)
	resizable = "yes"; 
if (!scrollbars)
	scrollbars = "yes"; 

//These variables are used to (roughly) center the popup window on the screen
//Buffer is used to account for any toolbars, taskbars etc on the screen
var buffer=15;
//var toppos=((screen.availHeight-buffer)-ysize)/2;
//var leftpos=((screen.availWidth-buffer)-xsize)/2;
var toppos=(((screen.availHeight-buffer)/2)-(ysize/2));
var leftpos=(((screen.availWidth-buffer)/2)-(xsize/2));

  /* Check to see if any dimentions have been passed. If so, use them, if not, use the standard */
  if (x != null) { xsize = x; }
  if (y != null) { ysize = y; }

  var wndName = 'Popup';
  var sid = CurrentSessionInfo_Get('sid');
  if (sid && sid > 0)
      wndName = sid;
	
  /* Open the popup window using the variables required */
  var w = window.open(filename, wndName, 'width=' + xsize + ',height=' + ysize + ', left=' + leftpos + ',top=' + toppos + ',resizable=' + resizable + ',scrollbars=' + scrollbars);
  w.focus();
  
  return w;
}

function popup(filename,x,y) 
{
    popupWnd(filename,x,y);
}

function GoToPage(Page, NavOpt)	{
	var userType = SessionInfo_Get("UserType");
	if (userType == "A" || userType == "I")
	{
			parent.frames[1].location = Page; 
			parent.frames[0].location = "/firstnet/LHN.aspx?NavOpt=" + NavOpt + "&welcome=yes";
	}
	else
	{ 
		if (parent.frames[1].name == "ContextNav")
		{
			parent.frames[2].location = Page; 
			parent.frames[1].location = "/FirstNet/NavigationDynamic.asp?NavOpt=" + NavOpt + "&welcome=yes";
		}
		else
		{
			parent.frames[1].location = Page; 
			parent.frames[0].location = "/FirstNet/NavigationDynamic.asp?NavOpt=" + NavOpt + "&welcome=yes";
		}
	}
}

function HelpPopup(filename,x,y){
/* Standard Sizes to be used if none are supplied */
var xsize = 640;
var ysize = 480;

  /* Check to see if any dimentions have been passed. If so, use them, if not, use the standard */
  if (x != null) { xsize = x; }
  if (y != null) { ysize = y; }

  /* Open the popup window using the variables required */
  var w = window.open(filename,'small', 'width=' + xsize + ',height=' + ysize + ',resizable=yes,scrollbars=yes,menubar=1,location=0,toolbar=1');
  w.focus();
}

// Note: must include FirstNet/include/BrowserCheck.js to use this function.
function popupFirstNet() 
{

	var pixH, pixW;
	pixH=768;
	pixW=1024;
	if (screen.availHeight <= pixH){
		//minus 50 for start bar...
		pixH = screen.availHeight-50;
	}
	if (screen.availWidth <= pixW){
		//minu 10 cos it never exactly fits the screen...
		pixW = screen.availWidth-10;
	}
	var strUrl = "/firstnet/login.aspx?CompanyCode=001";
	var strUrlNotSupported = "/firstnet/NotSupportedFrames.asp";

	/* var w = window.open(strUrlNotSupported,"FirstNet","width=" + pixW + ",height=" + pixH + ",resizable=yes,scrollbars=no,status=yes,left=0,top=0,screenX=0,screenY=0"); */
	if (!is.ie5_5up && !is.nav6up) {
		var w = window.open(strUrlNotSupported,"FirstNet","width=" + pixW + ",height=" + pixH + ",resizable=yes,scrollbars=1,status=yes,left=0,top=0,screenX=0,screenY=0");
	}else{
		var w = window.open(strUrl,"FirstNet","width=" + pixW + ",height=" + pixH + ",resizable=yes,scrollbars=1,status=yes,left=0,top=0,screenX=0,screenY=0");
	} 
	w.focus();
	
}
function fwLogin() 
{
	var pixH, pixW;
	pixH=768;
	pixW=1024;
	if (screen.availHeight <= pixH){
		pixH = screen.availHeight-50;
	}
	if (screen.availWidth <= pixW){
		pixW = screen.availWidth-10;
	}
	var strUrl = "https://www.firstwrap.com.au/";
	var w = window.open(strUrl,"FirstWrap","width=" + pixW + ",height=" + pixH + ",resizable=yes,scrollbars=1,status=yes,left=0,top=0,screenX=0,screenY=0");
	w.focus();	
}

