if( navigator.appName.indexOf("Netscape") == -1)
{
	window.onerror = ErrorSetting;
}
var e_msg="";
var e_file="";
var e_line="";
var HTTP_URL="";

function ErrorSetting(msg, file_loc, line_no) {
	e_msg=msg;
	e_file=file_loc;
	e_line=line_no;
	var options='toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=770,height=520,top=10,left=10,screenX=0,screenY=0';
	var title= 'HSBCBankBrasil';
	self.close();
	jancgi= window.open(getCgiPath(HTTP_URL),title,options);
	return true; 
}

function display() {
	var   error_d = "Error in file: " + e_file + 
      		            "\nline number:" + e_line +
	      	             "\nMessage:" + e_msg;

	alert("Error Window:\n"+error_d);
}

function abreLink(url,typehome) 
{
	HTTP_URL= url;
	var parent1= typeof window.opener.parent;
 var opener1= objType(window.opener);
	var central1, opener2;
	var options='toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=770,height=520,top=10,left=10,screenX=0,screenY=0';
	var title= 'HSBCBankBrasil';
	var jancgi;
	if( !isUndef(parent1))
	{
		central1= objType(window.opener.parent.central);
	}else{
		central1= "undefined";
	}

	if( !isUndef(opener1))
	{
		if( (typeof window.opener.window) != "unknown" )
		{
			if( isUndef(objType(window.opener.window)) )
				opener2= "undefined";
			else
				opener2= objType(window.opener.window.opener);
		}
	}else{
		opener2= "undefined";
	}


   if( isUndef(opener1) || isUndef(parent1) 
		 || (isUndef(central1) && isUndef(opener2)) )
   {
      jancgi= window.open(getCgiPath(url),title,options);
   }else{
      if( central1 != "undefined")
      {
         window.opener.parent.central.document.location.href = url;
         window.opener.parent.central.focus();
	 if( typehome && typehome == 'j' )
	 {
		window.opener.parent.menu.document.location.href = '/menu_emp.html';
	 }
      }else{
			if( isUndef(objType(window.opener.window.opener.parent)) )
			{
				jancgi= window.open(getCgiPath(url),title,options);
			}else{
				var tipo= objType(window.opener.window.opener.parent.central);
				if( !isUndef(tipo))
				{
					window.opener.window.opener.parent.central.document.location.href=url;
					window.opener.window.opener.parent.central.focus();
				}else{
					jancgi= window.open(getCgiPath(url),title,options);
				}
			}
      }
   }
}

function isUndef(tipo)
{
	if( tipo == null)
		return false;
	return( tipo == "undefined" || tipo == "unknown");
}

function objType(obj)
{
	if( obj == null)
		return "undefined";
	return typeof obj;
}

function getCgiPath(url)
{
	var urlRet= '/cgi-bin/frameset.cgi?url=';
	if( url.charAt(0) == '/')
		return urlRet+url; 
	else
		return urlRet+getPath()+url;
}

function getPath()
{
	var href= window.location.href;
	var achou= false;
	var i= href.length-1;
	var url;
	while( !achou && i> 0)
	{
		if( href.charAt(i) == "/")
			achou= true;
		else
			i--;
	}
	var inic= href.substring(7).indexOf("/");
	return href.substring(7+inic,i+1);
}
function abreLinkframe(link) {
	parent.opener.location=link;
	parent.opener.focus();
}

