//FCKeditor v2.0b2
function SelectPDF()
{
	// Set the browser window feature.
	var iWidth	= screen.width * 0.6 ;	// 60%
	var iHeight	= screen.height * 0.6 ;	// 60%
	
	var iLeft = (screen.width  - iWidth) / 2 ;
	var iTop  = (screen.height - iHeight) / 2 ;

	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
	sOptions += ",width=" + iWidth ; 
	sOptions += ",height=" + iHeight ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	// Open the browser window.
	var FCKLinkBrowser = "../FCKeditor/editor/filemanager/browser/mcpuk/browser.html?Type=PDF&Connector=connectors/aspx/connector.aspx" ;
	var oWindow = window.open( FCKLinkBrowser, "FCKBrowseWindow", sOptions ) ;
	//var oWindow = ShowDialog(FCKLinkBrowser, window, iWidth, iHeight);
}

function SelectImage(s)
{
	// Set the browser window feature.
	var iWidth	= screen.width * 0.6 ;	// 60%
	var iHeight	= screen.height * 0.6 ;	// 60%
	
	var iLeft = (screen.width  - iWidth) / 2 ;
	var iTop  = (screen.height - iHeight) / 2 ;

	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
	sOptions += ",width=" + iWidth ; 
	sOptions += ",height=" + iHeight ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	// Open the browser window.
	var FCKLinkBrowser = s + "FCKeditor/editor/filemanager/browser/mcpuk/browser.html?Type=Image&Connector=connectors/aspx/connector.aspx" ;
	var oWindow = window.open( FCKLinkBrowser, "FCKBrowseWindow", sOptions ) ;
	//var oWindow = ShowDialog(FCKLinkBrowser, window, iWidth, iHeight);
}

//Return function from file browser
function SetUrl(url)
{
	var txtExternalUrlIndex = 0;
	//Find the txtUrl textbox		
	var elem = document.forms[0].elements;
	for (var i = 0; i < elem.length; i++)
	{
		if (elem[i].type == "text" && ((elem[i].name.indexOf("txtExternalUrl") != -1) || (elem[i].name.indexOf("txtPhoto") != -1)) )
		{
			txtExternalUrlIndex = i;
			break;
		}
	}
	
	//Set if valid
	if (url.length > 0)
	{
		var txtExternalUrl = document.forms[0].elements[txtExternalUrlIndex];
		txtExternalUrl.value = url;
		txtExternalUrl.blur();
		
		//Out focus
		var btnSelect = document.forms[0].elements[txtExternalUrlIndex + 1];
		btnSelect.setActive();
		btnSelect.focus();		
	}
}

//ModalDialog wrapper
function ShowDialog(pagePath, args, width, height)
{
	return showModalDialog(pagePath, args, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
}

//Sets focus to first text box in page if found
function FocusFirstTextBox()
{
	if (document.forms[0] != null)
	{
		var e = document.forms[0].elements;
		if (e.length > 0)
		{
			//Loop thru all the avail. form elements & find a textbox.. if found we set the focus and just quit.
			for (var i=0; i<e.length; i++)
			{
				if (e[i].type == "text")
				{
					if (e[i].enabled)
					{
						e[i].focus();
						break;
					}
				}
			}
		}
	}
}

/* TreeView client functions */
/*
function ProcessClientDrop(source, dest) 
{
	if (source != null && dest != null)
	{
		if (source.Category == "ROOT")
		{
			alert("You cannot move root nodes.");
			return false;
		}
		else
		{
			return confirm("Are you sure you want to move node '" + source.Text + "' to be a child of node '" + dest.Text "'?");
		}
	}
	
	return false;
} 
*/

function EnableLongContent(chkCtrl)
{
    var e1 = document.getElementById("trAuthor");
    var e2 = document.getElementById("trLongContent");
    
    if (chkCtrl.checked)
    {
        e1.style.display = "block";
        e2.style.display = "block";
    }
    else
    {
        e1.style.display = "none";
        e2.style.display = "none";
    }
}

function ShowSecGroups(c)
{
    var e = document.getElementById("divEnablePageSecurity");
    
    if (c.checked)
        e.style.display = "block";
    else
        e.style.display = "none";
}

function DisableSecGroups(c)
{
    if (c.checked)
    {
    	if (document.forms[0] != null)
	    {
		    var e = document.forms[0].elements;
		    if (e.length > 0)
		    {
			    //Loop thru all the avail. form elements & find security checkbox.
			    for (var i=0; i<e.length; i++)
			    {
				    if (e[i].id != c.id && e[i].type == "checkbox" && e[i].id.indexOf("cblSecGroups") > -1)
				    {
				        e[i].checked = false;
					    e[i].disabled = true;					    
				    }
			    }
		    }
	    }
    }
    else
    {
    	if (document.forms[0] != null)
	    {
		    var e = document.forms[0].elements;
		    if (e.length > 0)
		    {
			    //Loop thru all the avail. form elements & find security checkbox.
			    for (var i=0; i<e.length; i++)
			    {
				    if (e[i].id != c.id && e[i].type == "checkbox" && e[i].id.indexOf("cblSecGroups") > -1)
				    {
					    e[i].disabled = false;
				    }
			    }
		    }
	    }
    }
}