/**
	 * prepares a URL for CB usage
	 *
	 * @param  string  $task
	 * @param  string  $msg
	 * @param  boolean $htmlspecialchars
	 * @param  boolean $redirect
	 * @param  string  $type
	 * @param  boolean $return
	 * @param  boolean $ajax
	 * @return string
	 */
    static public function getCBURL( $task = null, $msg = null, $htmlspecialchars = true, $redirect = false, $type = null, $return = false, $ajax = false ) {
		$plugin				=	cbgjClass::getPlugin();

		if ( is_integer( $task ) ) {
			$itemidtask		=	'userprofile';
			$task			=	( $task ? '&task=userprofile&user='******'&task=' . urlencode( $task ) : null );
		}

		$itemid				=	( $itemidtask ? getCBprofileItemid( false, $itemidtask ) : getCBprofileItemid() );
		$setReturn			=	( $return ? cbgjClass::setReturnURL() : null );
		$vars				=	$task . $itemid . $setReturn;
		$format				=	( $ajax ? 'component' : 'html' );
		$url				=	cbSef( 'index.php?option=' . $plugin->option . $vars, $htmlspecialchars, $format );

		if ( $msg ) {
			if ( $redirect ) {
				cbgjClass::setRedirect( $url, ( $msg === true ? null : $msg ), $type );
			} else {
				if ( $msg === true ) {
					$url	=	"javascript: location.href = '" . addslashes( $url ) . "';";
				} else {
					$url	=	"javascript: if ( confirm( '" . addslashes( $msg ) . "' ) ) { location.href = '" . addslashes( $url ) . "'; }";
				}
			}
		}

		return $url;
	}