//-------------------------------------
// Global javascript file
// created: 11/01/04
// last modified: 12/21/04
//-------------------------------------

function PrintIt(target) { 
  winPrint=window.open('','printwin','width=650,height=350'); 
  winPrint.document.write(target); 
  winPrint.document.close(); 
  winPrint.focus(); 
  if (window.print) winPrint.print(); 
} 

function ClosePrintIt()
{
	//window.focus();
	winPrint.close();
}

function OpenPopUpWindow(theUrl, winName, features)
{
	fooWin = window.open(theUrl, winName, features)
	if(!fooWin){
	  alert("Please turn off your pop up blocker -- or refer to our Help section.");
	}
	else
	{
		fooWin.focus();
	}
}

function ConfirmDelete(msg)
{
	returnValue = confirm(msg);
	if(returnValue)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function CloseSelfAndRefreshParent()
{
	window.opener.location.reload();
	window.opener.focus();
	window.close();
}

function CloseSelf()
{
	window.opener.focus();
	window.close();
}

function ModalWindow()
{
	//if(!window.focus())
	//{
	//	window.focus();
	//}
}

function CheckFrameIsTop()
{
	if (parent.location.href == self.location.href) 
	{
		if (window.location.href.replace)
		{
			window.location.replace('FrameMain.aspx');
		}
		else
		{
			// causes problems with back button, but works
			window.location.href = 'FrameMain.aspx';
		}
	}
}

function BreakOutOfFrame()
{
	//check if in a frame
	if (top.location != location) 
	{
		top.location.href = document.location.href;
	}
	LoadPopupPageInOpener();
}

function LoadPopupPageInOpener()
{
	//check to see if popup
	if (window.opener != null)
	{
		window.opener.location.href = window.location.href;
		window.opener.focus();
		window.close();
	}
}

function CheckLicenseAgreement()
{
	var chkVal;
	
	for (var i = 0; i < document.Form1.length; i++)
	{
		if (document.Form1.elements[i].type == 'radio' && document.Form1.elements[i].checked)
		{
			chkVal = document.Form1.elements[i].value;
		}
	}
	
	if(chkVal == "false")
	{
		var retVal = confirm("You must accept the license agreement in order to use this tool.  Click \"Cancel\" to change your selection or \"OK\" to logout.");
		if(retVal)
		{
			return true;	
		}
		else
		{
			return false;
		}
	}

}

function GoToUrl(sHref)
{
	var i, args=GoToUrl.arguments; document.sReturnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function tabsBottomSelect(tab)
{
	try
	{
		//home, reportBuilder, reportViewer, dataExporter
		top.tabsbottom.setActive(tab);
		//top.stage.location.replace(sFile + ".aspx");
	} catch(e) 
	{
		//alert(e);
	}
}

function PrintPage()
{
    window.print();
}

function disableSelection(target)
{
     if (typeof target.onselectstart!="undefined") //IE route
	      target.onselectstart=function(){return false}
     else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	       target.style.MozUserSelect="none"
     else //All other route (ie: Opera)
	       target.onmousedown=function(){return false}
     target.style.cursor = "default"
}

