<!--
/* Client script utility functions for Navigation control */
function getNavigationLevel() 
{
	var ctrlNavLevel = document.getElementById('navigationLevel');

	var counter = 0;
	var m_opener = window.dialogArguments;

	// Reassign window opener because of not informed ¿?
	if ("" + m_opener != "undefined") window.opener = window.dialogArguments;
	while ("" + m_opener != "undefined") 
	{
		counter++;
		try 
		{
			m_opener = m_opener.window.opener;
		}
		catch (e)
		{
			break;
		}
	}
	ctrlNavLevel.value = counter;
}

// Init, register and attach to calculate the navigation level
addEvent(window, 'load', getNavigationLevel);

var MIN_HEIGHT = 500;

function autoSizeFrame() 
{
	if (window.name == 'contentframe') 
	{
		var topframe = window.top.document.getElementById('contentframe');
		var pageHeight = document.body.scrollHeight + 20;

		// if page has subframe add the subframe top offset 
		if (window.parent != window.top) 
			pageHeight += 80;

		topframe.style.height = Math.max(pageHeight, MIN_HEIGHT);
//		alert(topframe.style.height);
		
		// if page has subframe
		if (window.parent != window.top)
		{
			// subdocument height
			var subframe = window.parent.document.getElementById('contentframe');
			var fHeight = topframe.style.height;
			var sHeight = fHeight.toString().substr(0, fHeight.length - 2);
			var iHeight = parseInt(sHeight);
			subframe.style.height = Math.max(iHeight, MIN_HEIGHT);
//			alert(subframe.style.height);
		}
	}
}

// For iframe autosize
addEvent(window, 'load', autoSizeFrame);

// OpenModaldialog
// url: the url to load into the new window
// windowOptions: window options
// eventTarget: name (postback without validation) 
function OpenModalDialog(url,windowOptions, eventTarget)
{
// Show modal dialog
if (!windowOptions) 
	{windowOptions="edge: Raised; help: No; resizable: Yes; status: No;";}

SetCursor('wait');
var oRetValue=window.showModalDialog(url, window, windowOptions);

// For each control update: we process only optional parameters
if (oRetValue!=null)
	{
	var iInit=3;
	var iRet=0;
	var sRetValues='';
	var sId=null;
	var oControl=null;
	var sType=null;
	for (i=iInit;i<arguments.length;i++)
		{
		sId=arguments[i];
		oControl=BntGet(sId);
		if (typeof(oControl)=='object')
		{
		sType=oControl.tagName;
		
		sRetValues+=oRetValue[iRet] + BNT_SEPARATOR;

		if (sType=='INPUT') // textbox
			{oControl.value=oRetValue[iRet];}
		else if (sType=='SPAN') // labels
			{oControl.innerText=oRetValue[iRet];}
		else	// el resto de controles
			{i++; oControl[arguments[i]]=oRetValue[iRet];}
		}
		iRet++;
		}
	}

// we make a postback if needed
if (eventTarget)
	{
	__doPostBack(eventTarget,sRetValues);
	}
	
//Page_ValidationActive=True;
SetCursor('');
return oRetValue;
}

//-->
