var agt=navigator.userAgent.toLowerCase();
var is_firefox = (agt.indexOf("firefox") != -1);
var is_mac = (appVer.indexOf("ppc") != -1);
var is_safari = (agt.indexOf("safari") != -1);

function searchpop(url) 
{
	nWidth = 745;
	nHeight = 520;
	if(screen.height <= 600)
	{
		nHeight = 520;
	}
	else if(screen.height <=768)
	{
		nHeight = 680;
	}
	else if(screen.height <=960)
	{
		nHeight = 730;
	}
	else
	{
		nHeight = 730;
	}

	if(is_firefox)
	{
		nHeight += 20; 
	}

	//nTop = parseInt(screen.height - nHeight)/2
	//nLeft = parseInt(screen.width - nWidth)/2

	//newwindow=window.open(url,'name','toolbar=no,menubar=no,location=no,resizable=no, left = ' + nLeft + ', top = ' +nTop + ', status=no,width='+ nWidth  + ',height=' +  nHeight+ ',scrollbars=no');
	newwindow = OpenWindow("SchoolSearch", url, nWidth, nHeight, false,false, true);
	if (newwindow.focus) {newwindow.focus()}
	return false;
}

function OpenWindow(sWinName, sURL, nWidth, nHeight, bModal,bFullScreen, bScrollBars)
{
	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. 
		if(bScrollBars)
		{
			strWinProp += ",scrollbars=yes" ;  //Displays scrollbars is document is larger than window.
		}
		else
		{
			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               

		if(bFullScreen)
		{
			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.
		}
		else
		{
			strWinProp += ",top=" + (((screen.height - 50) - nHeight) /2)  ;  //task bar height          //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(is_firefox && nWidth == screen.width)
		{
			hWin.resizeTo(nWidth, nHeight)
		}
				
		hWin.focus();

		if(hWin != null)
        {
            if(hWin.opener == null) 
            {
                hWin.opener = self;
            }
         }
		else
		{
			HandleError(4);
		}
	}

	return hWin;
}

function HandleError(nErrorCode)
{
alert("Error Code: " + nErrorCode);
}