<!--

//*************************************************************************************************************************************
//*		     Kay Media Technologies Ltd - HSE Development - COSHH Essentials
//*          ---------------------------------------------------------------
//* Element		: ECoshh.js
//* Description : This is the global JavaScript file that contains common functions used on every  
//*				  asp and html page on the electronic COSHH Essentials online system.
//*				 
//* Last Modified on: 05-05-2002					Modified by:	Manoj Gopinath
//*************************************************************************************************************************************

//=============================================================================================================
//Global javascript variables that determine the browser type and version 


var opera = ((navigator.appName == "Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4)&&(navigator.userAgent.indexOf('Opera') != -1));
var ie4 = false;
var ns4 = false;
var ns6 = false;
var NewWindow;

if(!opera)
{
	 ie4 = ((navigator.appName == "Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4));
	 ns4 = ((navigator.appName == "Netscape")&&(parseInt(navigator.appVersion) < 5 ));
	 ns6 = ((navigator.appName == "Netscape")&&(parseInt(navigator.appVersion) >= 5 ));
}
//alert("opera="+opera);
//alert("ie="+ie4);
//alert("ns4="+ns4);
//alert("ns6="+ns6);

//Global variable for direct progress bar

var strIndustryString = "";
var bStaging;

// 0 - Home page, 1 - Processes and tasks, 2 - State and mixture, 3 - Chemical name , 
// 4 - RPhrase, 5 - Hazard Group, 6 - Hazard group Override, 7 - Volatile Solid, 8 - Volatile Liquid 
// 9 - Usage, 10 - Summary, 11 - Control Approach, 12 -  ?

//Global javascript variable that stores the status message that are displayed on the status bar of the browser on each page
var aryStatMsg= new Array(  "COSHH Essentials Home Page",
							"Click the 'Go' button to proceed...",
							"Click the 'Go' button to proceed...",
							"Click the 'Go' button to proceed...",
							"Click the 'Go' button to proceed...",
							"Click the 'Go' button to proceed...",
							"Choose an option at the bottom of the page to proceed...",
							"Click the 'Go' button to proceed...",
							"Click the 'Go' button to proceed...",
							"Click the 'Go' button to proceed...",
							"Click the 'Go' button to proceed...",
							"Thank you for using this online service.",
							"Choose an option by clicking the Go button...");
							
//=============================================================================================================
//Function that determines the browser and displays a message to the user if the user is accessing the system with a browser 
//that is NOT Internet Explorer 4.0 or higher or Netscape Navigator 4.5 or higher
function BrowserCheck(){
	if(!ns4 && !ie4 && !opera && !ns6) {
		document.write("<font color=#aa0000>This site does not support the type of browser, you are using. Please use Internet" +
		               " Explorer 4.x,5.x OR Netscape Navigator 4.7x.</font></b>");
	}
}


//=============================================================================================================
//Function that opens a pop up window with the specified url, name and features
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//=============================================================================================================
//Reloads a page
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//=============================================================================================================
//Function to retains the original image after a mouseover effect, i.e., when the mouse pointer has moved away from the image
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 to preload images when a page is being rendered
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 that determines if a specific html documant object exists, and if so returns the instance of the object
function MM_findObj(n, d) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

//=============================================================================================================
//Funtion that displays a new image when the mouse pointer is postioned on an image
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 to display the status message on the browser
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

//=============================================================================================================
//Function that sets the focus on a popup window that has been invoked
function setModal(){
 if(setModal.arguments.length > 0) 
	setInterval("focus()",1000);
 self.focus();  
}

var defaultEmptyOK=false;

//=============================================================================================================
//Function that returns true if the string passed to it is an empty ot null string
function IsEmpty(s){   
    return ((s == null) || (s.length == 0))
}

//=============================================================================================================
//Function that returns true if the character passed to it is an alphabet
function IsLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

//=============================================================================================================
//Function that returns true if the character passed to it is a digit
function IsDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

//=============================================================================================================
// IsInteger (STRING s [, BOOLEAN emptyOK])
// Returns true if all characters in string s are numbers.
function IsInteger (s) {   
    var i;

    if (IsEmpty(s)) 
       if (IsInteger.arguments.length == 1) return defaultEmptyOK;
       else return (IsInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!IsDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

//=============================================================================================================
// IsSignedInteger (STRING s [, BOOLEAN emptyOK])
// Returns true if all characters are numbers; 
// first character is allowed to be + or - as well.

function IsSignedInteger (s)

{   if (IsEmpty(s)) 
       if (IsSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (IsSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (IsSignedInteger.arguments.length > 1)
            secondArg = IsSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (IsInteger(s.substring(startPos, s.length), secondArg))
    }
}

//=============================================================================================================
//	IsPositiveInteger (STRING s [, BOOLEAN emptyOK])
//	Returns true if string s is an integer > 0.
//  If emptyOK is false (or any value other than true), 
//  the function will return false if s is empty.
function IsPositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (IsPositiveInteger.arguments.length > 1)
        secondArg = IsPositiveInteger.arguments[1];

      return (IsSignedInteger(s, secondArg)
         && ( (IsEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}


//=============================================================================================================
// IsAlphabetic (STRING s [, BOOLEAN emptyOK])
// Returns true if string s is English letters 
// (A .. Z, a..z) only.
function IsAlphabetic (s)

{   var i;

    if (IsEmpty(s)) 
       if (IsAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (IsAlphabetic.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!IsLetter(c))
        return false;
    }

    // All characters are letters.
    return true;
}


//=============================================================================================================
// IsAlphanumeric (STRING s [, BOOLEAN emptyOK])
// Returns true if string s is English letters 
// (A .. Z, a..z) and numbers only.
function IsAlphanumeric (s)

{   var i;

    if (IsEmpty(s)) 
       if (IsAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (IsAlphanumeric.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphanumeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number or letter.
        var c = s.charAt(i);

        if (! (IsLetter(c) || IsDigit(c) ) )
        return false;
    }

    // All characters are numbers or letters.
    return true;
}

//=============================================================================================================
// isFloat (STRING s [, BOOLEAN emptyOK])
// True if string s is an unsigned floating point (real) number. 
function IsFloat (s)

{   var i;
    var seenDecimalPoint = false;
	var decimalPointDelimiter = "."

    if (IsEmpty(s)) 
       if (IsFloat.arguments.length == 1) return defaultEmptyOK;
       else return (IsFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!IsDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}


//=============================================================================================================
// HasNoDoubleQuote(STRING s)
// True if string s contains a double quote character 
function HasNoDoubleQuote(s) {
   var i ;
   var bFound = false ;

   for (i = 0; i < s.length; i++) {
	if (s.charAt(i) == '"') {
	    bFound = true ;
	}
   } 		
   return(!bFound) ;
}

//=============================================================================================================
//function to close pop up window
function closeHelpPop()
{
	if(NewWindow != null)
	{
		if(NewWindow.closed == false)
		{
			NewWindow.close();
			NewWindow = null;
		}
	}
}


//=============================================================================================================
// Image Preload function-calls that preload all the Left Navigation and  Prgress Bar images on every page
MM_preloadImages('../images/AboutOver.gif','../images/HomeOver.gif','../images/HelpNavOver.gif','../images/ExampleOver.gif','../images/HSENavOver.gif','../images/HSEDirectNavOver.gif','../images/DTIOver.gif','../images/EnvironmentOver.gif','../images/go.gif','../images/goClicked.gif');
MM_preloadImages('../images/ProcessOver.gif','../images/HowManyOver.gif','../images/ChemicalNameOver.gif','../images/HazardOver.gif','../images/FormOver.gif','../images/HowMuchOver.gif','../images/SummaryOver.gif','../images/AdviceOver.gif');


//-->
