function goSetHeight() {

	if (parent == window) {

		return;
		
	}
	// arg: id of iframe element this doc is to be loaded into
	else {
		if (parent.setIframeHeightinCMDefault != null) {

			parent.setIframeHeightinCMDefault('AnotherWebsiteFrame');


		}
		if (parent.setIframeHeight != null) {
			parent.setIframeHeight('ifrm');
		}

		//get the parent of the parent window (ie. default.aspx, if there is one)
		var pp = parent.parent;
		if (pp != null) {
			if (pp.setIframeHeightinCMDefault != null) {
				pp.setIframeHeightinCMDefault('AnotherWebsiteFrame');
			}

		}

		
	}

}
//taken from cmdotnet common.js
function encodeMyHtml(strValue)
{
var  encodedHtml = strValue; 
encodedHtml = stringreplace(encodedHtml, "=", "%3F");
encodedHtml = stringreplace(encodedHtml, "+", "%2B");
encodedHtml = stringreplace(encodedHtml, "?", "%3F");
encodedHtml = stringreplace(encodedHtml, "&", "%26");
encodedHtml = stringreplace(encodedHtml, "@", "%40");
return encodedHtml;
}
//taken from cmdotnet common.js
function stringreplace(checkMe,toberep,repwith)
{

	var temp = checkMe;
	var i = temp.indexOf(toberep);
	while(i > -1)
	{
		temp = temp.replace(toberep, repwith);
		i = temp.indexOf(toberep, i + repwith.length + 1);
	}
	return temp;
}		
//based on cmdotnet common.js
function HandleSearch(evt, keywordtxtBox)
{
	if (evt.keyCode == 13)
	{
		
		if (!document.all && document.getElementById) {
			evt.preventDefault();
			evt.stopPropagation();
		}
		evt.cancelBubble = true;
		evt.returnValue = false;
		window.location.href="search.aspx?Keyword=" +  escape(encodeMyHtml(keywordtxtBox.value)) + ""
		return false;
	}
}
function is_checked_using_array(cbarray){
    //this function checks the array of checkboxes (whose names are in cbarray) if any are ticked.
    //Parameter: cbarray is an array of strings containing the checkbox names/ids to check
    //Returns true if at least 1 is ticked.
    //Returns false if none are ticked.
    
    if (cbarray != null){
        for (var i = 0; i < cbarray.length; i++){
            var cb = document.getElementById(cbarray[i]);
            if (cb.checked){
                return true;
            }
        }
        return false;
    }
}

function checkbox_items_exist(cbarray) {
    //this function checks if there is an array of checkboxes
    //Parameter: cbarray is an array of strings containing the checkbox names/ids to check
    //Returns true if at there is least 1 checkbox item
    //Returns false if no checkboxes exist
    
    if (cbarray != null) {
        if (cbarray.length > 0) {
            return true;
        }
        else {
            return false;
        }
    }
    else {
       return false;    
    }
}

function UpdateSelectedOnClick(CheckBoxIDs) {
    if (checkbox_items_exist(CheckBoxIDs)) {
        if(is_checked_using_array(CheckBoxIDs)) {
            if(!UpdateConfirm()) {
                return false;
            }
        } 
        else {
            alert('Please select an item to update');
            return false;
        }
    }
    else {
        alert('There are no items to update');
        return false;
    }
    return true;
}
function UpdateConfirm(){
    if(confirm("Are you sure you want to update?"))
    {
        return true;
    }
    else
    {
        return false;
    }
}
function SetAllCheckBoxes(CheckBoxIDs, checkbox) {
    if (checkbox_items_exist(CheckBoxIDs)) {
        var cb =document.getElementById(checkbox);
        SetCheckBoxArray(CheckBoxIDs, cb.checked);
    }
}
function SetCheckBoxArray(cbarray, value){
    //this function ticks/unticks the array of checkboxes (whose names are in cbarray)
    //Parameter: cbarray is an array of strings containing the checkbox names/ids 
    //value: true - checkboxes will be all ticked
    //       false - checkboxes will be all unticked
    //Returns:none
    
    
    if (cbarray != null){
        for (var i = 0; i < cbarray.length; i++){
            var cb = document.getElementById(cbarray[i]);
            cb.checked=value;
        }
    }
}

