//BrowserCheck.js
//Created to Include Browser Related Checks
//Benny - 18/Aug/2004 - Start
//

//function CheckPopupSupported is used to check if popups are supported
// in the current browser.
function CheckPopupSupported()
{
	var PopupSupported = 0;
	//Fix #45561 :Altered code to remove the close popup windows message - Mandar
	try
	{	    
	    var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
        if(mine)
        {
            mine.close()
            return true;
        }
        else
            throw new Error(10001, GetMerlinMsg(12633));
	}
	catch(er)
	{		
		var strMessage = GetMerlinMsg(12510).replace("'{0}'",siteName());
		if (navigator.appName =="Microsoft Internet Explorer")
		{			
			//For XP SP2, Use a different message (attach a message to add to Trusted Zone)
			if (navigator.userAgent.indexOf("SV1") > -1)
			{
				//Commented following line as part of fix for bug# 34408 by Shardul
				//strMessage = GetMerlinMsg(12516).replace("'%1'",siteName()); 
				strMessage = FormatVBMsg(GetMerlinMsg(12516), 1, siteName());
			}			
			
			if (er.description.indexOf(GetMerlinMsg(12633)) != -1)
			{
				MerlinSystemMsg(strMessage);
				return false;
			}
			else
			{
				//MerlinSystemMsg(GetMerlinMsg(12511)); //Commented as part of fix for bug# 34408 by Shardul.
				MerlinSystemMsg(strMessage);
				return false;
			}
		}
		else if (er.message.indexOf("10001") != -1)
		{
			MerlinSystemMsg(strMessage);
			return false;
		}
		else
		{
			MerlinSystemMsg(GetMerlinMsg(12511));
			MerlinSystemMsg(strMessage);
			return false;
		}			
	}	
	return true;
}

//XmlHttp is fundamental for QuickViews, so we check it prior to login to 
//warn users
function checkXmlHttpEnabled()
{
   if (!UtilIsIe())
      return;
   
   try
   {
      var tmp = new ActiveXObject("MicroSoft.XMLHTTP");
   }
   catch (e)
   {
      //probably have ActiveX running or scripting turned off
      MerlinSystemMsg(GetMerlinMsg(12530));
      return true; //let them continue anyway
   }
   return true;
}

function checkBrowserFunctionality()
{
	if(typeof(bDisableBrowserCheck) != "undefined")
		if(bDisableBrowserCheck)
			return true;
		
   if (!CheckPopupSupported())
      return false;

   if (!checkXmlHttpEnabled())
      return false;
   
   return true;
}

function siteName() 
{
	myString = new String(document.URL);
	if (myString.indexOf("/", 8) > 0) //if there's a 3rd / in it also cut the rest of
		return myString.substring(0, myString.indexOf("/", 8));
	else
		return myString
}

//End

