
    function onTabSelecting(sender, args)
    {
		if (args.get_tab().get_pageViewID())
		{
			args.get_tab().set_postBack(false);
		}
    }

	function GetRadWindow()
	{
		var oWindow = null;
		if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
		else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz az well)				
		return oWindow;
	}
	
	function CloseOnReload()
	{
		GetRadWindow().BrowserWindow.document.location.href = GetRadWindow().BrowserWindow.document.location;
		GetRadWindow().Close();			
	}
	
	var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}


var selectedRowIndex;
var selectedRowIndexCorp;
function RowClick(rowIndex) {

    if (rowIndex == selectedRowIndex) {
        window["<%= rgMembershipOptions.ClientID %>"].MasterTableView.DeselectRow(window["<%= rgMembershipOptions.ClientID %>"].MasterTableView.Rows[rowIndex].Control);
        selectedRowIndex = -1;

        return false;
    }
}
function RowSelected(rowObject, eventObject) {

    selectedRowIndex = rowObject.Index;
}

function RowClickCorp(rowIndex) {

    if (rowIndex == selectedRowIndexCorp) {
        window["<%= rgCorporateMembershipOptions.ClientID %>"].MasterTableView.DeselectRow(window["<%= rgCorporateMembershipOptions.ClientID %>"].MasterTableView.Rows[rowIndex].Control);
        selectedRowIndexCorp = -1;
        return false;
    }
}
function RowSelectedCorp(rowObject, eventObject) {
    selectedRowIndexCorp = rowObject.Index;
}


var editorList = new Object();
//var editorLengthArray = [4000, 4000]; //Max size of ParamValue
//var counter = 0;
var maxLength = 4000;

function isAlphaNumericKey(keyCode) {
    if ((keyCode > 47 && keyCode < 58) || (keyCode > 64 && keyCode < 91)) {
        return true;
    }
    return false;
}

function LimitCharacters(editor) {

    editorList[editor.get_id()] = maxLength;
   // counter++;

    editor.attachEventHandler("onkeydown", function (e) {
        e = (e == null) ? window.event : e;
        if (isAlphaNumericKey(e.keyCode)) {
            var maxTextLength = editorList[editor.get_id()];

            textLength = editor.get_html(true).length;

            if (textLength >= maxTextLength) {
            alert(textLength);
                alert('You are not able to type more than ' + maxTextLength + ' characters!');

                e.returnValue = false;
            }
        }
    });

    var element = document.all ? editor.get_document().body : editor.get_document();
    $telerik.addExternalHandler(element, "paste", function (e) {
        e = (e == null) ? window.event : e;

        var maxTextLength = editorList[editor.get_id()];
        textLength = editor.get_html().length;

        var clipboardLength = window.clipboardData.getData("Text").length;
        textLength += clipboardLength;
        alert(textLength);
        if (textLength >= maxTextLength) {
            alert('You are not able to type more than ' + maxTextLength + ' characters!');
            e.returnValue = false;
            return false;

        }
    });
}

function CalculateLength(editor, value) {
    var textLength = editor.get_text().length;
    var clipboardLength = value.length;
    textLength += clipboardLength;
    return textLength;
}  

