//Browser detection script.

//Holds result of detection
var is = new DetectBrowser();

function isValid(rItem){
	if (is.nav4up) return (rItem!=undefined && rItem!=null);
	else if (is.ie4up) return rItem!=null;
}

function DetectBrowser () {   
    var agt=navigator.userAgent.toLowerCase()

    this.major = parseInt(navigator.appVersion)
    this.minor = parseFloat(navigator.appVersion)
    this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)))
	this.mac  = (agt.indexOf("mac") != -1)
	this.aol  = (agt.indexOf("aol") != -1)
	this.macaol = (this.mac && this.aol)
    this.nav2 = (this.nav && (this.major == 2))
    this.nav3 = (this.nav && (this.major == 3))
    this.nav4 = (this.nav && (this.major == 4))
    this.nav5 = (this.nav && (this.major == 5)) 
    this.nav6 = (this.nav && (this.major == 5) && (navigator.userAgent.indexOf('Netscape6') != -1)) //Netscape 6+ version has this.major=5 - Needed for engine.
	this.nav7 = (this.nav && (this.major == 5) && (navigator.userAgent.indexOf('Netscape/7') != -1))    
    this.ie   = (agt.indexOf("msie") != -1)
    this.ie3  = (this.ie && (this.major == 2))
    this.ie4  = navigator.appVersion.indexOf("MSIE 4.") != -1 ? true : false;
    this.ie5  = navigator.appVersion.indexOf("MSIE 5.") != -1 ? true : false;
	this.ie6  = navigator.appVersion.indexOf("MSIE 6.") != -1 ? true : false;
    this.opera = (agt.indexOf("opera") != -1)
    this.nav4up = this.nav && (this.major == 4)
    this.nav5up = this.nav && (this.major >= 5)
    this.nav6up = this.nav && (this.major >= 5)
    this.ie4up  = (this.ie  && (this.major >= 4)) || (this.nav6up)
	this.DOM1 = (this.ie5 || this.nav6up);
}


rWindows = new Array();
rWindowNames = new Array();

//Returns a Window object to the window specified in Name, or null if it doesn't exist
function getWindow(sName)
{
	for(nWindow=0;nWindow < rWindowNames.length; nWindow++ )
		{
		if(rWindows[nWindow].closed == true)
			rWindowNames[nWindow]="";
			
		if(rWindowNames[nWindow]==sName)
			return rWindows[nWindow];
			
		}
	return null;
}

//Creates a new instance of our popup window
function openWindow(sName, sURL, sAttributes){
	rWindow = getWindow(sName);

if (sAttributes == null)
	 sAttributes ="resizable,status,scrollbars=1,width=735,height=500,top=1,left=25";

	if(rWindow == null || rWindow.closed) 
		{
 		rWindow = window.open(sURL, sName, sAttributes);
		var nTemp = rWindows.length;
		rWindows[nTemp] = rWindow;
		rWindowNames[nTemp] = sName;
		} 
		
	else if(rWindow.open && !rWindow.closed) 
		{
		// A reference already exists so focus it
		rWindow.location.href = sURL;
		rWindow.focus();
		}
}
 
 //Closes the window specified in name
function closeWindow(sName){
	var rWindow = getWindow(sName);
	
	if(rWindow != null && rWindow.open)
	  	rWindow.close();
}
  

