function changeFrameHeight(hasErrors) {   
    try
    {
        //resize the iframe to fit the hight of the page it contains
        //parent.document.getElementById('iframe').style.height = document.getElementById('body').scrollHeight + 30;
        //scroll the parent frame to the top of the page
        if(typeof(hasErrors) == 'undefined'){
            document.body.scrollTop = 0;  
        }      
    }
    catch(err)
    {
       
    }
}

function GetRequestValue(variable, checkParent) {
  var query;
  if(checkParent){
    query = parent.location.search.substring(1);
  }else{
    query = window.location.search.substring(1);
  }
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  return "";
}

function ShowError(strErrorLabelID, strErrMessage){
    document.getElementById(strErrorLabelID).innerHTML = strErrMessage;
    if(strErrMessage != ""){
        document.getElementById(strErrorLabelID).style.display = 'block';        
        if(bErrorAlreadyHasFocus == false){
            document.getElementById(strErrorLabelID).focus(); 
            bErrorAlreadyHasFocus = true;
        }
    }else{
        document.getElementById(strErrorLabelID).style.display = 'none';
    }
}

function IsTextBoxEmpty(strTextBoxId){
//Returns true if the given text box in empty
    if(document.getElementById(strTextBoxId).value == ""){
        return true;        
    }else{
        return false;
    }    
}

function IsNoItemSelected(strGroupName){
//Returns true if no items are selected in the group name provided
    var strElementID;
	var boolNoItemSelected = true;
	var objFormElements = document.forms['form1'].elements;
    for(i=0; i<objFormElements.length; i++)
    {
		strElementID = objFormElements[i].id
		if(strElementID.indexOf(strGroupName) > -1){	
			if(objFormElements[i].checked == true){
				//at least one item is checked, stop looping
				boolNoItemSelected = false;
				i=objFormElements.length;
			}
		}
    }
    return boolNoItemSelected;
}

function RemoveBadTextBoxCharacters(strTextBoxID){
//remove bad characters in the given text box
   var strTextBoxValue = document.getElementById(strTextBoxID).value;
   strTextBoxValue = strTextBoxValue.replace(/</g, '');
   strTextBoxValue = strTextBoxValue.replace(/>/g, '');
   document.getElementById(strTextBoxID).value = strTextBoxValue;
}
