var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);

// Note: On IE, start of appVersion return 3 or 4
// which supposedly is the version of Netscape it is compatible with.
// So we look for the real version further on in the string

var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
   is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
   is_major = parseInt(is_minor);
}

// Netscape6 is mozilla/5 + Netscape6/6.0!!!
// Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
var nav6Pos = agt.indexOf('netscape6');
if (nav6Pos !=-1) {
   is_minor = parseFloat(agt.substring(nav6Pos+10))
   is_major = parseInt(is_minor)
}

// Netscape 7 is mozilla/5 + Netscape/7.0
// Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
if ((agt.indexOf('mozilla') != -1) && (agt.indexOf('netscape/') != -1))
{
	is_minor = parseFloat(agt.substring(agt.indexOf('netscape/')+9))
	is_major = parseInt(is_minor)
}

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) ||
                 (agt.indexOf("; nav") != -1)) );

var is_nav6   = (is_nav && is_major==6);    // new 010118 mhp
var is_nav6up = (is_nav && is_minor >= 6) // new 010118 mhp

var is_nav5   = (is_nav && is_major == 5 && !is_nav6); // checked for ns6
var is_nav5up = (is_nav && is_minor >= 5);

var is_ie   = (iePos!=-1);
var is_ie3  = (is_ie && (is_major < 4));

var is_ie4   = (is_ie && is_major == 4);
var is_ie4up = (is_ie && is_minor >= 4);
var is_ie5   = (is_ie && is_major == 5);
var is_ie5up = (is_ie && is_minor >= 5);
var is_ie6   = (is_ie && is_major == 6);
var is_ie6up = (is_ie && is_minor >= 6);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
// or if this is the first browser window opened.  Thus the
// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.

var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);

var is_opera = (agt.indexOf("opera") != -1);
var is_webtv = (agt.indexOf("webtv") != -1);
var is_safari = (agt.indexOf("safari") != -1);
var is_mac = (appVer.indexOf("ppc") != -1);
var is_firefox = (agt.indexOf("firefox") != -1);

/*
	Jan 25-31 Carnival Test
*/
function OpenWindow(sWinName, sURL, nWidth, nHeight, bModal,bFullScreen)
{
	var nMacBugW , nMacBugH ;

	if(is_mac && ! is_safari)
	{
		nMacBugW = 0;
		nMacBugH = 0;
	}
	else
	{
		nMacBugW = 6;
		nMacBugH = 26;
	}

	if (window.showModalDialog && bModal)
	{
		var hWin = window.showModalDialog(sURL, "returnValue",'dialogWidth:' + (nWidth + nMacBugW) +'px;dialogHeight:' + (nHeight+ nMacBugH) +'px; help:no; center:yes; resizable:no; status:no; scroll:no; center:yes');
		//eval("var " + sWinName + " = window.showModalDialog(FlashcardsURL, null,'dialogWidth:526px;dialogHeight:406px; help:no; resizable:no; status:no; scroll:no; center:yes');";)
		if(hWin)	document.location = hWin;
	}
	else if (window.showModelessDialog && bModal)
	{

		var hWin = window.showModelessDialog(sURL, null,'dialogWidth:' + (nWidth + nMacBugW) +'px;dialogHeight:' + (nHeight+ nMacBugH) +'px; help:no;center:yes; resizable:no; status:no; scroll:no; center:yes');
		//eval("var " + sWinName + " = window.showModelessDialog(FlashcardsURL, null,'dialogWidth:526px;dialogHeight:406px; help:no; resizable:no; status:no; scroll:no; center:yes');";)
		hWin.focus();

		if(hWin != null)
        {
            if(hWin.opener == null)
            {
                hWin.opener = self;
            }
        }
		else
		{
			HandleError(3);
		}
	}
	else
	{
		var strWinProp = " toolbar=no" ;        //Back, Forward, etc...
		strWinProp += ",location=no" ;     //URL field
		strWinProp += ",directories=no";   //"What's New", etc...
		strWinProp += ",status=no" ;      //Status Bar at bottom of window.
		strWinProp += ",menubar=no";  //Menubar at top of window.

		if(bFullScreen)
		{
			strWinProp +=" ,fullscreen=yes";
		}
		else
		{
			strWinProp +=" ,fullscreen=no";
		}

		strWinProp += ",resizable=no" ;   //Allow resizing by dragging.
		strWinProp += ",scrollbars=no" ;  //Displays scrollbars is document is larger than window.
		strWinProp += ",titlebar=no" ;    //Enable/Disable titlebar resize capability.
		strWinProp += ",width=" + nWidth   ; //Standard 640,800/788, 800/788
		strWinProp += ",height=" + nHeight ; //Standard 480,600/541, 600/566
		strWinProp += ",top=" + ((screen.height - nHeight) /2)  ;            //Offset of windows top edge from screen.
		strWinProp += ",left=" + ((screen.width - nWidth) /2)  ;            //Offset of windows left edge from screen.
		strWinProp += ",maximize=no" ;            //Offset of windows left edge from screen.
		strWinProp += "";

		var hWin = window.open(sURL, sWinName, strWinProp);

		if(!(is_safari || is_firefox ))
		{
			//hWin.resizeTo(nWidth, nHeight)
		}

		/// resize fullscreen windows on FF


		if(hWin != null)
        {
			if(is_firefox && nWidth == screen.width)
			{
				hWin.resizeTo(nWidth, nHeight)
			}


			hWin.focus();
            if(hWin.opener == null)
            {
                hWin.opener = self;
            }
         }

	}

	return hWin;
}

