/*
	FMP-IWPErr.js
	
	(c) Copyright 1999-2000 FileMaker, Inc. All rights reserved.
	
	Modification History:
	3/5/99 KJJ	Created.
*/

/* Err Object Definition */

function IWPErr()
{
	this.english	=	"Z";
	this.eFormat	=	"-format=";
	this.where		=	"";
	this.delim		=	"~";
	this.fmres		=	"/fmres/";
	this.cr2		=	"\r\r";
	this.cn			=	":";
	this.css		=	"css.";
	this.txt		=	"txt.";
	this.dot		=	".";
	this.amp		=	"&";
	this.title		=	"Unexpected Error";
	this.mssg		=	"Unable to process your request because the server encountered an\n" +
						"unexpected condition.";
						
	this.display = function()
	{
		alert(this.title + this.cn + this.cr2 + this.mssg);
		if ( location.href.toLowerCase().indexOf(this.fmres) > -1 )
		{
			if ( this.where == "" )
				history.back();
			else if ( this.where != "stop" )
			{
				this.where = this.local(this.where);
				window.location = this.where;
			}
		}
		else
			history.back();
	}

	this.local = function(str)
	{
		var result = "";
		
		if ( str.indexOf(this.delim) > -1 )
		{
			segments = str.split(this.delim);
			if ( segments[0] != "" )
				result = segments[0];
			var styl = this.getstyle();
			result += this.getlang(styl) + segments[1] + styl + segments[2];
		}
		else
			result = str;
		return result;
	}

	this.getlang = function(styl)
	{
		if ( this.lang == null )
		{
			this.lang = "";
			if ( styl == this.dot )
				this.lang = this.vformat.substring(0,1);
		}
		return this.lang;
	}

	this.getstyle = function()
	{
		if ( this.style == null )
		{
			this.style = this.dot;
			if ( this.vformat.indexOf(this.css) != -1 )
				this.style = this.css;
			else if ( this.vformat.indexOf(this.txt) != -1 )
				this.style = this.txt;
		}
		return this.style;
	}
}

/* Create Objects */

err = new IWPErr();
