function findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function swapImage() { //v3.0
  
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function swapImgRestore() { //v3.0
  	
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  
}

function login(sPartner)
{
	launchReeleezeeApplication('http://login.reeleezee.nl/default.aspx?partner='+sPartner);
}

function launchReeleezeeApplication(sFilename)
{
	var bIsWin98 = (window.navigator.userAgent.match(/Windows 9[85]/) != null);

	if (bIsWin98)
	{
		top.document.location.href = sFilename;
	}
	else
	{
		
		if (!window.oReeleezeeAppWin || window.oReeleezeeAppWin.closed)
		{
					
		
			var bToolbar		= false;
			var bLocation		= true;
			var bMenubar		= true;
			var bDirectories	= false;
			var bStatus		= false;
			var bScrollbars		= true;
			var bResizable		= true;

			var iInnerHeight;
			var iInnerWidth;
			var iOuterHeight;
			var iOuterWidth;
			var iTitlebarHeight		= 30;
			var iToolbarHeight		= 25;
			var iLocationHeight		= 25;
			var iMenubarHeight		= 25;
			var iDirectoriesHeight	= 25;
			var iStatusHeight		= 25;
			var iBottomBorderHeight	= 6;
			var iExtraCorrectionHeight = -1;
																					//															 640	 800	 800	1024	1280	1280	1400	1600
																					//															 480	 600	 570	 768	 768	1024	1050	1200
			//Determine the desired outer height									//															----	----	----	----	----	----	----	----
			iOuterHeight = Math.min(window.screen.availHeight, 600);				// 600 als het kan of minder als het moet (bijv 570 of 480)	 480	 600	 570	 600	 600	 600	 600	 600
			iOuterHeight = Math.max(iOuterHeight, window.screen.availHeight-100);	// meer als het kan, maar niet scherm vullend				 480	 600	 570	 668	 668	 924	 950	1100
			iOuterHeight = Math.min(iOuterHeight, 725); //768						// en ook niet overdreven groot op enorme beeldschermen		 480	 600	 570	 668	 668	 725	 725	 725

			//Now correct the inner height for *known* window features
			iInnerHeight = iOuterHeight;
			iInnerHeight -= iTitlebarHeight;			//always
			iInnerHeight -= bToolbar? iToolbarHeight : 0;
			iInnerHeight -= bLocation? iLocationHeight : 0;
			iInnerHeight -= bMenubar? iMenubarHeight : 0;
			iInnerHeight -= bDirectories? iDirectoriesHeight : 0;
			iInnerHeight -= iStatusHeight;				//always
			iInnerHeight -= iBottomBorderHeight;		//always
			iInnerHeight -= iExtraCorrectionHeight;		//always

			//Determine the desired outer width
			iOuterWidth = Math.min(window.screen.availWidth, 800);					// 800 als het kan of minder als het moet 	
			iOuterWidth = Math.max(iOuterWidth, window.screen.availWidth-100);		// meer als het kan, maar niet scherm vullend				
			iOuterWidth = Math.min(iOuterWidth, 950); //1024						// en ook niet overdreven groot op enorme beeldschermen		
			iInnerWidth = iOuterWidth;

			//Open the window
			try
			{
				window.oReeleezeeAppWin = window.open(

					sFilename, 
					"oReeleezeeAppWin", 
					"height="		+ iInnerHeight + "," +
					"width="		+ iInnerWidth + "," +
					"top="			+ ((window.screen.availHeight-iOuterHeight)/2) + "," +
					"left="			+ ((window.screen.availWidth-iOuterWidth)/2) + "," +
					"toolbar="		+ (bToolbar? "yes" : "no") + "," +
					"location="		+ (bLocation? "yes" : "no") + "," +
					"menubar="		+ (bMenubar? "yes" : "no") + "," +
					"directories="	+ (bDirectories? "yes" : "no") + "," +
					"status="		+ (bStatus? "yes" : "no") + "," +
					"scrollbars="	+ (bScrollbars? "yes" : "no") + "," +
					"resizable="	+ (bResizable? "yes" : "no"),
					true
				);
			}
			catch (e) 
			{
				window.oReeleezeeAppWin.focus();
			}
		}
		else
		{
			window.oReeleezeeAppWin.focus();
			window.oReeleezeeAppWin.location.replace(sFilename);
		}
		
	}
}
