/****************************************************************************************************
*	Filename: crestAlert.js
*	Purpose: All the  functions that are used for the pop-up error message are defined in here. 
*	Author : SemoSoftware
	*	Creation Date: 29/8/2007
	*	Last Modified: 3/9/2007
****************************************************************************************************/
var def_crestAlert="1.0";
var defaultWidth = 400;     // Default width of window
var defaultHeight = 200;    // Default height of window
var maxHeight = screen.availHeight / 2; // Maximum height of window
var win;

if (navigator.appName.indexOf("Netscape") >= 0 && parseInt(navigator.appVersion) >= 4)
{
  var aboveNN4 = true
}
if (navigator.appName.indexOf("Explorer") >= 0 && parseInt(navigator.appVersion) >= 4)
{
  var aboveIE4 = true;
}

if( typeof(def_validateForm)!= "undefined" )
{
  alertMethod = "crestAlert";
  alertMIME   = "html";
}

function keyPress(d)
{
    key = aboveNN4 ? d.which : win.event.keyCode
    if( key == 13 )
    {
        winClose();
    }
}

function winClose(selfRef)
{
  if( typeof( win ) == 'object' && !win.closed )
  {
    win.close();
  }
  else if (typeof(selfRef) == 'object')
  {
    selfRef.close();
  }
  
}

function crestAlert( name, text, width, height )
{
  winClose();
  if( typeof( width ) == "undefined" )
  {
    width = defaultWidth;
  }
  if( typeof( height ) == "undefined" )
  {
    height = defaultHeight;
  }
  if( height > maxHeight )
  {
    height = maxHeight;
  }
  win = open( "", "CrestGlobal_alert", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=" + width + ",height=" + height );
  win.document.write( '<html>\n' +
    '<head>\n' +
    '  <title>' + name + '</title>\n' +
    '  <link rel="stylesheet" type="text/css" href="css/bluestyle.css" />\n' +
    '</head>\n' +
    '<body onload= focus(); leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">\n' +
    '<table border="0" cellpadding="5" width="100%" >\n' +
    '<tr>\n' +
    '  <td height="16" class="navbar_td" align="center">' + name + '</td>\n' +
    '</tr>\n' +
    '</table>\n' +
    '<table border="0" cellpadding="6" width="100%" >\n' +
    '<tr>\n' +
    '  <td valign="top"  class="main_text1">' + text + '</td>\n' +
    '</tr>\n' +
    '<tr>\n' +
    '  <td valign="bottom" width="100%" class="main_text1" ><div align="center"><br /><br /><br /><br /><img src="images/bullet2.jpg" valign="bottom" width="11" height="11" alt="Crest Global Logistics India" />&nbsp;<a class="main_text1" href="javascript:opener.winClose(this)">Close</a></div></td>\n' +
    '</tr>\n' +
    '</table>\n' +
    '</body>\n' +
    '</html>' );

if (aboveNN4 && typeof( win ) == 'object' && !win.closed )
{
    win.captureEvents(Event.KEYDOWN);
    win.onkeydown = keyPress;
}
else if (aboveIE4 && typeof( win ) == 'object' && !win.closed )
{
  win.document.onkeydown = keyPress;
}
  win.document.close();
  win.focus();
  return win;
}
