var wndHandle_Arr = new Array();
var argsArr = null;

var featuresDog = "left=135,top=75,screenX=135,screenY=75,width=764,height=408,toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,directories=no,location=no";

// Initiates launch of the window.
// Any old window is closed before the new window is re-opened under the same name; this has been done for browser-compatibility purposes.
// Netscape runs this function once whereas IE runs this function twice. IE uses a two-step
// process because it needs to pause after closing the old window (before opening the new
// window), otherwise the new window may never open.
// Maybe this happens in IE because maybe the old window's thread is still closing while the
// JavaScript may be allowed to continue (unsure). What is known is the pause allows enough
// time that IE does not exhibit the weird behaviour after the pause is completed.
// Not all IEs suffer from this open/close window phenomena, but for brevity purposes I make
// all IEs go through the two-step process because all of them can without error.
// this function stors windowhandle in the global array of handles by window name

function LaunchPopup(wndName,wndTarget,wndFeatures,url,iePart2) 
{
	if (!iePart2)
		argsArr = arguments;
	ClosePopup(argsArr[0]);
    var hWndPopup = window.open(argsArr[3], argsArr[0], argsArr[2]);
	wndHandle_Arr[argsArr[0]] = hWndPopup;
	return false;
}


// Only closes the window if it appears to be opened.
function ClosePopup(wndName)
{
	// loooking foe window handle in the global array
	if (wndHandle_Arr[wndName] && (!wndHandle_Arr[wndName].closed))
	{
		wndHandle_Arr[wndName].close();
		wndHandle_Arr[wndName] = null;
		//removing window handle from the array
		delete wndHandle_Arr[wndName];
	}
	return false;
}


// function that close all open windows
function CloseAll()
{
	for (var i in wndHandle_Arr)
		ClosePopup(i);

	return false;
}

// When called, Iterate through the multi-action array and perform all actions.
function BeforePageUnload()
{
	for (var AllFunc=0;AllFunc < ArrayUnloadFunctions.length; AllFunc++)
		ArrayUnloadFunctions[AllFunc]();
}

// function
function AfterPageLoad()
{
	// Attach the CloseAll function to the beggining of array of unload function
	ArrayUnloadFunctions[ArrayUnloadFunctions.length] = CloseAll;
	
	// Attach previus window.onunload to the end of array ArrayUnloadFunctions
	// IMPORTANT: previus window.onunload event has to be the last in this array.
	if (window.onunload)
		ArrayUnloadFunctions[ArrayUnloadFunctions.length] = window.onunload;
	
	// Attach the BeforePageUnload function to the window.onunload event.
	window.onunload = BeforePageUnload;
}

// Define the multi-action array if it doesn't already exist.
if (!window.ArrayUnloadFunctions)
	window.ArrayUnloadFunctions = new Array();

function Confirm(strConfirm) 
{
	return confirm(strConfirm);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



