<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="ClientScripting._Default" %>

<%@ Register Assembly="RadWindow.Net2" Namespace="Telerik.WebControls" TagPrefix="radW" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">

    <script>  
      function handleClick()   
      {   
        var manager = GetRadWindowManager(); 
        var windows = manager.GetWindows(); 
        var TextArea1 = document.getElementById("TextArea1");
        for(var i = 0;i<windows.length;i++)
        {
          TextArea1.value += windows[i].Name + ": " + windows[i].Url + "\n"; 
        } 
      }   
      
      function handleShowWindowClick()   
      {   
        var manager = GetRadWindowManager(); 
        var txtShowWindow = document.getElementById("txtShowWindow");
        var window1 = manager.GetWindowByName("RadWindow1"); 
        window1.SetUrl(txtShowWindow.value);
        window1.SetTitle(txtShowWindow.value);  
        window1.Show(); 
      }  
      
      function handleEntryClick()   
      {   
        var manager = GetRadWindowManager(); 
        var rwEntry = manager.GetWindowByName("rwEntry"); 
        var userObj = new Object(); 
        userObj.First = "Mr"; 
        userObj.Last = "Telerik"; 
        rwEntry.argument = userObj; 
        rwEntry.Show(); 
      }  
      
      function clientPageLoad(window)
      {
//        if (window.name = "rwEntry")
//        {      
//          var userObj = window.argument;
//          var contentWindow = window.GetContentFrame().contentWindow; 
//          contentWindow.SetName(userObj.First, userObj.Last); 
//        }
  
        LogIt("OnClientPageLoad: " + window.Name);
      }
      function clientShow(window)
      { 
        LogIt("OnClientShow: " + window.Name);
      }
      function clientClose(window)
      {
        LogIt("OnClientClose: " + window.Name);
      }
          
      function callBack(window, returnValue)
      {
        LogIt("ClientCallBackFunction: " + window.Name);
        ListProperties(returnValue); 
      }
      
      function LogIt(text)
      {
        var TextArea1 = document.getElementById("TextArea1");
        TextArea1.value += text + "\n"; 
      }
            
      function ListProperties(obj)
      {
        for (prop in obj){
          LogIt(prop + ": " + obj[prop]); 
        }
      }
    </script>

<radW:RadWindowManager ID="RadWindowManager1" runat="server" 
  ClientCallBackFunction="callBack" 
  OnClientClose="clientClose"
  OnClientPageLoad="clientPageLoad"
  OnClientShow="clientShow"
  >
      <Windows>
        <radW:RadWindow ID="RadWindow1" runat="server" Left="" NavigateUrl="http://www.telerik.com"
          SkinsPath="~/RadControls/Window/Skins" Title="Telerik Site" Top="" VisibleStatusbar="False"           
          />
        <radW:RadWindow ID="RadWindow2" runat="server" Left="" NavigateUrl="http://www.google.com"
          SkinsPath="~/RadControls/Window/Skins" Title="Google Site" Top="" VisibleStatusbar="False" />
        <radW:RadWindow ID="rwEntry" runat="server" Left="" NavigateUrl="WebForm1.aspx"
          SkinsPath="~/RadControls/Window/Skins" Title="Entry" Top="" VisibleStatusbar="False"  />
      </Windows>
    </radW:RadWindowManager>
    <textarea id="TextArea1" cols="50" rows="10"></textarea>
    <br />
    <input id="Button1" type="button" value="List Windows" onclick="handleClick();" /><br />
    <br />
    <br />
    <input id="txtShowWindow" type="text" value="http://www.yahoo.com" />
    <input id="btnShowWindow" type="button" value="Show Window" onclick="handleShowWindowClick();" /><br />
    <br />
    <br />
    <input id="btnEntry" type="button" value="Get Entry" onclick="handleEntryClick();" /><br />
    <br />
  </form>
  
</body>
</html>
