// function to determine the browser
	
function Is()
{
	agent  = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
    
		
	// Netscape 7 will show as Netscape 6 ( this.ns6 )
	
	this.ns    = ((agent.indexOf('mozilla')   !=   -1) &&
                ((agent.indexOf('spoofer')   ==   -1) &&
                (agent.indexOf('compatible') ==   -1)));
                 
	this.ns2   = (this.ns && (this.major      ==    3));
	this.ns3   = (this.ns && (this.major      ==    3));
	this.ns4b  = (this.ns && (this.major      ==    4) &&
	             (this.minor                  <= 4.03));
	this.ns4   = (this.ns && (this.major      >=    4));
	this.ns6    = (this.ns && (this.major     >=    5));
   
	this.ie    = (agent.indexOf("msie")       !=   -1);
   
	this.ie3   = (this.ie && (this.major      <     4));
	this.ie4   = (this.ie && (this.major      ==    4) &&
	             (agent.indexOf("msie 5.0")   ==   -1));
	this.ie4   = (this.ie && (this.major      ==    4) &&
		         (agent.indexOf("msie 5.0")   ==   -1) &&
		         (agent.indexOf("msie 5.5")	  ==   -1) &&
				 (agent.indexOf("msie 6.0")   ==   -1));
	this.ie5   = (this.ie && (this.major      ==    4) &&
		         (agent.indexOf("msie 5.0")   !=   -1));
	this.ie55  = (this.ie && (this.major      ==    4) &&
		         (agent.indexOf("msie 5.5")   !=   -1));
	this.ie6 =   (this.ie && (this.major      ==    4) &&
		         (agent.indexOf("msie 6.0")   !=   -1));
		             
		
}
 
// ------------------------------------------------------------------------------	
	
	
// declare an object of this type
	
var is = new Is();

var msGUID;

var lPrintAlert =0;





// Browser Back function


function BrowserBack()
{
	var Parent = parent;
	
	if ( is.ns4 || is.ns4b || is.ns6 )
	{
		window.back();
	}
	else
		{
			history.back();
		}

}

function BrowserForward()
{
	var Parent = parent;
	
	if ( is.ns4 || is.ns4b || is.ns6 )
	{
		window.forward();
	}
	else
		{
			history.forward();
		}

}

function setPrintAlert(lPrintAlertConstant)
{
	lPrintAlert = lPrintAlertConstant;
}



function printPage()
{
	// print the requested frame
	
	
	
	var sMessage;
	
	if (is.ie4 || is.ie5 || is.ie55 || is.ie6 )
	{
				
		if ( is.ie4  )
		{
			alert("Unfortunately this functionality is not available with this Browser\nRight click on this window and select 'Print'.");
		}
		else
			{
				
				switch (lPrintAlert)
				{
					case 1: // Graph Print Alert
						sMessage = "The Profile's print facility uses your browser's default settings for printing.\n";
						sMessage+= "Please ensure that the paper orientation is set to 'landscape' prior to printing.";
						break;
					default:
						sMessage="";			
				
				
				
				}
		
		
				if(lPrintAlert)
				{
					alert(sMessage);
				}		
				
				window.print();
			}	
		
		
	}
	
	
	if (is.ns4 || is.ns4b)
	{
		
		appVer = parseFloat(navigator.appVersion);

		if (appVer < 4.0)
		{
			alert("Unfortunately this functionality is not available with this Browser.\n");

		}
		else
			{
				window.print();
			}
	
	
	
	
	}
}

function openNewWindow(myPage)
{
		// open a child window containing the site map for the user
		// to see if the changes are reflected correctly
		
	var MyWindow
		
	MyWindow = open(myPage,"MyWindow",
					"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=800,height=600");
		
} // end function

function openEmailWindow(myPage)
{
		// open a child window containing the site map for the user
		// to see if the changes are reflected correctly
		
	var MyWindow
		
	MyWindow = open(myPage,"MyWindow",
					"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=600,height=570");
		
} // end function


function openNewPrintWindow(myPage)
{
		// open a child window containing the site map for the user
		// to see if the changes are reflected correctly
		
	var MyWindow
		
	MyWindow = open(myPage,"MyWindow",
					"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=800,height=600");
		
		
} // end function


function openSmallWindow(myPage)
{
		// open a child window containing the site map for the user
		// to see if the changes are reflected correctly
		
	var MyWindow
		
	MyWindow = open(myPage,"ExitWindow",
					"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=400,height=300");
		
} // end function

function openGraphWindow(myPage)
{
		// open a child window containing the site map for the user
		// to see if the changes are reflected correctly
		
	var MyWindow;
	
		
	MyWindow = open(myPage,"GraphWindow",
					"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=850,height=650");
		
} // end function


function setGUID(sGUID)
{

	msGUID = sGUID;


}

function openGraphSubWindow(iElementType, lValue,lSource,bShowPending,bComment)
{
		// open a child window containing the site map for the user
		// to see if the changes are reflected correctly
		
	var MyWindow;
	var sPending;
	var sComment;
	var SUPPLIER_CORPORATE_PERFORMANCE = 1;
	var SUPPLIER_CAPABILITY_PROFILE = 2;
	var SUPPLIER_CORPORATE_PERF_PROFILE=3;
	var SUPPLIER_PRODUCT_PERF_PROFILE = 4;
	var SUPPLIER_PERF_BENCHMARK = 5;
	var SUBSCRIBER_PERF_PROFILE = 6;
	var SUBSCRIBER_PERF_BENCHMARK = 7;
	
	
	if (bShowPending) 
	{
		sPending="YES"
	}
	
	if (bComment)
	{
		sComment="YES"
	}
	else
	{
		sComment="NO"
	}
	
		
	if (bShowPending)
	{
		MyWindow = open('ElementDetails.asp?GraphSource=' + lSource + '&ElementType=' + iElementType + "&Value=" + lValue + "&Pending=" + sPending + "&Comment=" + sComment + "&GUID=" + msGUID,"GraphSubWindow",
					"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=780,height=240");

	
	}
	else
	{
		MyWindow = open('ElementDetails.asp?GraphSource=' + lSource + '&ElementType=' + iElementType + "&Value=" + lValue + "&Comment=" + sComment + "&GUID=" + msGUID,"GraphSubWindow",
					"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=780,height=240");

	
	}
		
} // end function


function openNewBrowser(myPage)
{
		// open a browser window containing the site map for the user
		// to see if the changes are reflected correctly
		
	var MyWindow
		
	MyWindow = open(myPage,"MyWindow",
					"toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=800,height=600");
		
} // end function

function openHomeBrowser(myPage)
{
		// open a browser window containing the site map for the user
		// to see if the changes are reflected correctly
		
	var MyWindow
		
	MyWindow = open(myPage,"MyWindow",
					"toolbar=yes,location=no,directories=yes,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=800,height=600");
		
} // end function


function openHelpWindow(myPage)
	{
		// open a child window containing the site map for the user
		// to see if the changes are reflected correctly
		
		var MyWindow
		
			MyWindow = open(myPage,"HelpWindow",
					"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=800,height=600");
		
	} // end function









// function getObj

// returns a reference to the particular layer or the layers style
	

function getObj(name)
{
	if (document.getElementById)
	{
		return document.getElementById(name).style;
	}
		else if (document.all)
	{
		return document.all[name].style;
	}
	else if (document.layers)
	{
		return document.layers[name];
	}
}

function getLayer(name)
{
	if (document.getElementById)
	{
		return document.getElementById(name);
	}
		else if (document.all)
	{
		return document.all[name];;
	}
	else if (document.layers)
	{
		return document.layers[name];
	}

}

// function toggleLayer()
// to toggle a layer visible or invisible
	
function toggleLayer(layerName)
{
		
	var myObj = getObj(layerName);
	
	if (myObj.visibility == "hidden" || myObj.visibility == "hide" || myObj.visibility == "")
	{
		showLayer(layerName);
	
	}
	else
	{
		hideLayer(layerName);
	
	}
	
	
}

	
	
	
// function showLayer()
// to show a Layer
	
function showLayer(layerName)
{
		
	var myObj = getObj(layerName);
			
	myObj.visibility = "visible";
	
		
	
} //end of showLayer()
	
	
	
// function hideLayer
//  to hide a layer
	
function hideLayer(layerName)
{
	var myObj = getObj(layerName);
		
		
	myObj.visibility = "hidden";
		
}

function LTrim(String)
{
		var i = 0;
		var j = String.length - 1;

		if (String == null)
			return ('');

		for (i = 0; i < String.length; i++)
		{
			if (String.substr(i, 1) != ' ' &&
			    String.substr(i, 1) != '\t')
				break;
		}

		if (i <= j)
			return (String.substr(i, (j+1)-i));
		else
			return ('');
}

function RTrim(String)
{
		var i = 0;
		var j = String.length - 1;

		if (String == null)
			return ('');

		for(j = String.length - 1; j >= 0; j--)
		{
			if (String.substr(j, 1) != ' ' &&
				String.substr(j, 1) != '\t')
			break;
		}

		if (i <= j)
			return (String.substr(i, (j+1)-i));
		else
			return ('');
}

function Trim(String)
{
		if (String == null)
			return ('');
	
		return RTrim(LTrim(String));
}

/**************************************************************
 IsAlphanumeric: Returns a Boolean value indicating whether an 
                 expression can be evaluated as a number or
                 char.

 Parameters:
      Expression = Variant containing a numeric expression or 
                   string expression.

 Returns: Boolean
***************************************************************/
function IsAlphanumeric(Expression)
{
	Expression = Expression.toLowerCase();
	RefString = "abcdefghijklmnopqrstuvwxyz0123456789 ";

	if (Expression.length < 1) 
		return (false);

	for (var i = 0; i < Expression.length; i++) 
	{
		var ch = Expression.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a == -1)
			return (false);
	}
	return(true);
}


/**************************************************************
 IsNumber: Returns a Boolean value indicating whether an 
           expression can be evaluated as a number (this
           includes values like $15,656.00)

 Parameters:
      Expression = Variant containing a numeric expression or 
                   string expression.

 Returns: Boolean
***************************************************************/
function IsNumber(Expression)
{
	Expression = Expression.toLowerCase();
	RefString = "0123456789.-";

	if (Expression.length < 1) 
		return (false);

	for (var i = 0; i < Expression.length; i++) 
	{
		var ch = Expression.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a == -1)
			return (false);
	}
	return(true);
}


/**************************************************************
	IsEmail: Returns a Boolean if the specified Expression is a
          valid e-mail address. If Expression is null, false
          is returned.

	Parameters:
			Expression = e-mail to validate.

	Returns: Boolean
	***************************************************************/
	function IsEmail(Expression)
	{
		if (Expression == null)
			return (false);

		var supported = 0;
		if (window.RegExp)
		{
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported) 
			return (Expression.indexOf(".") > 2) && (Expression.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(Expression) && r2.test(Expression));
	}
	
	

function IsDate(dateStr)
{
	// Checks for the following valid date formats:
	// MM/DD/YYYY   MM-DD-YYYY

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

	var matchArray = dateStr.match(datePat)
	if (matchArray == null)
		return false

	month = matchArray[1]
	day = matchArray[3]
	year = matchArray[4]
	if (month < 1 || month > 12)
		return false

	if (day < 1 || day > 31)
		return false

	if ((month==4 || month==6 || month==9 || month==11) && day==31)
		return false

	if (month == 2)
	{
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
		if (day>29 || (day==29 && !isleap))
			return false;
	}
	return true;
}
	
	
	
// Image Switching
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_nbGroup(event, grpName) 
{ //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}



function MM_openBrWindow(theURL,winName,features)
{ //v2.0
  window.open(theURL,winName,features);
}


  function MessageOfTheDay() {
	
	var sTargetPage;
	var oNewWindow;
	
	sTargetPage="./Bulletins/MessageOfDay.asp";
		
	oNewWindow=window.open(sTargetPage,'MessageOfTheDay','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=0,resizable=0,width=500,height=300');
	oNewWindow.focus();
  }
  
  function showHSEWindow(sURL) {
	
	var oNewWindow;
	
		
	oNewWindow=window.open(sURL,'winHSE','titlebar=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=0,width=575,height=450');
	oNewWindow.focus();
  }



