<%@ Register TagPrefix="radt" Namespace="Telerik.WebControls" Assembly="RadTreeView.NET2" %>
<%@ Register TagPrefix="radts" Namespace="Telerik.WebControls" Assembly="RadTabStrip.NET2" %>
<%@ Register TagPrefix="rada" Namespace="Telerik.WebControls" Assembly="RadAjax.NET2" %>

<%@ Page CodeFile="DefaultCS.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="Telerik.AjaxIntegrationExamplesCSharp.DragDrop.DefaultCS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
	<head runat="server">
		
	<link rel="stylesheet" type="text/css" href="styles.css"></link>
	<script  type="text/javascript">
    //calculate the time before calling the function in window.onload
    beforeload = (new Date()).getTime();
    function pageloadingtime()
    {
     
            //calculate the current time in afterload 
            afterload = (new Date()).getTime();
            // now use the beforeload and afterload to calculate the seconds
            secondes = (afterload-beforeload)/1000;
            //alert the loading time
            alert('You Page Load took  ' + secondes + ' seconde(s).');
           
            
    }
      
    window.onload = pageloadingtime;
    </script>
	</head>
	<body class="BODY">
		<form id="mainForm" style="WIDTH: 100%" method="post" runat="server">
			
			<script type="text/javascript">
/*<![CDATA[*/
var blnDragging = false;

function GetRealParent(e)
{
	var target = (document.all) ? e.srcElement : e.target;
	parentNode = target;
	while (parentNode != null)
	{
		if (parentNode.id)
		{
			if (-1 !=parentNode.id.indexOf("Page1"))
			{
				return "Page1";
			}
			else if (-1 !=parentNode.id.indexOf("Page2"))
			{
				return "Page2";
			}
			else if (-1 !=parentNode.id.indexOf("Page3"))
			{
				return "Page3";
			}
		}
		parentNode = parentNode.parentNode;
	}
	return null;
}

function tabMouseOver(sender, eventArgs)
{
	if (blnDragging)
		eventArgs.Tab.Click();
}

function BeforeDragHandler()
{
	blnDragging = true;
}
	
function BeforeDropHandler(source, dest, e)
{
	blnDragging = false;
	var dropTarget = GetRealParent(e);
	if 	(dropTarget != null)
	{
		var args = source.ClientID;
		if (dest)
			args += '!' + dest.ClientID;
		source.TreeView.HtmlElementID = dropTarget; 
		window["<%= RadAjaxManager1.ClientID %>"].AjaxRequest(dropTarget + "?" + args);
	}
	return (false);
}
/*]]>*/
			</script>
			<div class="topFrame">
			<div class="bottomFrame">
			    <h3 class="files">My Files</h3>
			    <div class="innerFrame">
				<table class="skeleton">
					<tr>
						<td class="leftColumn">
						    <h4>Drag an Item over a Tab:</h4>
						<radt:RadTreeView id="RadTreeView1" Width="240" Height="400" DragAndDrop="True" ContentFile="RadTreeView.xml"
								BeforeClientDrag="BeforeDragHandler" BeforeClientDrop="BeforeDropHandler" Runat="server" Skin="Vista"></radt:RadTreeView></td>
						<td class="rightColumn">
							<radts:RadTabStrip id="RadTabStrip1" Runat="server" Height="27px" Width="465px" SelectedIndex="0" OnClientMouseOver="tabMouseOver"
								Skin="Vista" MultiPageID="multiPageContent">
								<Tabs>
									<radTS:Tab ID="Tab1" Text="Outlook" Width="90"></radTS:Tab>
									<radTS:Tab ID="Tab2" Text="Source Safe" Width="90"></radTS:Tab>
									<radTS:Tab ID="Tab3" Text="Explorer" Width="90"></radTS:Tab>
								</Tabs>
							</radts:RadTabStrip>
							<radts:RadMultiPage id="multiPageContent" Runat="server" Width="465px" SelectedIndex="0" CssClass="PageViewCss">
								<radts:PageView id="Page1" Runat="server">
									<div class="dragInstructions">
									    <p>Drag a treeview item over the tabs.</p>
									    <p>Drop items inside this area to attach them to the email.</p>
									</div>
									<table cellspacing="0" cellpadding="0" border="0">
										<tr>
											<td>To:</td>
											<td>
												<asp:TextBox id="TextBoxTo" Runat="server"></asp:TextBox></td>
											<td style="width:30px" rowspan="3">&nbsp;</td>
											<td rowspan="3">
												<asp:Button id="SendEmail" onclick="SendEmail_Click" Runat="server" CssClass="button" Text="Send "></asp:Button></td>
										</tr>
										<tr>
											<td>Cc:</td>
											<td>
												<asp:TextBox id="TextBoxCc" Runat="server"></asp:TextBox></td>
										</tr>
										<tr>
											<td>Subject:&nbsp;</td>
											<td>
												<asp:TextBox id="TextBoxSubject" Runat="server"></asp:TextBox></td>
										</tr>
									</table>
									<br/>
									<br/>
									<b>Attachments:</b><br/>
									<div style="OVERFLOW: auto; WIDTH: 300px; HEIGHT: 104px">
										<asp:Label id="Attachments" Runat="server"></asp:Label></div>
								</radts:PageView>
								<radts:PageView id="Page2" Runat="server">
									<div class="dragInstructions">
									    <p>Drag a treeview item over the tabs.</p>
									    <p>Drop items inside this area to attach them to the email.</p>
									</div>
									<radt:RadTreeView id="RadTreeView2" Runat="server" ContentFile="SourceSafe.xml"></radt:RadTreeView>
								</radts:PageView>
								<radts:PageView id="Page3" Runat="server">
									<div class="dragInstructions">
									    <p>Drag a treeview item over the tabs.</p>
									    <p>Drop items inside this area to attach them to the email.</p>
									</div>
									<div style="OVERFLOW: auto; HEIGHT: 212px">
										<asp:DataGrid id="DataGrid1" Runat="server" Width="300px" BorderStyle="None" BackColor="White"
											CellPadding="3">
											<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
											<ItemStyle ForeColor="#000066"></ItemStyle>
											<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#abc3ce"></HeaderStyle>
											<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
											<PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>
										</asp:DataGrid></div>
								</radts:PageView>
							</radts:RadMultiPage>
						</td>
					</tr>
				</table>
			</div>
			</div>
			</div>
			
			<rada:RadAjaxManager id="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
                <AjaxSettings>
                    <rada:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <UpdatedControls>
                            <rada:AjaxUpdatedControl ControlID="multiPageContent" LoadingPanelID="LoadingPanel1"></rada:AjaxUpdatedControl>
                        </UpdatedControls>
                    </rada:AjaxSetting>
                    <rada:AjaxSetting AjaxControlID="SendEmail">
                        <UpdatedControls>
                            <rada:AjaxUpdatedControl ControlID="multiPageContent" LoadingPanelID="LoadingPanel2"></rada:AjaxUpdatedControl>
                        </UpdatedControls>
                    </rada:AjaxSetting>
                </AjaxSettings>
            </rada:radajaxmanager>
            <rada:AjaxLoadingPanel id="LoadingPanel1" Runat="server" Transparency="30" BackColor="#E0E0E0">
				<asp:Image style="margin-top:10px" id="Image3" runat="server" AlternateText="Loading..." BorderWidth="0px" ImageUrl="~/RadControls/AJAX/Skins/Default/loading.gif"></asp:Image>
			</rada:AjaxLoadingPanel>
		</form>
	</body>
</html>
