function updateCharCount()
{
    maxCharacters = 115;
    count = questionTextBox.value.length;
    document.getElementById("characterCount").innerHTML = maxCharacters - count;
	
    if (count >= maxCharacters)
    {
        questionTextBox.value = questionTextBox.value.substring(0, maxCharacters - 1);
    }
}

function submitenter(myfield,e,button)
{
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else
		if (e) keycode = e.which;
	else 
		return true;

	if (keycode == 13)
	{
		button.click();
		return false;
	}
	else
		return true;
}

function RegisterView()
{
    Anthem_InvokePageMethod("RegisterView", null, function() {}, null);
}

function GetUrlParameter(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
  {
    return "";
  }
  else
  {
    return results[1];
  }
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function GetRadioValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function getWindowData(width, height) 
{
    var g = typeof window.screenX!='undefined'?window.screenX:window.screenLeft;
    var h = typeof window.screenY!='undefined'?window.screenY:window.screenTop
    var f = typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth;
    var e = typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22);
    var j = width, c = height, d = parseInt(g+((f-j)/2),10), i = parseInt(h+((e-c)/2.5),10);
    
    return 'width='+j+',height='+c+',left='+d+',top='+i;
}

var w;
function openPopup(url, width, height) 
{
    var position = getWindowData(width, height);
    
    w = window.open(url, 'popupwindow', position + 'scrollbars=no,resizable=no');    
}

function closePopup() 
{
    if (w != null) 
    { 
        w.close(); 
    }
}

function CommentFocus()
{
    if (document.location.href.indexOf('#commentsList') > -1)
    {
        var commentListId = document.location.href.substring(document.location.href.indexOf('#') + 1);
        commentListId = commentListId.replace('Link', '');
        var list = document.getElementById(commentListId);
        list.style.display = 'block';
    }
}

function showComments(commentsDivId)
{
    var comments = document.getElementById(commentsDivId);
    comments.style.display = 'block';
    document.location.href = '#' + commentsDivId;
}
