//start presentaion object
function presentationObj()
{
//var lyr = new layerObj(name,w,h,x,y,z);

this.popUpwinAlert=false;
this.AlertBox=false;
this.layerAlert=false;
this.Src="";
this.dispType=arguments[1];
//layer object is dependent on file LayerObj.js
this.layerName="";
this.layerObj=null;
this.layerDimWidth="";
this.layerDimHeight="";
this.layerDimX="";
this.layerDimY="";
this.layerDimZ="";
//w,h,x,y,z
this.errorFlag=false;
this.errorArray=arguments[0];

this.checkerrorFlag();
this.setAlertType();
}//end presentationObj


function pres_setAlertType()
{
 if(this.dispType)
 {if(this.dispType.toLowerCase()=="win"){this.setwinAlert(true); this.constHtmlErrMsg();}
  if(this.dispType.toLowerCase()=="layer"){this.setlayerAlert(true); this.constHtmlErrMsg();}
  if(this.dispType.toLowerCase()=="popupbox"){this.setpopUpAlert(true); this.constTextErrMsg();}
 }
}

function pres_showAlert()
{if(this.errorFlag)
 {
 if(this.popUpwinAlert)this.errorCall();
 if(this.layerAlert){this.layerObj.layerWrite(this.Src); this.layerObj.changeDisplay("block"); }
 if(this.AlertBox)alert(this.Src);
 }
}//end showAlert

function pres_seterrorFlag(val){this.errorFlag=(val==true||val=="true")?true:false;}
function pres_setwinAlert(val){this.popUpwinAlert=(val==true||val=="true")?true:false;}
function pres_setpopUpAlert(val){this.AlertBox=(val==true||val=="true")?true:false;}
function pres_setlayerAlert(val){this.layerAlert=(val==true||val=="true")?true:false;}
function pres_checkerrorFlag(){if(this.errorArray.length>0)this.seterrorFlag(true); else this.seterrorFlag(false);}
function pres_setlayerDim()
{var minArgs=6;
if((arguments)&&(this.layerAlert))
 {
   for(i=1; i<minArgs; i++) if(!arguments[i])arguments[i]="auto";
   
   this.layerName = arguments[0] ; this.layerDimWidth = arguments[1];
   this.layerDimHeight = arguments[2]; this.layerDimX = arguments[3];
   this.layerDimY = arguments[4]; this.layerDimZ=arguments[5]; 
  this.setlayerObj();
  }
}

function pres_setlayerObj()
{if(this.layerAlert) this.layerObj= new layerObj(this.layerName,this.layerDimWidth,this.layerDimHeight,this.layerDimX,this.layerDimY,this.layerDimZ); this.layerObj.changeDisplay("none");}

function pres_seterrorarray(arr){if(arr)this.errorArray = arr;}//end 
function pres_setSrc(str){if(str)this.Src = str;}//end 

/*****************************************************************************************
* function construct_error_messagehtml parses the error array for html output*
******************************************************************************************/ 
function construct_error_messagehtml()
{
var message_str='<table width="100%">\n';
 if(this.errorArray)
   for(i=0; i<this.errorArray.length; i++)
    message_str+='<tr><td valign="top">&#0149;</td><td>'+this.errorArray[i]+'</td></tr>\n';
message_str+='</table><br />';
this.setSrc(message_str);

}//end construct_error_messagehtml
//(this.popUpwinAlert||this.layerAlert)
function construct_error_messagetxt()
{
var message_str='';
 if(this.errorArray)
   for(i=0; i<this.errorArray.length; i++)  message_str+=this.errorArray[i]+"\n";

 this.setSrc(message_str);
}//end construct_error_messagetext


function pres_errorCall()
{
 
 var win_hieght=(this.errorArray.length >5)?220:150;
 var scroll_bars=(this.errorArray.length >8)?1:0;
 
//  if(error_flag) 
this.showgelErrorWin(this.Src,win_hieght,scroll_bars,'error window');
}

function pres_displayErrorDiv()
{
	var displayText="";
	displayText+='<table cellpadding="3" cellspacing="0" border="0">';
	displayText+='<tr><td valign=top ><img src=/images/icons/icon_warning.gif border="0" width="23" height="21"></td><td valign=top class="redbold">';
	displayText+='Please correct the following errors:';
	displayText+=this.Src;
	displayText+='</td></tr></table>';

	this.setSrc(displayText); 
}


//
function pres_gel_error_page(tMsg)
{
	//supports arg 1= text height in pixels, arg 2= scrollbars  1 or 0 
	//defaults: textHeight=175 (consequently winHeight=300), scrollbar= empty str

	if ((tMsg == "") || (tMsg == null))
	{
		tMsg="Error message not provided.";
	}
	var tStr="";
	var textHeight=185;
	var winTitle="Incomplete Form"
	if (arguments.length>1)	textHeight=arguments[1];
	if (arguments.length>3)	winTitle=arguments[3]; //third parameter passed is the window title
	
	
 tStr+='<html>\n';
 tStr+='<head>\n';
 tStr+='<base href="http://www.bellsouth.com">\n';
 tStr+='<title>BellSouth - ' + winTitle
 tStr+='</title>\n';
 tStr+='<script language="JavaScript" type="text/javascript" src="/scripts/sniffAPI.js"></script>\n';
 tStr+='</head>\n';
 
 tStr+='<body background="/images/popup_orange_bk.gif" onload="window.focus();">\n';
 
 tStr+='<table width="429" border="0" cellspacing="0" cellpadding="0" align="center">\n';
 
 tStr+='<tr>\n';
 tStr+='<td rowspan="3" colspan="2"><img src="/images/tl_orange_curv.gif" width="19" height="23" alt="" border="0"></td>\n';
 tStr+='<td bgcolor="#FF6600"><img src="/images/spacer.gif" height="1" width="391" border="0"></td>\n';
 tStr+='<td rowspan="3" colspan="2"><img src="/images/tr_orange_curv.gif" width="19" height="23" alt="" border="0"></td></tr>\n';
 
 tStr+='<tr>\n';
 tStr+='<td bgcolor="#FFDAC3" class="orangebold"><img src="/images/spacer.gif" height="18" width="1" border="0">Attention</td></tr>\n'; 
 
 tStr+='<tr>\n';
 tStr+='<td bgcolor="#FF6600"><img src="/images/spacer.gif" height="1" width="1" border="0"></td></tr>\n';  
 
 tStr+='<tr bgcolor="#FFFFFF">\n';
 tStr+='<td bgcolor="#FF6600"><img src="/images/spacer.gif" height="1" width="1" border="0"></td>\n';
 tStr+='<td bgcolor="#FFFFFF"><img src="/images/spacer.gif" height="1" width="18" border="0"></td>\n';
 tStr+='<td bgcolor="#FFFFFF">\n';
 tStr+='<table cellspacing="0" cellpadding="0" border="0" align="center" bgcolor="#FFFFFF">\n';
 
 tStr+='<tr>\n';
 tStr+='<td valign="top"><br><img src="/images/icons/icon_warning.gif" width="23" height="21" border="0"></td>\n';
 tStr+='<td width="10">&nbsp;</td>\n';
 tStr+='<td><br><span class="bluebold">';
 tStr+=winTitle;
 tStr+='</span><br><br>\n';
 tStr+=tMsg+'\n';
 tStr+='</td></tr>\n';
 
 tStr+='<tr>\n';
 tStr+='<td align="center" colspan="3"><a href="javascript: window.close();"><img src="/images/buttons/btn_closewindow.gif" width="82" height="27" alt="Click here to Close Window" border="0"></a></td></tr>\n';
 tStr+='</table>\n';
 tStr+='</td>\n';
 
 tStr+='<td bgcolor="#FFFFFF"><img src="/images/spacer.gif" height="1" width="18" border="0"></td>\n';
 tStr+='<td bgcolor="#FF6600"><img src="/images/spacer.gif" height="1" width="1" border="0"></td></tr>\n';
 
 tStr+='<tr>\n';
 tStr+='<td rowspan="2" colspan="2"><img src="/images/bl_orange_curv.gif" width="19" height="11" alt="" border="0"></td>\n';
 tStr+='<td bgcolor="#FFFFFF"><img src="/images/spacer.gif" height="10" width="1" border="0"></td>\n';
 tStr+='<td rowspan="2" colspan="2"><img src="/images/br_orange_curv.gif" width="19" height="11" alt="" border="0"></td></tr>\n';
 
 tStr+='<tr>\n';
 tStr+='<td bgcolor="#FF6600"><img src="/images/spacer.gif" height="1" width="1" border="0"></td></tr>\n'; 
 tStr+='</table>\n';
 tStr+='</body>\n';
 tStr+='</html>\n';
	
	var winHeight=((parseInt(textHeight))+125);  //use parseInt to force textHeight to be numeric
	var sBars="";
	if (arguments.length>2)
	 if (arguments[2])sBars=",scrollbars=yes,resizable=yes"; //second paramter
		
	
if(this.popUpwinAlert)
  {
	var error_win=window.open('','blsErrorWin','width=450,height='+winHeight+sBars+',alwaysRaised=yes');
	error_win.document.open();
	error_win.document.writeln(tStr);
	error_win.focus();
  }

}

presentationObj.prototype.constHtmlErrMsg = construct_error_messagehtml;
presentationObj.prototype.setErrorArray = pres_seterrorarray;
presentationObj.prototype.setSrc = pres_setSrc;
presentationObj.prototype.errorCall = pres_errorCall;
presentationObj.prototype.showgelErrorWin = pres_gel_error_page;
presentationObj.prototype.setAlertType = pres_setAlertType;
presentationObj.prototype.setwinAlert = pres_setwinAlert;
presentationObj.prototype.setpopUpAlert = pres_setpopUpAlert;
presentationObj.prototype.setlayerAlert = pres_setlayerAlert;
presentationObj.prototype.constTextErrMsg = construct_error_messagetxt;
presentationObj.prototype.setlayerDim = pres_setlayerDim;
presentationObj.prototype.setlayerObj = pres_setlayerObj;
presentationObj.prototype.showAlert =  pres_showAlert;
presentationObj.prototype.seterrorFlag = pres_seterrorFlag;
presentationObj.prototype.checkerrorFlag =  pres_checkerrorFlag;
presentationObj.prototype.displayErrorDiv = pres_displayErrorDiv;
