// JScript source code
/* cache 2 arrow images */
	imageUp = new Image();
	imageUp.src = "pictures/up.gif";
	imageDown = new Image();
	imageDown.src = "pictures/down.gif";
	
	var tabstate;
	
	var cnt;										/* for doing the loop */
	var objSpanCollection;							/* store a collecion of Menu */
	var menuHeightCollection = new Array(); 		/* store a collection of Menulists' height */
	var objMenu;	
									/* the menu is clicked on */
	function InitTab()
	{
		var tab = document.all.item(document.Form1.TabControl.value);
		if(tab != null)
			tab.className = "MyTabSelected";
	}
	
	
	function InitializeMenu() 
	{
		//alert(document.Form1.Command.value);
		
		
		
		var tab = document.all.item(document.Form1.TabControl.value);
		if(tab != null)
			tab.className = "MyTabSelected";
		
		objSpanCollection = document.body.all.MainMenu.getElementsByTagName("SPAN");
		
		var arr = new Array();
			arr = document.Form1.isLoad.value.split(":");
			for(var i = 1; i<arr.length; i++)
			{
				if(arr[i] == 0)
				{
					objSpanCollection(i-1).childNodes(1).style.display = "none";
					objSpanCollection(i-1).childNodes(1).childNodes(0).style.display = "none";
				}
			}
		
		//alert(document.getElementsByName("isLoad").value);
		//document.getElementsByName("isLoad").value = 1;
		/* get a collection of menus */
		
		for (var i = 0; i < objSpanCollection.length; i++)
		{
			
			
			//if(i > 0)
			//{
			//	objSpanCollection(i).childNodes(1).style.display = "none";
			//	objSpanCollection(i).childNodes(1).childNodes(0).style.display = "none"; 
			//}
		
			var objSpan = objSpanCollection(i);
			/* get a collection of Menus' height */
			menuHeightCollection[i] = objSpan.childNodes(1).clientHeight;
			
			/* get a collection of links inside a submenu */
			var objLinkCollection = document.body.all.MainMenu.getElementsByTagName("A");
			for (var j = 0; j < objLinkCollection.length; j++)
			{
				var objA = objLinkCollection(j);
				objA.onmouseover = ShowDescription;
				objA.onmousemove = ShowDescription;
				objA.onmouseout = HideDescription;
			}
			
			/* get a collection of links inside a submenu */
			var objInputCollection = document.body.all.MainMenu.getElementsByTagName("INPUT");
			for (var j = 0; j < objInputCollection.length; j++)
			{
				var objI = objInputCollection(j);
				if(objI.type == "text")
				{
					objI.onmouseover = ShowDescription;
					objI.onmousemove = ShowDescription;
					objI.onmouseout = HideDescription;
				}
			}
			
			/* assign the click event to every Menuheader */
			objSpan.childNodes(0).onclick = ControlMenu;
		}
		
		/* to collapse a submenu at startup change the index number of the
		objSpanCollection() to collapse the submenu you want */
		/*
		objSpanCollection(0).childNodes(1).style.display = "none";
		objSpanCollection(0).childNodes(1).childNodes(0).style.display = "none";
		*/
		
		
	}
	
	function ShowDescription()
	{	
		x = event.clientX + document.body.scrollLeft; /* get the mouse left position */
		y = event.clientY + document.body.scrollTop + 35; /* get the mouse top position  */
		this.parentNode.childNodes(this.parentNode.childNodes.length-1).style.display = "block";
		this.parentNode.childNodes(this.parentNode.childNodes.length-1).style.left = x;
		this.parentNode.childNodes(this.parentNode.childNodes.length-1).style.top = y;
	}
	
	function HideDescription()
	{
		this.parentNode.childNodes(this.parentNode.childNodes.length-1).style.display = "none";
	}
	
	function ControlMenu() 
	{
		cnt = 1;
		objMenu = this.parentNode.childNodes(1);	/* memorize the Menulist has been clicked */
		for (var i = 0; i < objSpanCollection.length; i++)
				if (objMenu.parentNode == objSpanCollection[i])
					SaveState(i);
		/* Get the arrow that belongs to the clicked menu */
		/* starting with <div> then <table> then <tbody> then <tr> then <td> and the last one is */
		/* what we need: <img> */
		var objArrow = this.childNodes(0).childNodes(0).childNodes(0).childNodes(1).childNodes(0);
		
		if (objMenu.style.display == "none")
		{
			objArrow.src = imageDown.src;  /* change to the Down Arrow */
			ShowMenu();
		}
		else
		{
			objArrow.src = imageUp.src;  /* change to the Up Arrow */
			HideMenu();
		}

	}
	
	function ShowMenu()
	{
		var objList = objMenu.childNodes(0);	// get the Linkslist of the Menulist
		if (cnt < 10)
		{
			// display the Menulist
			objMenu.style.display = "block";
			// increase the tranparency of the Menulist
			objMenu.filters["alpha"].opacity = objMenu.filters["alpha"].opacity + 20;
			// loop through the Menu collection to find the position of the clicked Menu
			// to get the actual height of the menu list and then increase the height of the Menulist
			for (var i = 0; i < objSpanCollection.length; i++)
				if (objMenu.parentNode == objSpanCollection[i])
				{
					objMenu.style.height = objMenu.clientHeight + (menuHeightCollection[i]/10);
					
				}
					   
			cnt++;
			
			cnt++;
			// do this function again after 30 miliseconds until the actual Menulist's height is returned
			setTimeout("ShowMenu()",10)
		}
		// display the Menulist if the it's actual height is returned
		if (cnt >= 10)
		{
		  	for (var i = 0; i < objSpanCollection.length; i++)
				if (objMenu.parentNode == objSpanCollection[i])
				{
					objMenu.style.height = menuHeightCollection[i];
					
				}
			objList.style.display = "block"; 
		}
	}
	
	function HideMenu()
	{	
		var objList = objMenu.childNodes(0);	// get the Linkslist of the Menulist
		if (cnt < 10)
		{
			objMenu.filters["alpha"].opacity = objMenu.filters["alpha"].opacity - 20;
			for (var i = 0; i < objSpanCollection.length; i++)
				if (objMenu.parentNode == objSpanCollection[i])
				    if (objMenu.clientHeight > menuHeightCollection[i]/10)
					objMenu.style.height = objMenu.clientHeight - (menuHeightCollection[i]/10);
			objList.style.display = "none";
			cnt++;
			cnt++;
			setTimeout("HideMenu()",1)
		}
		if (cnt >= 10)
		{
		    objMenu.style.height = 0;
			objMenu.style.display = "none";
		}
	}
	
	function SaveState(state)
	{
		//alert(state);
		var arr = new Array();
		arr = document.Form1.isLoad.value.split(":");
		//alert(arr.length);
		//var obj = this.parentNode.childNodes(1);
		
		if (objMenu.style.display == "none")
		{	
			arr[state+1] = 1;
			document.Form1.isLoad.value = "";
			for(var i = 1; i<arr.length; i++)
			{
				document.Form1.isLoad.value = document.Form1.isLoad.value + ":" + arr[i];
			}
		}
		else
		{
			arr[state+1] = 0;
			document.Form1.isLoad.value = "";
			for(var i = 1; i <arr.length; i++)
			{
				document.Form1.isLoad.value = document.Form1.isLoad.value + ":" + arr[i];
			}
		}
		
	}
	
	
	function SetCommand(command, control)
	{
		document.Form1.Command.value = command;
		document.Form1.TabControl.value = "SearchTab";
		document.Form1.LoadControlInTab.value = control;
		document.Form1.submit();
	}
	

	function ChangeState(tabID)
	{
		//alert(document.Form1.TabControl.value)
		var brevtab = document.all.item(document.Form1.TabControl.value);
		if(brevtab != null)
			brevtab.className = "MyTab";
				
		var tab = document.all.item(tabID);
		tab.className = "MyTabSelected";
		document.Form1.TabControl.value = tabID;
		document.Form1.CurentPage.value = "1";
		document.Form1.DomainID.value = "0";
		//alert(document.Form1.TabControl.value)
		document.Form1.submit();
			
	}
	
	function TabOver(tab)
	{
		//var tab = document.all.item();
		//if(tab != null)
		//alert(tab.className);
		tabstate = tab.className;
		if(tab.className != "MyTabSelected")
			tab.className = "MyTabOver";
	}
	
	function TabOut(tab)
	{
		//var tab = document.all.item();
		//if(tab != null)
		//if(tab.className == "MyTebSelected")
		//alert(tabstate);
		tab.className = tabstate;	
		//tab.className = "MyTabOut";
	}
	
	function OpenDNS(domainID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "DNSRecord";
		document.Form1.DomainID.value = domainID
		document.Form1.submit();
	}
	
	function OpenDNSInfo(domainID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "DNSInfo";
		document.Form1.DomainID.value = domainID
		document.Form1.submit();
	}
	
	function SelectRecord(obj)
	{
		document.Form1._ctl0_Record.value = obj;
	}
	
	function SelectRow(obj)
	{
		obj.className = 'SelectedRow';
		for (var i = 0; i < obj.parentNode.childNodes.length; i++)
		{
			if(obj.parentNode.childNodes[i] != obj)
				obj.parentNode.childNodes[i].className = 'UnSelectedRow';
		}
	}

	function OpenAdminDomainInfo(domainID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminDomainInfo";
		document.Form1.DomainID.value = domainID
		document.Form1.submit();
	}
	
	function OpenAdminSiteInfo(siteID, subscriptionID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminSiteInfo";
		document.Form1.DomainID.value = siteID;
		document.Form1.SubscriptionID.value = subscriptionID;
		if(siteID == 0)
			document.Form1.FirstLoadControl.value = 1;
		document.Form1.submit();
	}
	
	function OpenAdminSQLInfo(sqlDataID, subscriptionID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminSQLDataInfo";
		document.Form1.DomainID.value = sqlDataID;
		document.Form1.SubscriptionID.value = subscriptionID;
		if(sqlDataID == 0)
			document.Form1.FirstLoadControl.value = 1;
		document.Form1.submit();
	}
	function OpenAdminBindingInfo(bindingID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminBindingInfo";
		document.Form1.DomainID.value = bindingID
		document.Form1.submit();
	}

	function OpenAdminFTPInfo(ftpID, subscriptionID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminFTPInfo";
		document.Form1.DomainID.value = ftpID;
		document.Form1.SubscriptionID.value = subscriptionID;
		document.Form1.submit();
	}
	
	function OpenAdminAliasInfo(aliasID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminAliasInfo";
		document.Form1.DomainID.value = aliasID;
		document.Form1.submit();
	}
	
	function OpenAdminMailboxInfo(mailboxID, subscriptionID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminMailboxInfo";
		document.Form1.DomainID.value = mailboxID;
		document.Form1.SubscriptionID.value = subscriptionID;
		document.Form1.submit();
	}
	
	function OpenAdminSubscriptionInfo(subscriptionID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminSubscriptionInfo";
		document.Form1.DomainID.value = subscriptionID;
		document.Form1.SubscriptionID.value = subscriptionID;
		document.Form1.submit();
	}
	function OpenAdminUserInfo(userID)
	{
		//alert(userID);
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminUserInfo";
		document.Form1.DomainID.value = userID;
		document.Form1.submit();
	}

	function AddAliasToMailbox(mailboxID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AddAliasToMailbox";
		document.Form1.DomainID.value = mailboxID
		document.Form1.submit();
	}

	function AddSiteBinding(siteID)
	{
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AddSiteBinding";
		document.Form1.DomainID.value = siteID
		document.Form1.submit();
	}
	
	function SetDomainID(id, control)
	{
		//alert('sasasas');
		document.Form1.DomainID.value = id;
		document.Form1.LoadControlInTab.value = control;
	}

	function OpenAddSubscriptionToUser()
	{
		//alert('AddSubscription');
		
	}

function OpenNewUserRequestList()
	{
		//alert('OpenNewUserRequestList');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "OpenNewUserRequestList";
		//document.Form1.DomainID.value = userID;
		document.Form1.submit();
		
	}

function OpenUnPayedUserRequestList()
	{
		//alert('OpenUnPayedUserRequestList');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "UnPayedUserRequestList";
		//document.Form1.DomainID.value = userID;
		document.Form1.submit();
		
	}

function OpenPayedUserRequestList()
	{
		//alert('OpenUnPayedUserRequestList');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "PayedUserRequestList";
		//document.Form1.DomainID.value = userID;
		document.Form1.submit();
		
	}

function OpenAllUserRequestList()
	{
		//alert('OpenUnPayedUserRequestList');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AllUserRequestList";
		//document.Form1.DomainID.value = userID;
		document.Form1.submit();
		
	}
	
	function OpenNewRequestList(serviceType)
	{
		//alert('OpenUnPayedUserRequestList');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "NewRequestList";
		document.Form1.DomainID.value = serviceType;
		document.Form1.submit();
		
	}
	
	function OpenPayedRequestList(serviceType)
	{
		//alert('OpenPayedRequestList');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "PayedRequestList";
		document.Form1.DomainID.value = serviceType;
		document.Form1.submit();
		
	}
	
	function OpenUnPayedRequestList(serviceType)
	{
		//alert('OpenUnPayedUserRequestList');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "UnPayedRequestList";
		document.Form1.DomainID.value = serviceType;
		document.Form1.submit();
		
	}
	
	function OpenAllRequestList(serviceType)
	{
		//alert('OpenAllRequestList');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AllRequestList";
		document.Form1.DomainID.value = serviceType;
		document.Form1.submit();
		
	}

function OpenAdminUserRequest(requestID)
	{
		//alert('OpenAdminUserRequest');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AdminUserRequest";
		document.Form1.DomainID.value = requestID;
		document.Form1.submit();
		
	}
	
	function OpenUserRequestList()
	{
		//alert('OpenAdminUserRequest');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "UserRequestList";
		//document.Form1.DomainID.value = requestID;
		document.Form1.submit();
		
	}

function AddUserRequest(PackageID)
	{
		//alert('OpenAdminUserRequest');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AddUserRequest";
		document.Form1.DomainID.value = PackageID;
		document.Form1.submit();
	}
	
	function OpenUserAddObligation()
	{
		//alert('OpenAdminUserRequest');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "OpenUserAddObligation";
		//document.Form1.DomainID.value = PackageID;
		document.Form1.submit();
	}
	
	function OpenUserObligationInfo()
	{
		//alert('OpenAdminUserRequest');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "OpenUserObligationInfo";
		//document.Form1.DomainID.value = PackageID;
		document.Form1.submit();
	}

function AddUserRequestRenewDomain(domainID)
	{
		//alert('OpenAdminUserRequest');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "AddUserRequestRenew";
		document.Form1.DomainID.value = domainID;
		document.Form1.submit();
	}

	function OpenSettings()
	{
		//alert('OpenSettings');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "GlobalSettings";
		//document.Form1.DomainID.value = userID;
		document.Form1.submit();
		
	}

	function OpenMailLog()
	{
		//alert('OpenSettings');
		document.Form1.TabControl.value = "DataTab";
		document.Form1.LoadControlInTab.value = "MailLog";
		//document.Form1.DomainID.value = userID;
		document.Form1.submit();
		
	}
	
function GoToPage()
{
	document.Form1.CurentPage.value = document.Form1.txtCurrentPage.value;
	document.Form1.submit();
}

function ServiceWithoutObligation(url)
{
	window.open(url,'','resizable=yes, scrollbars=yes, status=yes');
}

function serviceWithExpiredPayment(url)
{
	window.open(url,'','resizable=yes, scrollbars=yes, status=yes');
}

function RealPayments(url)
{
	window.open(url,'','resizable=yes, scrollbars=yes, status=yes');
}
function DistributionPayments(url)
{
	window.open(url,'','resizable=yes, scrollbars=yes, status=yes');
}

function UnpayedObligation(url)
{
	window.open(url,'','resizable=yes, scrollbars=yes, status=yes');
}
	
