function confirm_exit() {
	if ( needToConfirm ) {
		return "You have not saved changes. Do you want to continue without saving.";
	}
}

function change_made() {
	needToConfirm = true;
}

function change_remove() {
	needToConfirm = false;
}

function collapseCategories( iCount ) {
	for ( i = 1; i <= iCount; i++ ){
		document.getElementById( "section_" + i ).style.visibility = "hidden";
		document.getElementById( "section_" + i ).style.position = "absolute";
		document.getElementById( "expand_" + i ).src = "assets/icon_expand.gif";
	}
}

function delete_confirmation( strName ) {
	return confirm( "Are you sure that you want to delete '" + strName + "'?\nThis can not be undone." );
}

function default_field_clear( objField, strTxt ) {
	if( objField.value == strTxt ){
		objField.value = '';
	}
}

function expandCategories( iCount ) {
	for ( i = 1; i <= iCount; i++ ) {
		document.getElementById( "section_" + i ).style.visibility = "visible";
		document.getElementById( "section_" + i ).style.position = "static";
		document.getElementById( "expand_" + i ).src = "assets/icon_collapse.gif";
	}
}

function field_maxlength( evt, objName, iLen ) {
	var charCode = ( evt.which ) ? evt.which : event.keyCode;
	return ( ( objName.value.length < iLen ) || ( charCode == 8 ) || ( charCode == 46 ) || ( charCode == 37 ) || ( charCode == 39 ) );
}

function keycheck_numbers_only( evt ){
	var charCode = ( evt.which ) ? evt.which : event.keyCode;
	return ( ( charCode == 8 ) || ( charCode == 46 ) || ( charCode == 37 ) || ( charCode == 39 ) || ( charCode > 47 && charCode < 58 ) || ( charCode > 95 && charCode < 106 ) );
}

function remaining_text( objField, objText, iLen ){
	objText.innerHTML = "[ " + ( iLen - objField.value.length ) + " character(s) remaining ]";
}

function toggle( objButton, objFrame ){
	if ( objFrame.style.visibility == "hidden" ){
		objFrame.style.visibility = "visible";
		objFrame.style.position = "static";
		objButton.src = "assets/icon_collapse.gif";
	} else {
		objFrame.style.visibility = "hidden";
		objFrame.style.position = "absolute";
		objButton.src = "assets/icon_expand.gif";
	}
}
