var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;

var objCount = 0;
var pics = new Array();

              function preload(name, first, second) {
                          var args = (arguments.length);
                          pics[objCount] = new Array(args);
                          pics[objCount][0] = name;
                          for(var i=1; i < args; i++) {
                                  pics[objCount][i] = new Image();
                                  pics[objCount][i].src = arguments[i];
                          }
                  objCount++;
              }

              function on(name) {
                var imgIndex = 2;
                  if (arguments.length > 1) {
                    imgIndex = parseInt(arguments[1]);
                  }
                  for (i = 0; i < objCount; i++) {
                    if (document.images[pics[i][0]] != null) {
                      if (name != pics[i][0])
                        { document.images[pics[i][0]].src = pics[i][1].src; }
                      else {
                        if (imgIndex < pics[i].length) { document.images[pics[i][0]].src =
			pics[i][imgIndex].src;
                        } else { document.images[pics[i][0]].src = pics[i][1].src; }
                      }
                    }
                }
              }

              function extra(name) {
                var i=0;
                var imgIndex = 2;
                  if (document.images[name] == null) { return 0; }
                  if (arguments.length > 1) {
                    imgIndex = parseInt(arguments[1]);
                  }
                  for(i=0;i<objCount;i++) {
                    if (pics[i][0] == name) { break; }
                  }
                  if (pics[i][0] != null && imgIndex < pics[i].length)
                  { document.images[name].src = pics[i][imgIndex].src; }
                  else { document.images[name].src = pics[i][1].src; }
                  return 1;
                return 0;
              }

              function off() {
                  for (i = 0; i < objCount; i++) {
                    if (document.images[pics[i][0]] != null) {
                    document.images[pics[i][0]].src = pics[i][1].src;
                    }
                  }
	      }

//This function will change the address currently loaded in the window
function setPageLocation(NewURLString) {
	window.location=NewURLString;
	
	//window.navigate(NewURLString);
}

/* 
a browser sniffer by Jan van Gessel<yaba(at)2central.com

Tests for Opera, mozilla based and IE based browsers.
The function returns browser name as text and browser version as a number making it easy to use
eq. if ((browser_name == "Netscape") && (browser_version<5)) {document.write('<LINK REL="stylesheet" HREF="siteNN.css" TYPE="TEXT/CSS">');}
Should be compatible wih future versions.
Due to the fact that Opera can identify as other browsers this is tested for first in order to avoid mistakes
The "if" statements are set up as independent entities making it easy to expand the function or use seperately
So far tested on opera 7.02, Netscape 4.7, mozilla 1.01, phoenix 0.5, IE5.5  on win95/98
Feel free to use as you see fit just keep it free for everyone, feedback on other browser versions, OSes or extensions to the function are appreciated

*/

var browser_name;
var browser_version;

id_browser();

/*alert('navigator.userAgent: ' + navigator.userAgent);

alert('whichBrs:' + whichBrs());

alert('navigator.appName: ' + navigator.appName);

alert('id_browser.browser_name: ' + browser_name); */

function id_browser(){
  if (navigator.userAgent.indexOf('Opera') != -1) {
      if (navigator.userAgent.indexOf('Opera/') != -1) {  // Opera as Opera
		browser_name='Opera';
		//alert('Found Opera');
		browser_version=navigator.appVersion;}
      if (navigator.userAgent.indexOf('Opera ') != -1) {   // Opera identifying as somebody else
         browser_name='Opera';
		 //alert('Found Opera2');
         temp=navigator.userAgent.split("Opera")
         browser_version=temp[1];
      }
  }else{    // if it is not opera check the others
     if (navigator.appName=="Netscape"){ // determine mozilla based version
        browser_name="Netscape";
		//alert('Found Netscape');
        browser_version=navigator.appVersion;}
     
     if (navigator.appVersion.indexOf("MSIE")!=-1){  // determine IE version
        browser_name="IE";
 		//alert('Found Opera');
        temp=navigator.appVersion.split("MSIE");
        browser_version=temp[1];}
  }
  // turn the version number into a real number
  browser_version=parseFloat(browser_version);
  return browser_name,browser_version;
}

// Browser Detection Javascript
// copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("myie2") != -1) return 'MyIE2';
if (agt.indexOf("maxthon") != -1) return 'Maxthon';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}

//Retrieves the Path of the current window and parses out the Language folder and returns it.
function getLanguage()
{
var strPath;
strPath =  window.location.toString();
var pathArray = strPath.split("/");
	//if( pathArray[3].value.toLowerCase() == "default.aspx" ||pathArray[3].value.toLowerCase() == "" )
	if( pathArray[3].value == null || pathArray[3].value.tolower() == "default.aspx")//root homepage so pass english lang folder.
		{
			return "en";
		}
	else	return pathArray[3];
}

function RunSearch()	
	{
		if ((document.Form1.searchbox.value.length != 0) && (document.Form1.searchbox.value.length <= 100)){ 
			if (document.Form1.searchbox.value == "search here") {
				
				window.location.href = "/" + getLanguage() +"/General/Search.aspx?query=" ;
				return false;
			}
			window.location.href = "/" + getLanguage() +"/General/Search.aspx?query=" + escape(document.Form1.searchbox.value);
			return false;
		}
		else{
			if (document.Form1.searchbox.value.length){
				alert("Please enter a search keyword less than 100 characters");
				document.Form1.searchbox.focus();
				return false;
			}
		}		
	}
	
function Form_TextBoxReturnClick(e, RunCode) {
	if(e && e.which){ 
                e = e;
                characterCode = e.which ;
    }
    else{                                                                            
                e = event ;                                                                      
                characterCode = e.keyCode; 
    }
    if(characterCode == 13){ 
				eval(RunCode);
                return false;
    }
    else{
                return true ;
    }
}
		
	/*This function is used when the search box in the footer gets the focus.
	If 'search here' is the text in the text box, it will be cleared, 
	otherwise all the text will be selected.
	*/
		function SafeClear(WhatEl){
			//alert(WhatEl.value.toLowerCase());
			if (WhatEl.value.toLowerCase()=='search')
			{
				WhatEl.value='';
			}
			else
			{
				WhatEl.select();
			}
		}

/* This Function is used to pop open a new window sized to iWidth and iHeight */
function popUp(URL,iWidth,iHeight,windowname)
 {
	window.open(URL,windowname,'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + iWidth + ',height=' + iHeight );
}
function OpenWin(URL,windowname, WindowProperties)
{
	window.open(URL,windowname,WindowProperties);
}
