//--------------------------Browser Detection-------------------------
var NS4 = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1 : 0;
var DOM = (document.getElementById) ? 1 : 0;

//
// Swaps the image
//
function changeImage(sName,sImage)
{
	document.images[sName].src = sImage
}


//
// Function: Open_Window
//
function open_Window(sURL, sWindowName, winWidth, winHeight) 
{
	if (winWidth == null) winWidth = 500;
	if (winHeight == null) winHeight = 350;

	// Get the screen resolution so we can center the dialog box 
	var nWidth  = window.screen.width;
	var nHeight = window.screen.height;
	var sCenter = ""; 

	if (nWidth != "" && nHeight != "")
	{
		sCenter =  ",top=" + (nHeight - winHeight) / 2; 
		sCenter += ",left=" + (nWidth - winWidth) / 2; 
	}
	newWindow = window.open(
		sURL, 
		sWindowName, 
		'width=' + winWidth + ',height=' + winHeight + 
			',scrollbars=yes,resizable=yes,toolbar=no,status=no,menubar=no' + sCenter);
}

//
// Shows the print dialog
//
function printWindow()
{  
	if (window.print) 
	{
		window.print() ;  
	} 
	else 
	{
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    
		WebBrowser1.outerHTML = "";  
	}
}

function openDialogWindowTest(sURL, winWidth, winHeight) 
{
    open_Window(sURL, 'SelectOrg', winWidth, winHeight);
}

//
// Function: openDialogWindow
//
function openDialogWindow(sURL, winWidth, winHeight) 
{
	if (winWidth == null) winWidth = 500;
	if (winHeight == null) winHeight = 500;

  leftPos=0;
  topPos=0;
  if(screen) 
  {
	leftPos=(screen.width/2)-(winWidth/2);
	topPos=(screen.height/2)-(winHeight/2);
  } 
  if (window.showModalDialog) 
  { 
	 var showWin = window.showModalDialog(sURL, null, 'status:no;dialogHeight:'+winHeight+'px;dialogWidth:'+winWidth+'px;center: yes;scroll:no;dialogLeft:'+leftPos+'dialogTop:'+topPos+';');
	 if (showWin != 'Saved'){return false;}
	 window.navigate(window.location);
  } 
  else 
  {
	 var showWin = window.open(sURL, 'new', 'width='+winWidth+',height='+winHeight+',left='+leftPos+',top='+topPos+',resizable=no,toolbar=no,status=yes,menubar=no,scrollbars=auto');
  }
}

function ShowTelerikPopup(url)
{
    ShowTelerikPopup(url, 500, 600)
    return;
}

function ShowTelerikPopup(url, width, height)
{
    var oWindow = GetRadWindowManager();
    oWindow = oWindow.Open(url, null);
    oWindow.Close();
    oWindow.SetModal(true);  
    oWindow.Show();
    oWindow.SetSize (width, height);
    oWindow.Center();
    //oWindow.SetTitle ("This is a clientside title");
    return;
}

//Get a reference to the the containing RadWindow   
function GetRadWindow()   
    {   
        var oWindow = null;   
        if (window.radWindow) oWindow = window.radWindow;   
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; 


        return oWindow;   
    }    
   
   
function CloseWin()   
    {   
        //Get the RadWindow   
        var oWindow = GetRadWindow();   
        //Call its Close() method   
        oWindow.Close();   
    }   
function ShowVirtualEarthPopup(queryString)
{
    var url = '/VirtualEarth.aspx?' + queryString;
    ShowTelerikPopup(url, 600, 650)
}

function ShowNewsPopup(queryString)
{
    var url = '/misc/NewsViewer.aspx?' + queryString;
    ShowTelerikPopup(url, 500, 400);
}

function ShowGettingStartedDoc(url)
{
    open_Window(url, null, 1000, 650);
}

//
// Function: open_Audio
//
function open_Audio(sURL) 
{
    open_Window(sURL, null, 350, 150) 
}

function openSurvey(sURL) 
{
    var winWidth = 1000;
    var winHeight = 700;
    
	// Get the screen resolution so we can center the dialog box 
	var nWidth  = window.screen.width;
	var nHeight = window.screen.height;
	var sCenter = ""; 

	if (nWidth != "" && nHeight != "")
	{
		sCenter =  ",top=" + (nHeight - winHeight) / 2; 
		sCenter += ",left=" + (nWidth - winWidth) / 2; 
	}
	newWindow = window.open(
		sURL, 
		'Survey', 
		'width=' + winWidth + ',height=' + winHeight + 
			',scrollbars=yes,resizable=yes,toolbar=yes,status=yes,menubar=yes' + sCenter);
}

//show model with scrollbars
function openDialogWindowWithScrollBars(sURL) 
{
    var winWidth = 950;
    var winHeight = 650;

  leftPos=0;
  topPos=0;
  if(screen) 
  {
    leftPos=(screen.width/2)-(winWidth/2);
    topPos=(screen.height/2)-(winHeight/2);
  } 
  if (window.showModalDialog) 
  { 
     var showWin = window.showModalDialog(sURL, null, 'status:no;dialogHeight:'+winHeight+'px;dialogWidth:'+winWidth+'px;center: yes;scroll:yes;dialogLeft:'+leftPos+'dialogTop:'+topPos+';');
     if (showWin != 'Saved'){return;}
     window.CallbackFunction();
  } 
  else 
  {
     var showWin = window.open(sURL, 'new', 'width='+winWidth+',height='+winHeight+',left='+leftPos+',top='+topPos+',resizable=yes,toolbar=no,status=yes,menubar=no,scrollbars=auto');
  }
}


// About Us Script
function openDialogWindow(sURL, winWidth, winHeight) 
{
    if (winWidth == null) winWidth = 500;
    if (winHeight == null) winHeight = 500;

  leftPos=0;
  topPos=0;
  if(screen) 
  {
    leftPos=(screen.width/2)-(winWidth/2);
    topPos=(screen.height/2)-(winHeight/2);
  } 
  if (window.showModalDialog) 
  { 
     var showWin = window.showModalDialog(sURL, null, 'status:no;dialogHeight:'+winHeight+'px;dialogWidth:'+winWidth+'px;center: yes;scroll:no;dialogLeft:'+leftPos+'dialogTop:'+topPos+';');
     if (showWin != 'Saved'){return;}
     //window.navigate(window.location);
  } 
  else 
  {
     var showWin = window.open(sURL, 'new', 'width='+winWidth+',height='+winHeight+',left='+leftPos+',top='+topPos+',resizable=no,toolbar=no,status=yes,menubar=no,scrollbars=auto');
  }
}
