function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
	
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+"="+escape( value ) +
		( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}
	
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function getJumpKey()
{
	var jk = document.getElementsByName("jump_key");
	if (jk == null) return 0;
	if (jk[0] == null) return 0;
	return jk[0].getAttribute("content");
}

function getQueryString(name) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var nameval = vars[i].split("=");
    if (nameval[0] == name) {
      return nameval[1];
    }
  } 
}

function startIB(popup)
{
	if (popup) {
	   loadFullScreen( 'https://www.hbfib.boq.com.au/hbfws/hbfbl' );
	} else {
		location.href = 'https://www.hbfib.boq.com.au/hbfws/hbfbl';
	}
}

function loadFullScreen( page )
{
   var resize = '';
   var titlebar = '';
   var wvalue = screen.width - 7;
   var hvalue = screen.height - 75;
   var ibWin = window.open(page,'', 'top=0,left=0,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=' + wvalue + ',height=' + hvalue + resize + titlebar + ',hotkeys=0');  
}


function launchJP() {
	loadFullScreen("/internet_banking_fraud_jump_page.htm")
}

function OnContinueClick()
{
	var c = getCookie("jpid");

	var flags = document.getElementsByName("Show_JP_Flag");
	var showMsgFlag = flags[0];
	if (showMsgFlag.checked == true) {
		var jpid = getJumpKey();
		setCookie("jpid", jpid, "365");
	}
	startIB(false);
}

function launchIB()
{
	document.cookie = "hbfcookieson=bqlcookies;path=/";
	cookieOn = (document.cookie.indexOf("hbfcookieson") != -1) ? true:  false;
	if (!cookieOn) {
		loadFullScreen( 'http://www.hbf.com.au/ibnocookie.html' );
		return;
	}
	var jpid = getJumpKey();
	if ( (jpid == 0) || (jpid == null)) {
		startIB(true);
	} else {
		var cid = getCookie("jpid");
		if ( (cid != null) && (cid == jpid) )
		{
			startIB(true);	
		} 
		else 
		{
			launchJP();
		}
	}
}
