//global variables
	var objRef;
	var strUrl;
	var strMode;

	var sf= false;
	var ie=false;



function BrowserDetection(){


	
	if (navigator.userAgent.indexOf("KHTML") != -1)
	{ 
		if(navigator.userAgent.indexOf("Safari") >0)
		{	 
			if(navigator.userAgent.indexOf("4.0")!=-1){
			sf=true;
			
			}
		}	
	
	}

	if (navigator.appName.indexOf("Internet Explorer") != -1)
	{
		if(navigator.userAgent.indexOf("MSIE") >0)
		{
			if(navigator.userAgent.indexOf("7")!=-1){
			
				ie=true;
			}
		}

	}

}

	
	// ///////////////////////////////////////////////////////////////
	// OpenSaferpayTerminal
	//
	// if java script is enabled this function sets a javascript code 
	// in the executive space of the open call or calls the 
	// OpenSaferpayTerminalWindow function directly (in case of BUTTON 
	// - works only with enabled java script)
	// ///////////////////////////////////////////////////////////////
	function OpenSaferpayTerminal(url, obj, mode) 
	{
		new BrowserDetection();
		
		if(sf == false && ie == false){
			window.onerror = DoNothing;
			
	
			// open a window for these browsers:
			// tested with windows internet explorer 7 / Safari 4 Public Beta Windows and Safari 3.2.2 Windows and Opera 9.64 Windows XP
			if(
				(
					(window.navigator.appName.indexOf("Microsoft Internet Explorer") != -1 &&
						window.navigator.appVersion.substring(0,1) >= 4
					) 
					||
					(window.navigator.appName.indexOf("Netscape") != -1 &&
						window.navigator.appVersion.substring(0,1) >= 4
					)
					||
					(window.navigator.userAgent.indexOf("Opera") != -1) 
				)
			)
			{
				objRef = obj;
				strUrl = url;
				strMode = mode;
			    
				if(mode == "LINK")
				{
					obj.href = "javascript:OpenSaferpayTerminalWindow()";
				}
				else if(mode == "FORM")
				{
					if(window.navigator.appName.indexOf("Microsoft Internet Explorer") != -1 &&
						window.navigator.appVersion.substring(0,1) >= 4)
					{
					  // only explorer needs this action 
					  objRef.action  =  "javascript:OpenSaferpayTerminalWindow()";
					}
					else {	 
					  objRef.action  = "javascript:OpenSaferpayWindowJScript(" + strUrl +")";
					  OpenSaferpayWindowJScript(strUrl);
					}
				}
				else if(mode == "BUTTON")
				{
					OpenSaferpayTerminalWindow();
				}
				window.navigator.appName
			}
		}
	
	}
	






	// ///////////////////////////////////////////////////////////////
	// OpenSaferpayTerminalWindow
	//
	// the java script code that was set thru OpenSaferpayTerminal
	// function will call this function. OpenSaferpayTerminalWindow 
	// then creates the saferpay window.
	// ///////////////////////////////////////////////////////////////
	function OpenSaferpayTerminalWindow() 
	{
		window.onerror = DoNothing;

		//reset the url for the next click
		if(strMode == "LINK") objRef.href = strUrl;
	    else if(strMode == "FORM" && (window.navigator.appName.indexOf("Microsoft Internet Explorer") != -1 &&
					window.navigator.appVersion.substring(0,1) >= 4))
		     {
				  objRef.action  =  strUrl;
			 }	
		
		//add the standalone attribute to deliver the window state to the server
		if(strUrl.indexOf("WINDOWMODE=Standalone") == -1) strUrl += "&WINDOWMODE=Standalone";
	
		w = window.open(
			strUrl,
			'SaferpayTerminal',
			'scrollbars=1,resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,width=580,height=400'
		);
		
		w.focus();
	}
	
	
	// ///////////////////////////////////////////////////////////////
	// OpenSaferpayWindowJScript(strUrl)
	//
	// this function provides the open window functionality for
	// using form javascript
	// ///////////////////////////////////////////////////////////////
	function OpenSaferpayWindowJScript(strUrl) 
	{
		window.onerror = DoNothing;
		
		
		//add the standalone attribute to deliver the window state to the server
		if(strUrl.indexOf("WINDOWMODE=Standalone") == -1) strUrl += "&WINDOWMODE=Standalone";
	
		w = window.open(
			strUrl,
			'SaferpayTerminal',
			'scrollbars=1,resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,width=580,height=400'
		);
		
		w.focus();
	}
     
	// ///////////////////////////////////////////////////////////////
	// DoNothing
	//
	// error handler does nothing.
	// ///////////////////////////////////////////////////////////////
	function DoNothing(sMsg,sUrl,sLine)
	{
		//if the error handler returns true the error will not be 
		//displayed except InterDev error handling is enabled.
		return true;
	}