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)
	wndName = sid;
	
  /* Open the popup window using the variables required */
  var w = window.open(filename, sid, '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();
}

function isFunction(o) {
  return (typeof(o)=="function");
}

// Note: must include FirstNet/include/BrowserCheck.js to use this function.
var menuLoginLastClicked = {v: new Date(2001, 1, 1)};
function popupFirstNet()
 {
	if (isFunction(MenuPreventDoubleClick)) if (MenuPreventDoubleClick(5000, menuLoginLastClicked)) return;

    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 = "/firstnet/login.aspx?CompanyCode=001";
    var strUrlNotSupported = "/firstnet/NotSupportedFrames.asp";

    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();
}


// Note: must include FirstNet/include/BrowserCheck.js to use this function.
function popupFirstNetQl()
 {

    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 = "/firstnet/login.aspx?CompanyCode=001";

    var strUrlNotSupported = "/firstnet/NotSupportedFrames.asp";


    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();

}

// extra CFS menu functions
var menuLastClicked = {v : new Date(2001, 1, 1)};
function MenuPreventDoubleClick(delay, timeLastClicked) {
	if (!timeLastClicked) timeLastClicked = menuLastClicked;
	if (!delay) delay = 1000;
	var now = new Date();
	var result = (now.getTime() - timeLastClicked.v.getTime() < delay);
	if (!result) timeLastClicked.v = now;
	return result;
}

function goURL(url)
{
	if (MenuPreventDoubleClick(5000)) return false;
	window.location = url;
}

function fwLogin() 
{
	var pixH, pixW;
	pixW=1024;
	pixH=768;
	if (screen.availWidth <= pixW){
		pixW = screen.availWidth-10;
	}
	if (screen.availHeight <= pixH){
		pixH = screen.availHeight-120;
	}
	var w = window.open("https://www.firstwrap.com.au/","FirstWrap","width=" + pixW + ",height=" + pixH + ",resizable=yes,scrollbars=yes,location=yes,menubar=yes,toolbar=yes,status=yes,left=0,top=0,screenX=0,screenY=0");
	w.focus();
}


/* Methods Added for the help popup 

        1.showPopupWindow
        2.showPopup
        3.openWindow

*/
function showPopupWindow(url, width, height, isResizable, hasScrollbars, windowName) {
    if (width == null) width = 700;
    if (width > screen.availWidth) width = screen.availWidth;
    if (height == null) height = 600;
    if (height > screen.availHeight) height = screen.availHeight;
    if (isResizable == null) isResizable = true;
    if (hasScrollbars == null) hasScrollbars = true;
    if (!windowName) windowName = "PopupWnd";

    var left = (screen.availWidth - width) / 2;
    var top = (screen.availHeight - height) / 2;

    if (!windowName) {
        if (window.getSessionPopupWindowName)
            windowName = window.getSessionPopupWindowName();
        else
            windowName = "PopupWnd";
    }

    return openWindow(url, windowName, left, top, width, height, false, false, false, false, false, isResizable, hasScrollbars);
}

function showPopup(url, width, height, windowName) {
    this.showPopupWindow(url, width, height, null, null, windowName);
}

function openWindow(url, name, left, top, width, height, showToolbar, showStatus, showLocation, showMenubar, showDirectories, isResizable, hasScrollbars) {
    var features = "  toolbar=" + (showToolbar ? 1 : 0) +
							", status=" + (showStatus ? 1 : 0) +
							", location=" + (showLocation ? "yes" : "no") +
							", menubar=" + (showMenubar ? "yes" : "no") +
							", directories=" + (showDirectories ? "yes" : "no") +
							", resizable=" + (isResizable ? "yes" : "no") +
							", scrollbars=" + (hasScrollbars ? "yes" : "no") +
							", left=" + parseInt(left) +
							", top=" + parseInt(top) +
							", width=" + parseInt(width) +
							", height=" + parseInt(height)
    var wnd = this.open(url, name, features);

    try {
        wnd.moveTo(left, top);
        wnd.resizeTo(width, height);
        wnd.focus();
        return wnd;
    } catch (e) { }
}